A83: Re: Re: Game programming


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

A83: Re: Re: Game programming




Collision detection is really very simple.  The entire map collision routine
is a bit more complex though.
Just look at the code i used in zelda for enemy collision detection. (i
changed it from 16x16 to 8x8 for this post though)


 ld a,(ex)                ; enemy X-position
 ld b,a
 ld a,(x)                  ; your X-position
 sub b
 cp 8 \ jr c,hitE        ; if his your X-his X<8, then check the y coords
 neg                       ; 255-a = number carried over
 cp 8 \ jr c,hitE        ; if his his X- your-X<8, then check the y coords
 ret

hitE:
 ld a,(ey)
 ld b,a
 ld a,(y)
 sub b
 cp 8 \ jr c,hit_enemy
 neg
 cp 8 \ ret nc                ; return if he is >= your right edge

hit_enemy:        ; this is where it goes if you collided with the enemy

-Harper Maddox

jerky@ebicom.net
IRC nick: Geori
ICQ: 1214597

-----Original Message-----
From: James Matthews <matthews@tkb.att.ne.jp>
To: assembly-83@lists.ticalc.org <assembly-83@lists.ticalc.org>
Date: Monday, September 07, 1998 8:16 AM
Subject: A83: Re: Game programming


>
>Somehow store the TL/BR coordinates of your object.  If its 8x8 sprites,
>then its simple!  You'll have to settle for bounding boxes, even Q2 limits
>boundaries to boxes :)...Harper apparently has some cool collision
>detection in his code...
>
>Later,
>
>James.
>