White Flame wrote:
One first-glance problem is that your shiftValues routine needs to be a loop.
Ok so after some time working the code I now have this but still doesn't seem to be working right. Any advice on what to do next? i think maybe my gameCheck isnt what it should be but I would like some advice on what to do next.
Code:
define snakeLength $00
define snakeHeadL $10
define snakeHeadH $11
define snakeBodyStart $12
init: ;initialize the values of the lo and hi bytes
;of the snake head and its length
lda #4
sta snakeLength
lda #$00
sta snakeHeadL
lda #$02
sta snakeBodyStart
lda #$01
sta $05
lda #$02
sta snakeHeadH
sta $03
sta $04
loop: ;this is the main game loop
jsr shiftValues
jsr updateHead
jsr gameCheck
jsr drawSnake
jmp loop
gameCheck:
ldx #2
lda snakeHeadL, x
cmp snakeHeadL
lda snakeHeadH,x
cmp snakeHeadH
beq gameOver
inx
inx
cpx snakeLength
beq drawSnake
jmp gameCheck
updateHead: ;this will move the head one row down
;the assembler
lda snakeHeadL
clc
adc #$20
sta snakeHeadL
incHeadH:
lda snakeHeadH
clc
adc #$01
sta snakeHeadH
cmp snakeHeadH
rts
shiftValues:
lda snakeHeadL, X
sta snakeBodyStart, X
dex
bpl shiftValues
rts
drawSnake: ;this will draw the snake at the current
;position after the updates
ldx snakeLength
lda #0
sta (snakeHeadL,x)
ldx #0
lda #1
sta (snakeHeadL,x)
rts
gameOver: