打字游戏程序设计.docx

上传人:b****7 文档编号:9625678 上传时间:2023-02-05 格式:DOCX 页数:39 大小:19.92KB
下载 相关 举报
打字游戏程序设计.docx_第1页
第1页 / 共39页
打字游戏程序设计.docx_第2页
第2页 / 共39页
打字游戏程序设计.docx_第3页
第3页 / 共39页
打字游戏程序设计.docx_第4页
第4页 / 共39页
打字游戏程序设计.docx_第5页
第5页 / 共39页
点击查看更多>>
下载资源
资源描述

打字游戏程序设计.docx

《打字游戏程序设计.docx》由会员分享,可在线阅读,更多相关《打字游戏程序设计.docx(39页珍藏版)》请在冰豆网上搜索。

打字游戏程序设计.docx

打字游戏程序设计

STACKSEGMENTSTACK

DB2000DUP(0)

STACKENDS

DATASEGMENT

COPYRIGHTDB'PROGRAMEDBYqiluofei'

NUMDB'NO.012002014815$'

MENU1DB'1.STARTGAME$'

MENU2DB'2.SELECTLEVEL$'

MENU3DB'3.HELP&ABOUT$'

MENU4DB'4.EXIT$'

MENU5DB'SELECTNUMBEROFMENU:

$'

;以上部分就是主界面上显示的内容

FGFDB'===============================================$';分隔符

MENU21DB'1.VERYEASY$'

MENU22DB'2.EASY$'

MENU23DB'3.NORMAL$'

MENU24DB'4.HARD$'

MENU25DB'5.HELL!

!

$'

MENU26DB'6.RETURN$'

;这一部分是难度的选择,当在主界面中选择2后即显示以上

MEG1DB'PRESSANYKEYTOSTARTTHEGAME...$'

MEG2DB'ESC=RETURNMAINMENU$'

MEG3DB'SPACEKEY=PAUSEORRESUME$'

MEG4DB'WHENTHEGAMEWASPAUSED,PRESSQTOQUIT!

$'

;这些是游戏开始之前的提示

MEG5DB'LIVES:

$';生命数

MEG6DB'SCORE:

$';分数

OVER1DB'GAMEOVER$'

OVER2DB'PRESSENTERTORETRY$'

OVER3DB'PRESSESCTORETURNMAINMENU$'

OVER4DB'YOURFANALSCOREIS:

$'

;当生命值降低到0时,游戏结束,界面上显示以上的字符

ABOUT1DB'THISPROGRAMWASPROGRAMMEDBYLULIN$'

ABOUT2DB'ITISAPIECEOFHOMEWORK$'

ABOUT3DB'IFYOUWANTTOHAVEMOREINFORMATION$'

ABOUT4DB'CONTRACTME!

$'

ABOUT5DB'MAIL:

QILUOFEI@163.COM$'

ABOUT6DB'QQ:

158085337$'

ABOUT7DB'FINISHEDON2004/08/08$'

;这些就是游戏相关的一些介绍,还有本人的一些信息

LOADINGDB'LOADING......'

JSQDW0

SPEEDDW3000D;游戏的速度,也决定了游戏的难度

LETTERSDB78DUP(0)

;上方显示的字母

LIFEDB39H;为了使生命数显示,故用的数字的ASCII码

CHUSHUDB33

POSITIONDB1;上方字母的位置,用于控制落下的字母

TIME_MDB0

TIME_SDB0

XMULDB17

NDB26

SCORE1DB30H

SCORE2DB30H

SCORE3DB30H

SCORE4DB30H

SCORE5DB30H

SCORE6DB30H

SCORE7DB30H

SCORE8DB30H

SCORE9DB'MAX!

!

$'

LEVELDB1

MUS_FREQDW330,294,262,294,3DUP(330)

DW3DUP(294),330,392,392

DW330,294,262,294,4DUP(330)

DW294,294,330,294,262,-1

MUS_TIMEDW6DUP(25),50

DW2DUP(25,25,50)

DW12DUP(25),100

COUNTDB0

DATAENDS

;====================================================

SHUCHUMACROOP1,OP2,OP3,OP4,OP5,OP6;循环输出,用于初始化界面

MOVCX,0

MOVDH,OP1;起行

MOVDL,OP2;起列

