A86: im a little stupid so i need some help


[Prev][Next][Index][Thread]

A86: im a little stupid so i need some help




ok im trying to make a game, a very simple one but it doesnt quite work right.

you can download it from  http://www.angelfire.com/ny2/mgc/Tag.txt   
here are the routines that give me trouble
i think it might be the conditionals but i cant get it to work
please let me know what im doing wrong 


playerx = _textShadow		;1 
playery = _textShadow+1		;1 
enemyx  = _textShadow+2		;1 
enemyy  = _textShadow+3		;1 
counter = _textShadow+4		;1 
score   = _textShadow+5		;2

;player starts at 0,0
;enemy starts at 15,7
;and i use Dan Eble's grid sprite routine
;so all coord should be between 0-7 and 0-15


move_down:
	ld hl,playery
	ld a,(hl)
	cp 7	;see if y value is max
	ret z	;return if so
	inc a
	ld (hl),a
	ret
move_up:
	ld hl,playery
	ld a,(hl)
	cp 0	;check y value if max
	ret z	;return if so
	dec a
	ld (hl),a
	ret
move_left:
	ld hl,playerx
	ld a,(hl)
	cp 0
	ret z
	dec a
	ld (hl),a
	ret
move_right:
	ld hl,playerx
	ld a,(hl)
	cp 15
	ret z
	inc a
	ld (hl),a
	ret


;this routine should move the enemy towards
;the player but it doesnt seem to work right

move_enemy:
	ld hl,counter
	ld (hl),10
	ld hl,playerx
	ld a,(hl)
	inc hl
	inc hl
	ld b,(hl)
	cp b
	jp z,move_enemy_up_or_down
	jp c,move_enemy_left
	jp move_enemy_right

move_enemy_left:
	ld hl,enemyx
	ld a,(hl)
	inc a
	ld (hl),a
	ret
move_enemy_right:
	ld hl,enemyx
	ld a,(hl)
	dec a 
	ld (hl),a
	ret
move_enemy_up_or_down:
	ld hl,playery
	ld a,(hl)
	ld hl,enemyy
	ld b,(hl)
	cp b
	jp z,hit
	jp c,move_enemy_up
	jp move_enemy_down
move_enemy_up:
	ld a,(hl)
	dec a
	ld (hl),a
	ret
move_enemy_down:
	ld a,(hl)
	inc a
	ld (hl),a
	ret