用Microsoft Visual Studio 2010做一个打地鼠游戏下载!!!

其他回答(4)
我也遇到过类似的问题,但没有彻底有效的解决。
估计的一种可能情况是,代码中有BUG,导致了系统出现死锁,所以VS在发现这样的情况的时候就直接退出了。
收获园豆:2
园豆:5085
修复,重装~
收获园豆:2
园豆:1048
之前XP用VS2010一直不行 换了WIN7就没发生过问题另外 那个显卡加速 一直关掉的 因为我是集显
收获园豆:2
按 &開始/Start Menu& -& &所有程式集/All Programs& -& &Microsoft Visual Studio 2010& -& &Visual Studio 工具 / Visual Studio Tools&Right Click &Visual Studio 命令行 (2010) / Visual Studio Command Prompt (2010)&之後選擇&以管理員身份執行& / Run as Administrator&&
之後可以執行以下的指令 #將所有活動記錄至記錄檔中,以進行疑難排解。 devenv /log
#還原 Visual Studio 的預設值 devenv /resetsettings
&&&您需要以后才能回答,未注册用户请先。当前位置:
Microsoft Visual Studio 2010 旗舰版 ISO 简体中文版
Microsoft Visual Studio 2010 旗舰版是一个集成环境,它简化了有关创建、调试和部署应用程序的基本任务。借助于 Visual Studio 2010 旗舰版,您可以尽情发挥您的想象力并轻松实现您的目标。这里提供的下载地址是微软官方的下载地址,试用期限为 30 天。若选择注册软件,试用期限可延长 60 天。但是请记住:Trial(测试版)+ Key(序列号)= 正式版VS2010正版序列号:YCFHQ-9DWCY-DKV88-T2TMH-G7BHP友情提醒:VS2010的SP1补丁也出来了,可以在安装后再打上SP1补丁:
下载不了?2012年5月 专题开发/技术/项目大版内专家分月排行榜第二2010年3月 C/C++大版内专家分月排行榜第二
2012年4月 Linux/Unix社区大版内专家分月排行榜第三2011年7月 Linux/Unix社区大版内专家分月排行榜第三2010年2月 C/C++大版内专家分月排行榜第三
2012年5月 专题开发/技术/项目大版内专家分月排行榜第二2010年3月 C/C++大版内专家分月排行榜第二
2012年4月 Linux/Unix社区大版内专家分月排行榜第三2011年7月 Linux/Unix社区大版内专家分月排行榜第三2010年2月 C/C++大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。WinForm打地鼠小游戏
相关最新源码
本源码是采用WinForm进行开发的一个并非简单的打地鼠小游戏,有动画效果哈!有打地鼠、计分、过关等功能。菜单功能:1、运行游戏后,输入玩家姓名,点击开始2、用鼠标点击从洞中钻出的地鼠给予打击3、界面上方显示玩家姓名和分数,打击30个地鼠视为过关注意事项:1、开发环境为Visual Studio 2010,使用.net 4.0开发。
&&&&&&&&&&&&&&&&&&&&&&&&&
源码下载地址47被浏览5,426分享邀请回答3811 条评论分享收藏感谢收起g.sina.cn/yc/zcmtb/index?vt=4手机端的,其中game.js的逻辑大概是这样:/**
* @author fuqiang3@staff.sina.com.cn
* @fileoverview 打地鼠游戏
(function(win, doc) {
var Crafty = win.C
if (!Crafty) {
throw new Error('must have Crafty.js!');
var Events = function() {
this.map = {};
Events.prototype = {
constructor: Events,
trigger: function(name, args) {
var cbs = this.map[name];
if (cbs) {
cbs.forEach(function(fn) {
fn.apply(this, args);
on: function(name, cb) {
if (this.map[name]) {
this.map[name].push(cb);
this.map[name] = [cb];
var hitMouse = function() {
var viewConfig = {
width: 530,
this.Constant = this.initConstant();
this.config = viewC
this.prec = win.screen.width / viewConfig.
if (this.prec & 1) {
this.prec = 1;
Events.call(this);
hitMouse.Crafty = C
hitMouse.prototype = {
constructor: hitMouse,
initGame: function(config) {
this.score = 0;
this.initTimeBar();
this.initScore();
this._initHoleAndMouse(config.line, config.col);
this.bindGameEvent();
this.trigger('gameStart', [this]);
this._startMouseMove();
initMuen: function() {
var self = this,
Constant = this.Constant,
STARTBTN = Constant.STARTBTN,
LOGO = Constant.LOGO,
TITLE = Constant.TITLE;
var startBtn = Crafty.e('2D,DOM,StartBtn,Mouse').attr({
w: STARTBTN.width,
h: STARTBTN.height,
x: self.alignCenter(STARTBTN),
y: STARTBTN.marginTop
var logo = Crafty.e('2D,DOM,LOGO').attr({
w: LOGO.width,
h: LOGO.height,
x: self.alignCenter(LOGO),
y: LOGO.marginTop
var title = Crafty.e('2D,DOM,TITLE').attr({
w: TITLE.width,
h: TITLE.height,
x: self.alignCenter(TITLE),
y: TITLE.marginTop
startBtn.bind('MouseDown', function() {
startBtn.destroy();
title.destroy();
logo.destroy();
startBtn.unbind('MouseDown');
self.initGame(self.config);
initTimeBar: function() {
var self =
var Constant = this.Constant,
CLOCK = Constant.CLOCK,
GAME_TIME = Constant.GAME_TIME;
this.clock = Crafty.e('2D,DOM,CLOCK').attr({
w: CLOCK.width,
h: CLOCK.height,
x: CLOCK.marginLeft,
y: CLOCK.marginTop
var clockAttr = {
w: CLOCK.timeWidth,
h: CLOCK.timeHeight,
x: CLOCK.marginLeft + CLOCK.width,
y: CLOCK.marginTop + CLOCK.timeDifferenceTop
this.timeBarBg = Crafty.e('2D,DOM,Color').attr(clockAttr).color('#FFFFFF');
this.timeBar = Crafty.e('2D,DOM,Color').attr(clockAttr).color('#FFD227');
this.now = 0;
var t = setInterval(function() {
if (self.now &= GAME_TIME) {
self.now = 0;
self._stopMouseMove();
clearInterval(t);
self.endGame();
self.now++;
self.trigger('playing', [self.now, self]);
self.timeBar.attr({
w: CLOCK.timeWidth - ((CLOCK.timeWidth / GAME_TIME) * self.now)
initScore: function(x, y) {
var SCORE = this.Constant.SCORE;
this.scoreText = Crafty.e('2D,DOM,Text').attr({
x: x || SCORE.marginLeft,
y: y || SCORE.marginTop,
w: SCORE.width
}).textFont({
size: SCORE.FONTSIZE
}).textColor("#FFFFFF").text("得分:" + this.score);
init: function() {
var self = this,
config = this.
this._initBgMap(config.width, win.screen.height, function() {
self._initComponent();
self.initMuen();
_initHoleAndMouse: function(line, size) {
var self =
var Constant = this.Constant,
MOUSE = Constant.MOUSE,
HOLE = Constant.HOLE,
BEFORE_HOLE = Constant.BEFORE_HOLE,
MAIN_VIEW_MARGIN_TOP = Constant.MAIN_VIEW_MARGIN_TOP;
this.holes = [];
this.mouses = [];
var forCenterLeft = (self.config.width - (self.config.col - 1) * (MOUSE.marginLeft + MOUSE.width)) / 2;
this._eachMap(line, size, function(i, j) {
var HOLE1 = {
x: (HOLE.width + HOLE.marginLeft) * i,
y: (HOLE.height + HOLE.marginTop) * j,
z: HOLE.zIndex
var HOLE2 = {
x: (BEFORE_HOLE.width + BEFORE_HOLE.marginLeft) * i,
y: (BEFORE_HOLE.height + BEFORE_HOLE.marginTop) * j + BEFORE_HOLE.differenceTop,
z: BEFORE_HOLE.zIndex
var mouseAttr = {
x: (MOUSE.width + MOUSE.marginLeft) * i,
//y: (MOUSE.height + MOUSE.marginTop) * j + MOUSE.differenceTop,
y: (MOUSE.height + MOUSE.marginTop) * j + 40,
z: MOUSE.zIndex
mouseAttr.x += forCenterL
mouseAttr.y += MAIN_VIEW_MARGIN_TOP;
var mouse = Crafty.e('2D,DOM,Image,MOUSE,Tween,Mouse').attr(mouseAttr);
mouse.initY = mouseAttr.y;
HOLE1.x += forCenterL
HOLE2.x += forCenterL
HOLE1.y += MAIN_VIEW_MARGIN_TOP;
HOLE2.y += MAIN_VIEW_MARGIN_TOP;
self.holes.push([Crafty.e('2D,DOM,HOLE1').attr(HOLE1), Crafty.e('2D,DOM,HOLE2').attr(HOLE2)]);
self.mouses.push(mouse);
_initBgMap: function(width, height, cb) {
var self = this,
Constant = this.Constant,
BG = Constant.BG,
CONTAINER = Constant.CONTAINER,
MAIN_VIEW_MARGIN_TOP = Constant.MAIN_VIEW_MARGIN_TOP,
SCORE = Constant.SCORE,
assetReg = /png|jpg|jpeg|gif/;
var ASSETS = {
images: function() {
var imgs = [];
for (var i in Constant) {
if (Constant.hasOwnProperty(i)) {
for (var key in Constant[i]) {
if (Constant[i].hasOwnProperty(key)) {
if (typeof Constant[i][key] === 'string' && assetReg.test(Constant[i][key])) {
imgs.push(Constant[i][key]);
this.setDivStyle();
Crafty.init(width, height, CONTAINER.ele);
Crafty.background(BG.color +' url(' + BG.img + ') top center repeat-x');
Crafty.viewport.scale(this.prec);
var loading = Crafty.e("2D, DOM, Text").attr({
x: self.alignCenter({width:250}),
y: MAIN_VIEW_MARGIN_TOP,
}).textFont({
size: SCORE.FONTSIZE
Crafty.load(ASSETS, function() {
loading.destroy();
}, function(e) {
loading.text("资源加载中: " + parseInt(e.percent,10) + '%');
_initComponent: function() {
var Constant = this.Constant,
BEFORE_HOLE = Constant.BEFORE_HOLE,
HOLE = Constant.HOLE,
MOUSE = Constant.MOUSE,
SHAREBTN = Constant.SHAREBTN,
STARTBTN = Constant.STARTBTN,
TITLE = Constant.TITLE,
CLOCK = Constant.CLOCK,
LOGO = Constant.LOGO,
RESTART = Constant.RESTART;
Crafty.sprite(SHAREBTN.img, {
Share: [0, 0, SHAREBTN.width, SHAREBTN.height]
Crafty.sprite(TITLE.img, {
TITLE: [0, 0, TITLE.width, TITLE.height]
Crafty.sprite(LOGO.img, {
LOGO: [0, 0, LOGO.width, LOGO.height]
Crafty.sprite(RESTART.img, {
Restart: [0, 0, RESTART.width, RESTART.height]
Crafty.sprite(STARTBTN.img, {
StartBtn: [0, 0, STARTBTN.width, STARTBTN.height]
Crafty.sprite(MOUSE.img, {
MOUSE: [0, 0, MOUSE.width, MOUSE.height]
Crafty.sprite(HOLE.img, {
HOLE1: [0, 0, HOLE.width, HOLE.height]
Crafty.sprite(BEFORE_HOLE.img, {
HOLE2: [0, 0, BEFORE_HOLE.width, BEFORE_HOLE.height]
Crafty.sprite(CLOCK.img, {
CLOCK: [0, 0, CLOCK.width, CLOCK.height]
_eachMap: function(line, size, cb) {
for (i = 0; i & i++) {
for (j = 0; j & j++) {
_resetMouseY: function() {
this.mouses.forEach(function(mouse) {
mouse.attr({
y: mouse.initY
_stopMouseMove: function() {
this.gameStop =
this.trigger('gameEnd', [this.score, this]);
_startMouseMove: function() {
var self =
var Constant = this.Constant,
MOUSE_MIN = Constant.MOUSE_MIN,
MOUSE = Constant.MOUSE;
//因为长时间有偏差,重置一次位置.XXX
this.gameStop =
self._resetMouseY();
var indexs = this.getUpMouseIndexs(MOUSE_MIN - 1, self.mouses.length);
self.mouses.forEach(function(mouse, index) {
if (indexs.indexOf(index) & -1) {
var oldY = parseInt(mouse.y, 10);
var differenceTop = parseInt(MOUSE.differenceTop, 10);
mouse.tween({
y: oldY - differenceTop
}, MOUSE.tweenDelayMS).timeout(function() {
mouse.tween({
}, MOUSE.tweenDelayMS).timeout(function() {
if (index === indexs[indexs.length - 1] && self.gameStop === false) {
self._startMouseMove();
}, MOUSE.tweenDelayMS);
}, MOUSE.tweenDelayMS);
_hitMouseDown: function(my, e) {
var self =
var target = e.
var Constant = my.Constant,
SCORE = Constant.SCORE,
MOUSE = Constant.MOUSE;
if (!self.isHit && my.hasClass(target, 'MOUSE')) {
self.isHit =
my.score += SCORE.oneH
my.scoreText.text('得分:' + my.score);
my.trigger('hit', [my.score, my]);
self.image(MOUSE.hitImg);
setTimeout(function() {
self.image(MOUSE.img);
self.isHit =
bindGameEvent: function() {
var self =
this.mouses.forEach(function(mouse) {
mouse.bind('MouseDown', self._hitMouseDown.bind(mouse, self));
unbindGameEvent: function() {
var self =
this.mouses.forEach(function(mouse) {
mouse.unbind('MouseDown', self._hitMouseDown.bind(mouse, self));
_destroyMain: function() {
this.mouses.forEach(function(mouse) {
mouse.destroy();
this.holes.forEach(function(hole) {
hole[0].destroy();
hole[1].destroy();
this.timeBarBg.destroy();
this.timeBar.destroy();
this.clock.destroy();
this.scoreText.destroy();
endGame: function() {
var self =
var Constant = this.Constant,
LOGO = Constant.LOGO,
SCORE = Constant.SCORE,
SHAREBTN = Constant.SHAREBTN,
RESTART = Constant.RESTART;
this._destroyMain();
var logo = Crafty.e('2D,DOM,LOGO').attr({
w: LOGO.width,
h: LOGO.height,
x: self.alignCenter(LOGO),
y: LOGO.marginTop
this.initScore(self.alignCenter(SCORE), SCORE.endTop);
var share = Crafty.e('2D,DOM,Share,Mouse').attr({
w: SHAREBTN.width,
h: SHAREBTN.height,
x: self.alignCenter(SHAREBTN),
y: SHAREBTN.marginTop
}).bind('MouseDown', function() {
self.trigger('share', [self.score, self]);
var restart = Crafty.e('2D,DOM,Restart,Mouse').attr({
w: RESTART.width,
h: RESTART.height,
x: self.alignCenter(RESTART),
y: RESTART.marginTop
}).bind('MouseDown', function() {
restart.destroy();
logo.destroy();
share.destroy();
self.scoreText.destroy();
self.initGame(self.config);
alignCenter: function(obj) {
var width = this.config.
return (width - obj.width) / 2;
setDivStyle: function() {
var CONTAINER = this.Constant.CONTAINER;
doc.getElementById(CONTAINER.ele).style.cssText += CONTAINER.styleT
initConstant: function() {
var Constant = {
CONTAINER: {
style: 'margin:0position:relative',
ele: 'gameDiv'
GAME_TIME: 20,
MOUSE_MIN: 1,
MOUSE_MAX: 3,
MAIN_VIEW_MARGIN_TOP: 200,
color:"#E5E32C",
img: 'images/bg.jpg'
img: 'images/logo.png',
width: 101,
height: 87,
marginTop: 250
img: 'images/title.png',
width: 234,
height: 68,
marginTop: 380
RESTART: {
img: 'images/btnRestart.png',
width: 250,
height: 58,
marginTop: 500
STARTBTN: {
img: 'images/btnStart1.png',
width: 250,
height: 58,
marginTop: 500
FONTSIZE: '29px',
width: 150,
oneHit: 1,
marginLeft: 400,
marginTop: 110,
endLeft: 220,
endTop: 400
img: 'images/clock.png',
width: 60,
height: 74,
timeWidth: 400,
timeHeight: 20,
marginLeft: 25,
marginTop: 35,
timeDifferenceTop: 28
img: 'images/mouse1.png',
hitImg: 'images/mouse2.png',
width: 134,
height: 80,
zIndex: 2,
marginLeft: 10,
marginTop: 70,
differenceTop: 50,
tweenDelayMS: 1000
img: 'images/hole1.png',
width: 134,
height: 80,
zIndex: 1,
marginLeft: 10,
marginTop: 70
BEFORE_HOLE: {
img: 'images/hole2.png',
width: 134,
height: 80,
zIndex: 3,
marginLeft: 10,
marginTop: 70,
differenceTop: 40
SHAREBTN: {
img: 'images/btnShare.png',
width: 250,
height: 58,
marginTop: 600
setConstant: function(config) {
for (var name in config) {
if (this.Constant.hasOwnProperty(name)) {
for (var key in config[name]) {
if (this.Constant[name].hasOwnProperty(key)) {
this.Constant[name][key] = config[name][key];
setLineCol: function(line, col) {
this.config.line =
this.config.col =
hasClass: function(element, cls) {
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') & -1;
getRangeRandom: function(start, end) {
return Math.floor(Math.random() * (start - end + 1) + end);
getUpMouseIndexs: function(start, end) {
var Constant = this.Constant,
MOUSE_MIN = Constant.MOUSE_MIN,
MOUSE_MAX = Constant.MOUSE_MAX,
size = this.getRangeRandom(MOUSE_MIN - 1, MOUSE_MAX + 1);
var mouseIndexs = [];
while (mouseIndexs.length & size) {
var num = this.getRangeRandom(start - 1, end);
if (mouseIndexs.indexOf(num) === -1) {
mouseIndexs.push(num);
return mouseIndexs.sort();
hitMouse.prototype.trigger = Events.prototype.
hitMouse.prototype.on = Events.prototype.
var myHitMouse = new hitMouse();
myHitMouse.Constant.GAME_TIME = 1;
myHitMouse.Constant.BG.img = "images/bg.png";
myHitMouse.Constant.BG.color = "#2ee52c";
hitMouse.prototype.endGame = function(){
var self =
var Constant = this.Constant,
LOGO = Constant.LOGO,
SCORE = Constant.SCORE,
SHAREBTN = Constant.SHAREBTN,
RESTART = Constant.RESTART;
var Crafty = hitMouse.C
this._destroyMain();
var logo = Crafty.e('2D,DOM,LOGO').attr({
w: LOGO.width,
h: LOGO.height,
x: self.alignCenter(LOGO),
y: LOGO.marginTop
this.initScore(self.alignCenter(SCORE), SCORE.endTop);
var TopTitle = Crafty.e('2D,DOM,TopTitle').attr({
x:self.alignCenter({width:367}),
var share = Crafty.e('2D,DOM,Share,Mouse').attr({
w: SHAREBTN.width,
h: SHAREBTN.height,
x: self.alignCenter(SHAREBTN),
y: SHAREBTN.marginTop
}).bind('MouseDown', function() {
self.trigger('share', [self.score, self]);
var restart = Crafty.e('2D,DOM,Restart,Mouse').attr({
w: RESTART.width,
h: RESTART.height,
x: self.alignCenter(RESTART),
y: RESTART.marginTop
}).bind('MouseDown', function() {
restart.destroy();
TopTitle.destroy();
logo.destroy();
share.destroy();
self.scoreText.destroy();
self.initGame(self.config);
hitMouse.prototype.initMuen =
function() {
var self = this,
Constant = this.Constant,
STARTBTN = Constant.STARTBTN,
LOGO = Constant.LOGO,
TITLE = Constant.TITLE;
var Crafty = hitMouse.C
Crafty.sprite('images/Toptitle.png',{
TopTitle:[0,0,367,40]
var TopTitle = Crafty.e('2D,DOM,TopTitle').attr({
x:self.alignCenter({width:367}),
var startBtn = Crafty.e('2D,DOM,StartBtn,Mouse').attr({
w: STARTBTN.width,
h: STARTBTN.height,
x: self.alignCenter(STARTBTN),
y: STARTBTN.marginTop
var logo = Crafty.e('2D,DOM,LOGO').attr({
w: LOGO.width,
h: LOGO.height,
x: self.alignCenter(LOGO),
y: LOGO.marginTop
var title = Crafty.e('2D,DOM,TITLE').attr({
w: TITLE.width,
h: TITLE.height,
x: self.alignCenter(TITLE),
y: TITLE.marginTop
startBtn.bind('MouseDown', function() {
startBtn.destroy();
title.destroy();
logo.destroy();
TopTitle.destroy();
startBtn.unbind('MouseDown');
self.initGame(self.config);
myHitMouse.init();
myHitMouse.on('hit', function(score, my) {
my.now = my.now - 1;
if(my.now & my.Constant.GAME_TIME){
my.now = my.Constant.GAME_TIME;
myHitMouse.on('playing', function(now, my) {
if (now & my.Constant.GAME_TIME * (1 / 3)) {
my.Constant.MOUSE.tweenDelayMS = 800;
if (now & my.Constant.GAME_TIME * (1 / 4)) {
my.Constant.MOUSE.tweenDelayMS = 500;
myHitMouse.on('gameEnd', function(score, my) {
//console.log(my.Constant.MOUSE.tweenDelayMS);
my.Constant = my.initConstant();
//console.log(my.Constant.MOUSE.tweenDelayMS);
var MyShareClass = win.MyShareC
myHitMouse.on('share', function(score) {
//alert('点击右上角分享到朋友圈!');
win.readConfig.share.content = '我在中超媒体杯决赛中,获得了'+score+'分';
var shareCom = new MyShareClass();
shareCom.wantShare(true,function(){
alert('分享成功');
})(window, document);
使用的框架是比较原始的一款js游戏引擎,其中实现的主要逻辑简单说一下:先分3个场景,菜单,游戏,结束。每个场景的原件配置到常量中。每个原件在对应的时机初始化和注销。位置自己动态计算,或者写死。游戏的时候,时间条是2个长方形叠加实现的,时间是扣点的方式。老鼠和洞,分3层,背景洞,老鼠,前景洞,然后设置老鼠的递归运动。框架有检测点击的方法,判断一下点击到老鼠了就加一分,时间没了游戏结束,给出分数就ok了。打老鼠很简单的一款游戏,规则比较清晰,实现也不复杂,建议大家都写写试试,我的代码比较多,主要为了解耦和以后这个游戏可以改成各种不同主题的,所以看起来可能比较麻烦,设计了几个特殊的api和event。。那个android下某些机型的scale可能还有些bug。。目前还没找到太好的办法,等比缩小全屏等问题还在解决中。。32 条评论分享收藏感谢收起

我要回帖

更多关于 打地鼠游戏下载 的文章

 

随机推荐