OP6:

MOVAH,02H

MOVBH,00H

INT10H

PUSHCX

MOVAH,0AH

MOVAL,OP3;要显示的字符

MOVCX,01H

MOVBH,00H

INT10H

POPCX

INCCX

INCOP4;这里指的要循环输出的是行还是列

CMPCX,OP5;循环次数

JNEOP6

ENDM

;======================================================

MENUMACROOP1,OP2,OP3;用于屏幕上文字的输出

MOVCX,0

MOVAH,02H

MOVBH,00H

MOVDH,OP1

MOVDL,OP2

INT10H

LEADX,OP3

MOVAH,9

INT21H

ENDM

;=======================================================

CLSMACROOP1,OP2,OP3,OP4;用于清屏,分别是起止的行和列

MOVAH,6

MOVBH,17H

MOVAL,0

MOVCH,OP1

MOVCL,OP2

MOVDH,OP3

MOVDL,OP4

INT10H

MOVAH,2

MOVBH,0

MOVDH,0

MOVDL,0

INT10H

ENDM

;=======================================================

CODESEGMENT

ASSUMECS:

CODE,DS:

DATA,SS:

STACK

START:

MOVAX,DATA

MOVDS,AX

MOVPOSITION,1

MOVSPEED,3000

MOVLEVEL,1

;这里是几个数据的初始化

MOVSCORE1,30H

MOVSCORE2,30H

MOVSCORE3,30H

MOVSCORE4,30H

MOVSCORE5,30H

MOVSCORE6,30H

MOVSCORE7,30H

MOVSCORE8,30H

MOVCOUNT,0

CALLMUSIC

JM:

MOVAH,01H

MOVCX,00H

ORCH,00010000B

INT10H;置光标类型,用于隐藏光标

CLS0,0,24,79

;下面这些是界面初始化

SHUCHU0,0,08H,DL,80,OP1

SHUCHU24,0,08H,DL,80,OP2

SHUCHU0,0,08H,DH,25,OP3

SHUCHU0,79,08H,DH,25,OP4

MENU11,25,MENU1

MENU13,25,MENU2

MENU15,25,MENU3

MENU17,25,MENU4

MENU18,15,FGF

MENU19,25,MENU5

MENU21,50,COPYRIGHT

MENU22,50,NUM;界面显示完毕

CHOOSE:

MOVAH,2

MOVBH,0

MOVDH,19

MOVDL,47

INT10H;把光标放在合适的位置

MOVAH,0AH

MOVAL,""

MOVBH,00H

MOVCX,01H

INT10H;这几行是为了在选择时屏蔽其他的按键,使之不出现在屏幕上

MOVAH,1

INT21H

INPUT:

CMPAL,'1'

JEBEGIN;当输入字符是1时,跳转到BEGIN

CMPAL,'2'

JETO_SPEED_C;当输入字符是2时,跳转,由于此时不能直接跳转到SPEED_C故用了个转移

CMPAL,'3'

JETO_ABOUT

CMPAL,'4'

JETO_EXIT

CMPAL,1BH;1BH是ESC的ASCII码

JETO_EXIT_D

JMPCHOOSE

TO_ABOUT:

MOVAH,1

INT21H

CMPAL,0DH

JNETO_OTHERKEY

JMPABOUT

TO_OTHERKEY:

JMPOTHERKEY

TO_EXIT:

MOVAH,1

INT21H

CMPAL,0DH

JNETO_OTHERKEY

JMPEXIT

TO_EXIT_D:

JMPEXIT

TO_SPEED_C:

JMPSPEED_C

;=======================================================

BEGIN:

MOVAH,1

INT21H

CMPAL,0DH

JNETO_OTHERKEY

CLS1,1,23,78

PLAY_MESSAGE:

;显示有关游戏提示

MENU10,20,MEG1

MENU12,25,MEG2

MENU14,22,MEG3

MENU16,15,MEG4

MOVAH,07H

INT21H

CMPAL,1BH;按任意键继续,不把输入的字符显示在屏幕上

JETO_JM

JMPPLAY

TO_JM:

JMPJM

PLAY:

CLS1,1,23,78

MOVLIFE,39H

MOVAH,2

MOVBH,0

MOVDH,1

MOVDL,1

INT10H

MOVBX,0

