Re: A83: tracking and moving many objects


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

Re: A83: tracking and moving many objects




i wrote a really good one for zelda, but i lost the source when i
reformatted.  I'm sure that Sam Heald has it, but i'll go ahead and
explain it since the algorithm is simple.

the best method is using a queue, where we have a static size of each item
in the queue, but a variable size.  Here is some code to explain:

projectileQueue = savesscreen
; entry format
;  .db <projectile ID>,<xpos>,<ypos>

...

addEntryToQueue:
 ld hl,projectileQueue

findEmptyQueueItem:
 ld a,(hl)
 or a
 jr z,emptyItemFound		; we are 3 bytes past the last item
				; or at the first

 inc hl
 inc hl
 inc hl
 jr findEmptyQueueItem

emptyItemFound:
 ld (hl),b			; projectile ID
 inc hl
 ld (hl),c			; xpos
 inc hl
 ld (hl),d			; ypos
 ret

hope that helps.

-harper

On Fri, 30 Jun 2000, Man on the Moon wrote:

> 
> What is a good method or algorithm to keep track of many objects, such as
> the coordinates of bullets in a game, and move these objects as well? I did
> come up with a method of storing each in a user defined varible but that was
> a pain in the neck, or code.
> 
> From: Chris (Man on the Moon)
> e-mail: apparatus@mediaone.net
> 
> 
> 




Follow-Ups: References: