1
0
mirror of https://github.com/fumiama/c64-snake.git synced 2026-06-05 00:32:39 +08:00

更改食物生成逻辑

This commit is contained in:
fumiama
2021-04-05 22:53:53 +08:00
parent 16b49bd98d
commit 120b67a7e9
5 changed files with 16 additions and 29 deletions

View File

@@ -52,7 +52,9 @@ addfood:
beq -
cmp #cblk
beq -
lda #csnk
cmp #crnd
beq -
lda #crnd
dey
sta (_ptr), y
rts

View File

@@ -1,9 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; append 增加蛇长
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
append:
.scope
inc c ; 蛇长加一
; 其他代码
rts
.scend

View File

@@ -1,6 +1,7 @@
.alias cblk $66 ; 边框
.alias csnk $a0 ; 像素
.alias csps $20 ; 空白
.alias crnd $51 ; 食物
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 按钮配置调试时使用WASD控制
@@ -23,5 +24,6 @@
.alias field $0428 ; 蛇所在屏幕内存区
.data
.org $c000
.org $c000
.space eat 1
.text

View File

@@ -5,9 +5,6 @@
main:
.scope
.data
.space lopcnt 1 ; 循环次数计数
.text
`init
jsr getchar ; 等待输入任意字符开始游戏
jsr erasehint ; 游戏开始,清空提示
@@ -18,28 +15,24 @@ main:
jsr printfail
jsr getchar
rts
clc
* jsr judgefood ; 判断是否吃到食物
* clc
lda #0
sta eat
jsr judgefood ; 判断是否吃到食物
bcc +
jsr append
inc c ; 蛇长加一
lda #1
sta eat
jsr addfood
* jsr calcscore ; 计算得分
jsr printscore ; 打印分数
lda #32
jsr delay ; 延时期间最后一个按键位于d
lda d
beq ++
cmp #ed_g
bne +
rts
* sta d
* inc lopcnt
lda lopcnt
cmp #16
bmi -----
lda #0
sta lopcnt
jsr addfood
jmp -----
* jmp ----
.scend
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -50,7 +43,7 @@ main:
jsr chrout
lda #$00
sta s
lda #$00
sta eat
sta s + 1 ; 初始化分数为0
jsr printscore ; 打印分数
lda #csnk
@@ -69,7 +62,6 @@ main:
.require "hint.asm"
.require "getchar.asm"
.require "addfood.asm"
.require "append.asm"
.require "delay.asm"
.require "judge.asm"
.require "move.asm"

BIN
snake.prg

Binary file not shown.