LEASI,LETTERS

OUTPUT_LETTERS:

;显示上方字母

MOVAH,2CH

INT21H

MOVAL,DL

MULXMUL

ADDAX,23D

DIVN

MOVDL,AH

ADDDL,61H

MOV[SI],DL

MOVAH,2

INT21H

MOVCX,13657

callwaitf

INCSI

INCBX

CMPBX,78

JENEXT

JMPOUTPUT_LETTERS

NEXT:

MENU23,70,MEG5

MENU23,30,MEG6;生命数的相关显示

PUSHDX

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,76

INT10H

MOVAH,0AH

MOVAL,LIFE

MOVBH,0

MOVCX,1

INT10H

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,43

INT10H

MOVAH,0AH

MOVAL,SCORE1

MOVBH,0

MOVCX,1

INT10H

POPDX

JMPGAME

SUB_P:

SUBPOSITION,78

JMPGAME_NEXT

CHANGE:

MOVBL,15H

JMPTEMP

GAME:

LEASI,LETTERS

MOVAH,2CH;这是一个很简单的假随机算法,方法是读取1/100秒,虽然很不严谨,

INT21H;但是在这里效果还是比较好的,因为打字的时间不一定啊,呵呵,太复杂的我也不会了

MOVAL,DL

MOVAH,0

DIVCHUSHU

ADDPOSITION,AH

CMPPOSITION,78;和78比较,大于则减去78

JASUB_P;SUB_P在上面……确实很不好找^_^

GAME_NEXT:

ADDSI,WORDPTRPOSITION

DECSI

MOVDL,POSITION;POSITION就代表的是列

MOVAH,02H

MOVDH,1

MOVBH,0

INT10H;置光标位置

CMPCOUNT,10

JECHANGE

MOVBL,17H

TEMP:

MOVCX,0

NEXTROW:

PUSHCX

MOVCX,0

YANCHI:

;延迟

PUSHCX

MOVCX,0

YANCHI1:

ADDCX,1

CMPCX,50000D;仿佛这个方法很笨,当时还没有看有关延迟的(现在也没看...)

;这是和另外一个程序学的,好像很耗资源

JNEYANCHI1

PUSHDX

MOVAH,06H

MOVDL,0FFH

INT21H

POPDX

JZPASS;不输入则跳转PASS

CMPAL,""

JEPAUSE;空格,暂停

CMPAL,1BH

JETO_START1;ESC,返回到开始时的界面

CMPAL,[SI]

JETO_DISAPPEAR;正确输入,字母消失

PASS:

POPCX

INCCX

CMPCX,SPEED;SPEED,字母下落速度,这种方法好像不同的电脑有不同的速度,汗

JEPRINT

JMPYANCHI

TO_DISAPPEAR:

JMPDISAPPEAR

TO_START1:

JMPSTART

TO_EXIT1:

JMPEXIT

PAUSE:

PUSHDX

MOVAH,06H

MOVDL,0FFH

INT21H

POPDX

CMPAL,'Q';暂停时输入大写的Q,则退出游戏

JETO_EXIT1

CMPAL,"";再次按空格,游戏继续

JNEPAUSE

JMPPASS

PRINT:

MOVAH,0AH

MOVBH,0

MOVAL,""

MOVCX,1;在字母处用空格填上

INT10H

MOVAH,02H

MOVBH,0

INCDH

INT10H;光标下移一行

MOVAH,09H

MOVAL,[SI]

MOVBH,0

MOVCX,1

INT10H;输出字母

POPCX

INCCX

CMPCX,21;如果落到第21行还没有消失,则生命数减一,字母消失

JETO_PRINT_NEXT

JMPNEXTROW

TO_PRINT_NEXT:

CMPCOUNT,10

JECHANGE_0

JMPPRINT_NEXT

CHANGE_0:

MOVCOUNT,0

JMPPRINT_NEXT

ADD_SCORE:

MOVCOUNT,0

PUSHDX

MOVDH,SCORE2

ADDDH,LEVEL

MOVSCORE2,DH

POPDX

CMPSCORE2,39H

JATO_SCORE_3

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,42

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE2

MOVCX,1

INT10H

JMPHIT

TO_SCORE_3:

JMPSCORE_3

DISAPPEAR:

;正确输入后字母消失

