关于打地鼠游戏的一些说明
开发工具:MASM6.11 和 Virtual PC 2007
开发所在系统:windows 9X
一些难点和思想:
首先,由于这些所有的东西都涉及到了中断操作,所以我们的环境不能搭建在windows7下面,因为这些后面来的系统已经把安全性能提高到了很高的境界,除非你去破解他,否则是没有办法进行实值模式操作的,所以,无奈的,我们只能在98下面进行所有的操作,又因为现在的机子很多都已经不能支撑这么古老的而又让人怀念的系统了,包括驱动,反正我的两台电脑都装不了,一台是根本装不了,另外一台是没有驱动的尴尬,导致键盘不能使用,所以,我们只能选择在虚拟机环境下进行操作了,虽然虚拟机环境下面的操作感变得很差了,但是没办法了,因为我们没有办法找到更好的版本了,这些硬件都太新了,找不到十几年前的驱动是很正常的。
那好,接下在再来说下虚拟机的选择,这里一共有三个虚拟机,一个是vmware,一个是vpc,一个是vbox,第三个基本可以排除在外了,oracle对98的支持很差,开源了也不咋地。另外来说下vmware,这个是我长期使用的虚拟机,但是由于它对98的兼容性主要包括显卡驱动真的没搞好,所以会导致我在测试游戏的时候一顿一卡的,这个我也只能说忍痛割爱了,用上了vpc,vpc确实好多了,在xp下(放弃win7是因为他让我死机了N次,害我代码一直处于丢失状态。),游戏正常运行,这是一件好事。总的来说,工欲善其事,必先利其器。准备工作是非常重要的,不然你会因为前期准备不足而导致后期一直影响你的思路。
开发步骤:
首先,一个游戏要有一个界面,根据打地鼠的游戏常态来看,我们就给他个9个方格,方格之类的就用制表符进行代替,因为98和后来系统的一些词库的问题,导致我的游戏拷贝出来在win7下使用的会出现乱码现在,所以,这里开始我就不再讨论系统问题了,全部放在98下进行测试。
制表符大家可以看这些代码
1 ;//------------------------------------------
2
3 ShowTheGraph PROC
4
5 ;// 显示场地的函数
6
7 ;//------------------------------------------
8
9 .data
10
11 str1 byte "┏━━━━━┳━━━━━┳━━━━━┓",0
12
13 str3 byte "┣━━━━━╋━━━━━╋━━━━━┫",0
14
15 str4 byte "┗━━━━━┻━━━━━┻━━━━━┛",0
16
17
18
19 .code
20
21 mov dh,4
22
23 mov dl,20
24
25 call Gotoxy
26
27 mov dx,offset str1
28
29 call writestring
30
31 mov dh,9
32
33 mov dl,20
34
35 call Gotoxy
36
37 mov dx,offset str3
38
39 call WriteString
40
41 mov dh,14
42
43 mov dl,20
44
45 call gotoxy
46
47 mov dx,offset str3
48
49 call writestring
50
51 mov dh,19
52
53 mov dl,20
54
55 call gotoxy
56
57 mov dx,offset str4
58
59 call writestring
60
61 call crlf
62
63 ret
64
65 ShowTheGraph ENDP
如上函数就行进行界面显示的函数了,为了节省资源,我们对其界面显示在整个游戏时间内只进行一次,不然每次用clrscr在show一下,会导致画面延迟卡顿。这样子是跟设计相反的。当画面设计好之后,我们同样要加入两样东西,速度和分数,这是这个游戏非常关键的部分,
1 ;//------------------------------------------
2
3 ShowTheSCoreAndSpeed PROC
4
5 ;// 显示分数和速度的函数
6
7 ;//------------------------------------------
8
9 .data
10
11 str5 byte "Speed:",0
12
13 str6 byte "Score:",0
14
15 str7 byte "Hit The Mouse Game",0
16
17 .code
18
19 mov dh,0
20
21 mov dl,29
22
23 call gotoxy
24
25 mov dx,offset str7
26
27 call writestring
28
29 mov dh,2
30
31 mov dl,9
32
33 call gotoxy
34
35 mov dx,offset str6
36
37 call writestring
38
39 mov ax,ScoreOfGame
40
41 call writedec
42
43 mov dh,2
44
45 mov dl,60
46
47 call gotoxy
48
49 mov dx,offset str5
50
51 call writestring
52
53 mov eax,SpeedOfGame
54
55 call writedec
56
57 ret
58
59 ShowTheSCoreAndSpeed ENDP
这里的显示分数和速度的函数在固定位置,每次都进行刷新显示,由于分数会越来越多位,所以我们在这里不进行blank操作,显得没有意义。
好了,接下来我们界面就已经基本搭建好了,那么在接下来就是显示地鼠了,显示地鼠说来简单,就是在每个方格给每个地鼠一个固定的编号,每次显示地鼠函数去匹配那个编号,如果编号相同,那么就把被被隐藏的光标移动到指定位置,然后显示地鼠,如果地鼠在某些时候触发了一些判断语句,那么同样的,会调用一个隐藏地鼠函数,对指定位置的地鼠进行隐藏,他那个样的,代码如下:
1 ;//------------------------------------------
2
3 ShowTheMouse PROC
4
5 ;// 显示老鼠的函数
6
7 ;//------------------------------------------
8
9 .data
10
11 str31 byte " ******* ",0
12
13 str32 byte "* + + *",0
14
15 str33 byte "* = *",0
16
17 str34 byte " ******* ",0
18
19 .code
20
21 .IF MouseOfNumber == 0
22
23 mov dh,5
24
25 mov dl,22
26
27 .ENDIF
28
29 .IF MouseOfNumber == 1
30
31 mov dh,5
32
33 mov dl,34
34
35 .ENDIF
36
37 .IF MouseOfNumber == 2
38
39 mov dh,5
40
41 mov dl,45
42
43 .ENDIF
44
45 .IF MouseOfNumber == 3
46
47 mov dh,10
48
49 mov dl,22
50
51 .ENDIF
52
53 .IF MouseOfNumber == 4
54
55 mov dh,10
56
57 mov dl,34
58
59 .ENDIF
60
61 .IF MouseOfNumber == 5
62
63 mov dh,10
64
65 mov dl,45
66
67 .ENDIF
68
69 .IF MouseOfNumber == 6
70
71 mov dh,15
72
73 mov dl,22
74
75 .ENDIF
76
77 .IF MouseOfNumber == 7
78
79 mov dh,15
80
81 mov dl,34
82
83 .ENDIF
84
85 .IF MouseOfNumber == 8
86
87 mov dh,15
88
89 mov dl,45
90
91 .ENDIF
92
93 ;////*****************************show the graph of mouse
94
95 call gotoxy
96
97 push dx
98
99 mov dx,offset str31
100
101 call writestring
102
103 pop dx
104
105
106
107 inc dh
108
109 call gotoxy
110
111 push dx
112
113 mov dx,offset str32
114
115 call writestring
116
117 pop dx
118
119
120
121 inc dh
122
123 call gotoxy
124
125 push dx
126
127 mov dx,offset str33
128
129 call writestring
130
131 pop dx
132
133
134
135 inc dh
136
137 call gotoxy
138
139 push dx
140
141 mov dx,offset str34
142
143 call writestring
144
145 pop dx
146
147
148
149 ;////*****************************END Show the graph of mouse
150
151
152
153 ret
154
155 ShowTheMouse ENDP
1 ;//------------------------------------------
2
3 HideTheMouse PROC
4
5 ;// 隐藏老鼠的函数
6
7 ;//------------------------------------------
8
9 .data
10
11 Blank byte " ",0
12
13 .code
14
15 .IF MouseOfNumber == 0
16
17 mov dh,5
18
19 mov dl,22
20
21 .ENDIF
22
23 .IF MouseOfNumber == 1
24
25 mov dh,5
26
27 mov dl,34
28
29 .ENDIF
30
31 .IF MouseOfNumber == 2
32
33 mov dh,5
34
35 mov dl,45
36
37 .ENDIF
38
39 .IF MouseOfNumber == 3
40
41 mov dh,10
42
43 mov dl,22
44
45 .ENDIF
46
47 .IF MouseOfNumber == 4
48
49 mov dh,10
50
51 mov dl,34
52
53 .ENDIF
54
55 .IF MouseOfNumber == 5
56
57 mov dh,10
58
59 mov dl,45
60
61 .ENDIF
62
63 .IF MouseOfNumber == 6
64
65 mov dh,15
66
67 mov dl,22
68
69 .ENDIF
70
71 .IF MouseOfNumber == 7
72
73 mov dh,15
74
75 mov dl,34
76
77 .ENDIF
78
79 .IF MouseOfNumber == 8
80
81 mov dh,15
82
83 mov dl,45
84
85 .ENDIF
86
87 ;////*****************************Hide the graph of mouse
88
89 call gotoxy
90
91 push dx
92
93 mov dx,offset Blank
94
95 call writestring
96
97 pop dx
98
99
100
101 inc dh
102
103 call gotoxy
104
105 push dx
106
107 mov dx,offset Blank
108
109 call writestring
110
111 pop dx
112
113
114
115 inc dh
116
117 call gotoxy
118
119 push dx
120
121 mov dx,offset Blank
122
123 call writestring
124
125 pop dx
126
127
128
129 inc dh
130
131 call gotoxy
132
133 push dx
134
135 mov dx,offset Blank
136
137 call writestring
138
139 pop dx
140
141
142
143 ;////*****************************END Hide the graph of mouse
144
145 ret
146
147 HideTheMouse ENDP
刚才也提到了一个函数,那就是隐藏光标,这里的隐藏光标是用了书上来的一个例子
1 ;//------------------------------------------
2
3 HideCursor PROC
4
5 ;// 隐藏光标
6
7 ;//------------------------------------------
8
9 mov ah,3
10
11 int 10h
12
13 or ch,30h
14
15 mov ah,1
16
17 int 10h
18
19 ret
20
21 HideCursor ENDP
22
23 ;//-------------------------------------------------------
红色部分是关键,因为他把光标的大小设置为非法的值,导致了光标没有办法正常显示,这里来进行个扫盲:何为隐藏光标,大家如果正在用word看我的文档,鼠标随便点击下页面,很明显的,是不是可以看到一个闪烁的东西,同样的,在命令行界面下,当你用里面的东西输出一个文本的时候,也是会有光标一直跟随在你的文本后面的,而同样的,我们所说的图形也只不过是用文本填充出来的而已,同样的,再高级的程序,也是这样子出来的,我现在只不过是可以直接接触到他的底层而已。所以还是很有成就感的。所以当你输出完一只地鼠之后,如果看到一个光标猛闪,肯定会印象分大打折扣对不,所以用函数在适当时机,把它隐藏了是必须的。不然就不叫游戏了。
接下来如果地鼠都能正常显示以及隐藏了。最后我们就要进入到游戏的关键部分,随机函数,坐标换算,鼠标捕获等等之类的问题了,待我来为你一一解说:
随机函数,
1 ;//------------------------------------------
2
3 RendomOfMouse PROC
4
5 ;// 随机出现一个老鼠号码的函数
6
7 ;//------------------------------------------
8
9 reRendom:
10
11 call randomize
12
13 mov eax,9
14
15 call randomrange
16
17 cmp MouseOfNumber,eax
18
19 je reRendom
20
21 mov MouseOfNumber,eax
22
23 ret
24
25 RendomOfMouse ENDP
26
27 ;//------------------------------------------
随机函数对大家来说应该是没有什么技术含量了,这里就不多做叙说了,只要注意的就是只能产生九个随机数,多的那就说明函数有误了,而且函数必须是真正随机的,不然就导致地鼠重复。
坐标切换:
1 ;//------------------------------------------
2
3 TranslateTheCoord PROC
4
5 ;// 换算坐标到方格的算法
6
7 ;//------------------------------------------
8
9 mov PressMouseOfNumber,0
10
11 .IF ((Y_coord >=32) && (Y_coord <=64))
12
13 add PressMouseOfNumber,0
14
15 .ENDIF
16
17 .IF ((Y_coord >=72) && (Y_coord <=104))
18
19 add PressMouseOfNumber,3
20
21 .ENDIF
22
23 .IF ((Y_coord >=112) && (Y_coord <=144))
24
25 add PressMouseOfNumber,6
26
27 .ENDIF
28
29 .IF ((X_coord >= 168) && (X_coord <= 248))
30
31 add PressMouseOfNumber,0
32
33 .ENDIF
34
35 .IF ((X_coord >= 256) && (X_coord <= 336))
36
37 add PressMouseOfNumber,1
38
39 .ENDIF
40
41 .IF ((X_coord >= 352) && (X_coord <= 432))
42
43 add PressMouseOfNumber,2
44
45 .ENDIF
46
47 ret
48
49 TranslateTheCoord ENDP
同理,因为我们鼠标捕获的是一个坐标,是没有办法直接跟地鼠的所在位置进行匹配比较的,所以我们要把它转化成一个可以比较的东西,看图:
坐标切换可以看上图上是怎么说的,这里就不做过多的诠释了。
鼠标捕获:
;//------------------------------------------
GetMousePress PROC
;// 返回鼠标左键最后按压坐标
;//------------------------------------------
mov ax,5
mov bx,0
int 33h
test ax,1
jz skip ;//左键没有按下就跳这个
mov X_coord,cx
mov Y_coord,dx
jmp return1
skip:
mov X_coord,0
mov X_coord,0
return1:
ret
GetMousePress ENDP
鼠标捕获是根据当前鼠标缓冲区是否有右键按下,有的话就把鼠标的状态取出来放进指定的临时变量里面,如果没有的话,那么就把鼠标临时临时变量的x_coord和Y_coord全部设置为,这时候根据游戏的判断,如果都为零就判断为没有按键按下,继续循环等待按键循环,如果是已经有了的话,就进行判断是否跟地鼠的坐标一致,这些上面都已经进行完整叙述了。
接下来呢,就是整个程序的运行流程图了:
接下来是一些测试函数和一些美化函数,大家可以自己看下:
1 ;//------------------------------------------
2
3 ShowTheCoord PROC
4
5 ;// 显示坐标
6
7 ;//------------------------------------------
8
9 mov ax,3
10
11 int 33h
12
13 push dx
14
15 mov dh,22
16
17 mov dl,30
18
19 call gotoxy
20
21 pop dx
22
23 mov ax,cx
24
25 call writedec
26
27 push dx
28
29 mov dh,23
30
31 mov dl,35
32
33 call gotoxy
34
35 pop dx
36
37 mov ax,dx
38
39 call writedec
40
41 ret
42
43 ShowTheCoord ENDP
1 ;//------------------------------------------
2
3 ShowEndScreen PROC
4
5 ;// 显示结尾画面
6
7 ;//------------------------------------------
8
9 .data
10
11 AllScore byte "You Last Score is:",0
12
13 .code
14
15 call HideCursor
16
17 call clrscr
18
19 mov dh,10
20
21 mov dl,17
22
23 call gotoxy
24
25 mov dx,offset AllScore
26
27 call writestring
28
29 mov ax,ScoreOfGame
30
31 call writedec
32
33 mov eax,10000
34
35 call delay
36
37 call HideCursor
38
39 ret
40
41 ShowEndScreen ENDP
FULL.code:
TITLE The game of Assambly (.asm) ;// This program ;// Last update: INCLUDE Irvine16.inc .data SpeedOfGame dword 0 ScoreOfGame word 0 MouseOfNumber dword 8 PressMouseOfNumber dword ? TheStartTime dword ? X_coord word 0 Y_coord word 0 startgame byte "Press the Mouse Left Key to Start The game",0 madeby byte "Made By :HXH",0 onlyfor byte "Warning:This game is only ready for WIN9X.",0 toquit dword 0 .code main PROC mov ax,@data mov ds,ax call InitScreen call SetTheSpeedOfGame L1: call ShowTheGraph call ShowTheSCoreAndSpeed call RendomOfMouse call ShowTheMouse call GetMseconds mov TheStartTime,eax L2: ;//-----------------------这是循环l2的部分 call GetMousePress cmp X_coord,0 jne L3 cmp Y_coord,0 je L4 L3: ;//-----------------------这里要进行的是当坐标不为零时候应该有的Action ;//接下来进行换算,如果换算完相等的话就分数加1,否则跳入下个循环 call TranslateTheCoord mov eax,MouseOfNumber cmp eax,PressMouseOfNumber jne L4 add ScoreOfGame,1 jmp L5 ;//-----------------------EndAcion ;//-----------------------endL2 L4: call GetMseconds sub eax,TheStartTime cmp eax,SpeedOfGame jl L2 L5: call HideTheMouse call Isquit cmp toquit,1 je quit1 L6: jmp L1;//-----------------endL1 quit1: call ShowEndScreen exit main ENDP ;//------------------------------------------ ShowTheGraph PROC ;// 显示场地的函数 ;//------------------------------------------ .data str1 byte "┏━━━━━┳━━━━━┳━━━━━┓",0 str3 byte "┣━━━━━╋━━━━━╋━━━━━┫",0 str4 byte "┗━━━━━┻━━━━━┻━━━━━┛",0 .code mov dh,4 mov dl,20 call Gotoxy mov dx,offset str1 call writestring mov dh,9 mov dl,20 call Gotoxy mov dx,offset str3 call WriteString mov dh,14 mov dl,20 call gotoxy mov dx,offset str3 call writestring mov dh,19 mov dl,20 call gotoxy mov dx,offset str4 call writestring call crlf ret ShowTheGraph ENDP ;//------------------------------------------ ShowTheSCoreAndSpeed PROC ;// 显示分数和速度的函数 ;//------------------------------------------ .data str5 byte "Speed:",0 str6 byte "Score:",0 str7 byte "Hit The Mouse Game",0 .code mov dh,0 mov dl,29 call gotoxy mov dx,offset str7 call writestring mov dh,2 mov dl,9 call gotoxy mov dx,offset str6 call writestring mov ax,ScoreOfGame call writedec mov dh,2 mov dl,60 call gotoxy mov dx,offset str5 call writestring mov eax,SpeedOfGame call writedec ret ShowTheSCoreAndSpeed ENDP ;//------------------------------------------ RendomOfMouse PROC ;// 随机出现一个老鼠号码的函数 ;//------------------------------------------ reRendom: call randomize mov eax,9 call randomrange cmp MouseOfNumber,eax je reRendom mov MouseOfNumber,eax ret RendomOfMouse ENDP ;//------------------------------------------ ShowTheMouse PROC ;// 显示老鼠的函数 ;//------------------------------------------ .data str31 byte " ******* ",0 str32 byte "* + + *",0 str33 byte "* = *",0 str34 byte " ******* ",0 .code .IF MouseOfNumber == 0 mov dh,5 mov dl,22 .ENDIF .IF MouseOfNumber == 1 mov dh,5 mov dl,34 .ENDIF .IF MouseOfNumber == 2 mov dh,5 mov dl,45 .ENDIF .IF MouseOfNumber == 3 mov dh,10 mov dl,22 .ENDIF .IF MouseOfNumber == 4 mov dh,10 mov dl,34 .ENDIF .IF MouseOfNumber == 5 mov dh,10 mov dl,45 .ENDIF .IF MouseOfNumber == 6 mov dh,15 mov dl,22 .ENDIF .IF MouseOfNumber == 7 mov dh,15 mov dl,34 .ENDIF .IF MouseOfNumber == 8 mov dh,15 mov dl,45 .ENDIF ;////*****************************show the graph of mouse call gotoxy push dx mov dx,offset str31 call writestring pop dx inc dh call gotoxy push dx mov dx,offset str32 call writestring pop dx inc dh call gotoxy push dx mov dx,offset str33 call writestring pop dx inc dh call gotoxy push dx mov dx,offset str34 call writestring pop dx ;////*****************************END Show the graph of mouse ret ShowTheMouse ENDP ;//------------------------------------------ HideTheMouse PROC ;// 隐藏老鼠的函数 ;//------------------------------------------ .data Blank byte " ",0 .code .IF MouseOfNumber == 0 mov dh,5 mov dl,22 .ENDIF .IF MouseOfNumber == 1 mov dh,5 mov dl,34 .ENDIF .IF MouseOfNumber == 2 mov dh,5 mov dl,45 .ENDIF .IF MouseOfNumber == 3 mov dh,10 mov dl,22 .ENDIF .IF MouseOfNumber == 4 mov dh,10 mov dl,34 .ENDIF .IF MouseOfNumber == 5 mov dh,10 mov dl,45 .ENDIF .IF MouseOfNumber == 6 mov dh,15 mov dl,22 .ENDIF .IF MouseOfNumber == 7 mov dh,15 mov dl,34 .ENDIF .IF MouseOfNumber == 8 mov dh,15 mov dl,45 .ENDIF ;////*****************************Hide the graph of mouse call gotoxy push dx mov dx,offset Blank call writestring pop dx inc dh call gotoxy push dx mov dx,offset Blank call writestring pop dx inc dh call gotoxy push dx mov dx,offset Blank call writestring pop dx inc dh call gotoxy push dx mov dx,offset Blank call writestring pop dx ;////*****************************END Hide the graph of mouse ret HideTheMouse ENDP ;//------------------------------------------ HideCursor PROC ;// 隐藏光标 ;//------------------------------------------ mov ah,3 int 10h or ch,30h mov ah,1 int 10h ret HideCursor ENDP ;//------------------------------------------------------- GetMseconds PROC LOCAL hours:BYTE, minutes:BYTE, seconds:BYTE, hhss:BYTE ;// 返回午夜到现在逝去毫秒数 ;//-------------------------------------------------------- .data timerec TimeRecord <> mSec DWORD ? .code push ebx push ecx push edx ;// get system time (see Section 13.2.4) mov ah,2Ch int 21h mov hours,ch mov minutes,cl mov seconds,dh mov hhss,dl ;// (mSec = hours * 3600000) movzx eax,hours mov ebx,3600000 mul ebx mov mSec,eax ;// mSec = mSec + (minutes * 60000) movzx eax,minutes mov ebx,60000 mul ebx add mSec,eax ;// mSec = mSec + (seconds * 1000) movzx eax,seconds mov ebx,1000 mul ebx add mSec,eax ;// mSec = mSec + (hundredths * 10) movzx eax,hhss mov ebx,10 mul ebx add mSec,eax ;// Return mSec in EAX mov eax,mSec pop edx pop ecx pop ebx ret GetMseconds ENDP ;//------------------------------------------ GetMousePress PROC ;// 返回鼠标左键最后按压坐标 ;//------------------------------------------ mov ax,5 mov bx,0 int 33h test ax,1 jz skip ;//左键没有按下就跳这个 mov X_coord,cx mov Y_coord,dx jmp return1 skip: mov X_coord,0 mov X_coord,0 return1: ret GetMousePress ENDP ;//------------------------------------------ TranslateTheCoord PROC ;// 换算坐标到方格的算法 ;//------------------------------------------ mov PressMouseOfNumber,0 .IF ((Y_coord >=32) && (Y_coord <=64)) add PressMouseOfNumber,0 .ENDIF .IF ((Y_coord >=72) && (Y_coord <=104)) add PressMouseOfNumber,3 .ENDIF .IF ((Y_coord >=112) && (Y_coord <=144)) add PressMouseOfNumber,6 .ENDIF .IF ((X_coord >= 168) && (X_coord <= 248)) add PressMouseOfNumber,0 .ENDIF .IF ((X_coord >= 256) && (X_coord <= 336)) add PressMouseOfNumber,1 .ENDIF .IF ((X_coord >= 352) && (X_coord <= 432)) add PressMouseOfNumber,2 .ENDIF ret TranslateTheCoord ENDP ;//------------------------------------------ ShowTheCoord PROC ;// 显示坐标 ;//------------------------------------------ mov ax,3 int 33h push dx mov dh,22 mov dl,30 call gotoxy pop dx mov ax,cx call writedec push dx mov dh,23 mov dl,35 call gotoxy pop dx mov ax,dx call writedec ret ShowTheCoord ENDP ;//------------------------------------------ InitScreen PROC call HideCursor ;////------------------Begain init screen ShSt: mov dh,10 mov dl,17 call gotoxy mov dx,offset startgame call writestring mov dh,23 mov dl,62 call gotoxy mov dx,offset madeby call writestring mov dh,0 mov dl,38 call gotoxy mov dx,offset onlyfor call writestring call GetMousePress cmp ax,1 jne ShSt ;////------------------END init screen call clrscr ret InitScreen ENDP ;//------------------------------------------ SetTheSpeedOfGame PROC ;// 设置游戏速度 ;//------------------------------------------ .data Input byte "Please Input the Speed Of Game:",0 loarding byte "Now Loading the Game ",0 dot byte "|",0 .code mov dh,10 mov dl,17 call gotoxy mov dx,offset Input call writestring call readint mov SpeedOfGame,eax mov eax,2000 call delay call clrscr mov dh,10 mov dl,27 call gotoxy mov dx,offset loarding call writestring mov ecx,10 mov dh,11 mov dl,31 call gotoxy dot1: mov dx,offset dot call writestring mov eax,1000 call delay loop dot1 mov eax,1500 call delay call clrscr ret SetTheSpeedOfGame ENDP ;//------------------------------------------ Isquit PROC ;// 判断是否要退出了 ;//------------------------------------------ mov ah,11h int 16h jz nokey mov ah,10h int 16h cmp ah,1Bh mov toquit,1 nokey: ret Isquit ENDP ;//------------------------------------------ ShowEndScreen PROC ;// 显示结尾画面 ;//------------------------------------------ .data AllScore byte "You Last Score is:",0 .code call clrscr mov dh,10 mov dl,17 call gotoxy mov dx,offset AllScore call writestring mov ax,ScoreOfGame call writedec mov eax,2000 call delay call HideCursor ret ShowEndScreen ENDP END main
成果截图和视频: