[A83] bcall(_iPoint) detection
[Prev][Next][Index][Thread]
[A83] bcall(_iPoint) detection
I am making a program, and when I shoot the gun (just one pixel), I am trying
to see if it is hitting the enemy. The first part is seeing if the pixel is
on (enemy is on that spot). The second part is putting the pixel of the
bullet, and the bullet moves higher up on the screen. My code for shooting
the bullet works just fine, but the enemy detection is not working right.
Any Suggestions? I tried using ionGetPixel too, but I couldnt get it to work
correctly. If anyone has any suggestion on using GetPixel, they are welcome
too.
shootgun:
;IONGETPIXEL:
;a=xcoord
;e=ycoord
;ipoint:
;b=xcoord
;c=ycoord
;d=offset
;INCREASES BULLET YCOORD (WORKS FINE)
ld a,(guny) ;loads the gun's ycoord into "a"
inc a ; so it can be increased (moved further up on the
screen)
cp 50 ;compares the guny to 50 to see if it has reached the
horizon yet
jp z,bulletgone ;if it has jump to bullet gone
ld (guny),a ;loads the increased amount back into guny
;CHECKS IF ENEMY OCCUPIES SPOT (DOESNT WORK)
ld c,a ;loads a (guny) into c for ipoints ycoord
ld a,(gunx) ;loads gunx into a so it can be
ld b,a ;put in b for ipoint's xcoord
ld d,3 ;loads 3 into d (3=testpixel)
bcall(_ipoint) ;calls romcall ipoint
jp nz,enemyhit ;if pixel was on, jp to enemy hit. if i use jp z,... it
always jumps there even if enemy hasnt been hit
;PUTS BULLET ON SCREEN (WORKS FINE)
ld a,(guny) ;loads guny into a
ld c,a ;loads that value into c for ipoint's ycoord
ld a,(gunx) ;loads gunx into and then int o
ld b,a ;b for ipoint's xcoord
ld d,1 ;loads 1 into d(1=pixelon)
bcall(_ipoint) ;calls romcall ipoint
ret ;returns to where it was called from
Thanks!
-Cole South