| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2816 人关注过本帖
标题:求汇编语言编写的"贪吃蛇"游戏的源程序.谢谢!
只看楼主 加入收藏
zhy589
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-7-2
结帖率:100%
收藏
 问题点数:0 回复次数:4 
求汇编语言编写的"贪吃蛇"游戏的源程序.谢谢!



搜索更多相关主题的帖子: 贪吃蛇 汇编语言 游戏 编写 
2007-07-02 14:47
justholdon
Rank: 1
等 级:新手上路
威 望:2
帖 子:69
专家分:0
注 册:2007-4-23
收藏
得分:0 

我也再找,想研究一下,如果你找到的话,给我也发一个好不好啊
我邮箱justholdon@sina.com
谢谢了
我要是找到就会回复你的
哈哈


just hold on !
2007-07-05 22:26
爱以走远
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:52
帖 子:7542
专家分:21
注 册:2007-3-16
收藏
得分:0 
怎么说呢
偶不知道你们是怎么想的
用汇编来编
用c还可以给你
汇编的没办法 偶也编不出来
不知道你们拿去干吗
其实汇编学拉能看懂就行拉 不要求会编
除非你以后设计到计算机硬件编程

   好好活着,因为我们会死很久!!!
2007-07-06 00:26
justholdon
Rank: 1
等 级:新手上路
威 望:2
帖 子:69
专家分:0
注 册:2007-4-23
收藏
得分:0 
C的能给我一分也行啊!最好加上注释,哈哈!
先谢谢了!
油箱:justholdon@sian.com

just hold on !
2007-07-06 10:08
liang52468
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-1-10
收藏
得分:0 
name "snake"

org     100h

; jump over data section:
jmp     start

; ------ data section ------

s_size  equ     7

; the snake coordinates
; (from head to tail)
; low byte is left, high byte
; is top - [top, left]
snake dw s_size dup(0)

tail    dw      ?

; direction constants
;          (bios key codes):
left    equ     4bh
right   equ     4dh
up      equ     48h
down    equ     50h

; current snake direction:
cur_dir db      right

wait_time dw    0

; welcome message
msg     db "==== how to play ====", 0dh,0ah
    db "this game was debugged on emu8086", 0dh,0ah
    db "but it is not designed to run on the emulator", 0dh,0ah
    db "because it requires relatively fast video card and cpu.", 0dh,0ah, 0ah
    
    db "if you want to see how this game really works,", 0dh,0ah
    db "run it on a real computer (click external->run from the menu).", 0dh,0ah, 0ah
    
    db "you can control the snake using arrow keys", 0dh,0ah    
    db "all other keys will stop the snake.", 0dh,0ah, 0ah
    
    db "press esc to exit.", 0dh,0ah
    db "====================", 0dh,0ah, 0ah
    db "press any key to start...$"

; ------ code section ------

start:

; print welcome message:
mov dx, offset msg
mov ah, 9
int 21h


; wait for any key:
mov ah, 00h
int 16h


; hide text cursor:
mov     ah, 1
mov     ch, 2bh
mov     cl, 0bh
int     10h           


game_loop:

; === select first video page
mov     al, 0  ; page number.
mov     ah, 05h
int     10h

; === show new head:
mov     dx, snake[0]

; set cursor at dl,dh
mov     ah, 02h
int     10h

; print '*' at the location:
mov     al, '*'
mov     ah, 09h
mov     bl, 0eh ; attribute.
mov     cx, 1   ; single char.
int     10h

; === keep the tail:
mov     ax, snake[s_size * 2 - 2]
mov     tail, ax

call    move_snake


; === hide old tail:
mov     dx, tail

; set cursor at dl,dh
mov     ah, 02h
int     10h

; print ' ' at the location:
mov     al, ' '
mov     ah, 09h
mov     bl, 0eh ; attribute.
mov     cx, 1   ; single char.
int     10h



check_for_key:

; === check for player commands:
mov     ah, 01h
int     16h
jz      no_key

mov     ah, 00h
int     16h

cmp     al, 1bh    ; esc - key?
je      stop_game  ;

mov     cur_dir, ah

no_key:



; === wait a few moments here:
; get number of clock ticks
; (about 18 per second)
; since midnight into cx:dx
mov     ah, 00h
int     1ah
cmp     dx, wait_time
jb      check_for_key
add     dx, 4
mov     wait_time, dx



; === eternal game loop:
jmp     game_loop


stop_game:

; show cursor back:
mov     ah, 1
mov     ch, 0bh
mov     cl, 0bh
int     10h

ret

; ------ functions section ------

; this procedure creates the
; animation by moving all snake
; body parts one step to tail,
; the old tail goes away:
; [last part (tail)]-> goes away
; [part i] -> [part i+1]
; ....

move_snake proc near

; set es to bios info segment:  
mov     ax, 40h
mov     es, ax

  ; point di to tail
  mov   di, s_size * 2 - 2
  ; move all body parts
  ; (last one simply goes away)
  mov   cx, s_size-1
move_array:
  mov   ax, snake[di-2]
  mov   snake[di], ax
  sub   di, 2
  loop  move_array


cmp     cur_dir, left
  je    move_left
cmp     cur_dir, right
  je    move_right
cmp     cur_dir, up
  je    move_up
cmp     cur_dir, down
  je    move_down

jmp     stop_move       ; no direction.


move_left:
  mov   al, b.snake[0]
  dec   al
  mov   b.snake[0], al
  cmp   al, -1
  jne   stop_move      
  mov   al, es:[4ah]    ; col number.
  dec   al
  mov   b.snake[0], al  ; return to right.
  jmp   stop_move

move_right:
  mov   al, b.snake[0]
  inc   al
  mov   b.snake[0], al
  cmp   al, es:[4ah]    ; col number.   
  jb    stop_move
  mov   b.snake[0], 0   ; return to left.
  jmp   stop_move

move_up:
  mov   al, b.snake[1]
  dec   al
  mov   b.snake[1], al
  cmp   al, -1
  jne   stop_move
  mov   al, es:[84h]    ; row number -1.
  mov   b.snake[1], al  ; return to bottom.
  jmp   stop_move

move_down:
  mov   al, b.snake[1]
  inc   al
  mov   b.snake[1], al
  cmp   al, es:[84h]    ; row number -1.
  jbe   stop_move
  mov   b.snake[1], 0   ; return to top.
  jmp   stop_move

stop_move:
  ret
move_snake endp
2008-01-10 23:04
快速回复:求汇编语言编写的"贪吃蛇"游戏的源程序.谢谢!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011608 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved