Re: A83: Galaxian algorithm
[Prev][Next][Index][Thread]
Re: A83: Galaxian algorithm
>I'm having a little trouble figuring out how does Galaxian handle the
>bullets, move so many sprites and keep track of them. I could figure out
>the
>source more easily if I knew the basic idea behind the code. Anyone care to
>help? Patrick Davidson, perhaps, if you're on this list? =)
I haven't worked with Galaxian in awhile, but I'll try to remember. The
idea is very very simple. A much simpler example of it can be found in my
SubHunt game (the source code is less than 1/4 of Galaxian's size, and
significantly less sophisticated in coding style). Basically, every aspect
of each bullet and enemy is stored within a large temporary data area. In
galaxian, the definitions are:
ybullets =APD_BUF+9 ;30 bytes
ebuls =APD_BUF+39 ;30 bytes
enemies =APD_BUF+69 ;80 bytes
enemy_coords =APD_BUF+256+1 ;40 bytes
The data includes the X coordinate, Y coordinate, HP remaining, enemy
type, etc. Collisions are detected by looping through the coordinates of the
bullets and comparing each bullet X,Y coordinate with every enemy X,Y
coordinate.
When determining when and how to move an enemy, the enemy type is looked
up in the data table. Each enemy is moved by altering the X and Y coords
that are also stored. Actually, I think I have the order wrong. A internal
timer tells when a specific enemy type should move, then the enemy movement
routine looks up which enemies should be moved.
Anyway, I reiterate that I think the idea is much more readable and
understandable in the SubHunt source code.
hope this helps,
Sam
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com