POPCX

POPCX

MOVAH,0AH

MOVBH,0

MOVAL,""

MOVCX,1

INT10H

CMPCOUNT,10

JEADD_SCORE

ADDCOUNT,1

PUSHDX

MOVDH,SCORE1

ADDDH,LEVEL

MOVSCORE1,DH

POPDX

CMPSCORE1,39H

JASCORE_2

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,43

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,""

MOVCX,1

INT10H

MOVAH,0AH

MOVAL,SCORE1

MOVBH,0

MOVCX,1

INT10H

JMPHIT

SCORE_2:

SUBSCORE1,10D

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,43

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE1

MOVCX,1

INT10H

ADDSCORE2,1

CMPSCORE2,39H

JASCORE_3

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,42

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE2

MOVCX,1

INT10H

JMPHIT

SCORE_3:

SUBSCORE2,10D

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,42

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE2

MOVCX,1

INT10H

ADDSCORE3,1

CMPSCORE3,39H

JASCORE_4

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,41

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE3

MOVCX,1

INT10H

JMPHIT

SCORE_4:

SUBSCORE3,10D

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,41

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE2

MOVCX,1

INT10H

ADDSCORE4,1

CMPSCORE4,39H

JASCORE_5

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,40

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE4

MOVCX,1

INT10H

JMPHIT

SCORE_5:

SUBSCORE4,10D

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,40

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE4

MOVCX,1

INT10H

ADDSCORE5,1

CMPSCORE5,39H

JASCORE_6

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,39

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE5

MOVCX,1

INT10H

JMPHIT

SCORE_6:

SUBSCORE5,10D

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,39

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE5

MOVCX,1

INT10H

ADDSCORE6,1

CMPSCORE6,39H

JASCORE_7

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,38

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE6

MOVCX,1

INT10H

JMPHIT

SCORE_7:

SUBSCORE6,10D

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,38

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE6

MOVCX,1

INT10H

ADDSCORE7,1

CMPSCORE7,39H

JASCORE_8

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,37

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE7

MOVCX,1

INT10H

JMPHIT

SCORE_8:

SUBSCORE7,10D

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,37

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE7

MOVCX,1

INT10H

ADDSCORE8,1

CMPSCORE8,39H

JASCORE_9

MOVAH,2

MOVBH,0

MOVDH,23

MOVDL,36

INT10H

MOVAH,0AH

MOVBH,0

MOVAL,SCORE8

MOVCX,1

INT10H

JMPHIT

SCORE_9:

MENU23,26,SCORE9

JMPHIT

TO_OVER:

JMPGAME_OVER

PRINT_NEXT:

SUBLIFE,1

CMPLIFE,2FH;生命数减为0时,游戏结束

JETO_OVER

MOVAH,0AH

MOVAL,""

MOVBH,0

MOVCX,1

INT10H

MOVAH,02H

MOVDH,23

MOVDL,76

MOVBH,0

INT10H

MOVAH,0AH

MOVAL,LIFE

MOVBH,0

MOVCX,1

INT10H;更新生命数

HIT:

MOVAH,02H

MOVBH,0

MOVDH,1

MOVDL,POSITION

INT10H;重新把光标移到顶端

MOVAH,2CH

INT21H

MOVAL,DL

MULXMUL

ADDAX,23D

DIVN

ADDAH,61H

MOV[SI],AH

MOVAH,0AH

MOVBH,0

MOVCX,1

MOVAL,[SI]

INT10H;重置字母

JMPGAME

SPEED_C:

;速度选择

MOVAH,1

INT21H

CMPAL,0DH

JNEOTHERKEY

JMPSPEED_JM

OTHERKEY:

;同样是为了隐藏字符,和上面一段代码基本一样

PUSHAX

MOVAH,2

MOVBH,0

MOVDH,19

MOVDL,48

INT10H

MOVAH,0AH

MOVAL,""

MOVBH,00H

MOVCX,01H

INT10H

MOVAH,2

MOVBH,0

MOVDH,19

MOVDL,47

INT10H

POPAX

MOVDX,AX

MOVAH,2

INT21H

JMPINPUT

SPEED_JM:

;难度选择的界面

CLS1,1,23,78

MENU8,30,MENU21

MENU10,30,ME

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 金融投资

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1