Jump to content
  • entries
    658
  • comments
    2,707
  • views
    906,895

He shoots*, he scores


* but only asteroids and mines.

 

Collision handling's going to be a bit different for Draconian as it's not feasible to check against all 150 sprites. One handy thing I can take advantage of is how the asteroids and mines are positioned. The screen's divided into horizontal bands that are 32 pixels tall. 4 stationary objects (combination of asteroids and mines) can appear in each band, and they're positioned so they never straddle multiple bands. Sprites 22-25 are in the first band, 26-29 are in the second band and so on.

 

Based on that knowledge I can limit the collision checks for shots by doing the following:

 

#define PLAYER_SPRITE           8
#define FORMATION_SPRITE        9
#define FIRST_STATIONARY_SPRITE 22
#define STATIONARY_DENSITY      4

for(i=0;i<4;i++)
{
    for(j=0;j<8;j++)
    {
        // not yet written, player shots and station collisions
    }
    
    for(j=FORMATION_SPRITE;j<FIRST_STATIONARY_SPRITE;j++)
    {
        // not yet written, player shots and enemy ship collisions
    }
    
    height = shot_height[i]
    start = ((shot_y / 32) * STATIONARY_DENSITY) + FIRST_STATIONARY_SPRITE
    end = (((shot_y + height) / 32) * STATIONARY_DENSITY) + FIRST_STATIONARY_SPRITE + STATIONARY_DENSITY
    
    for(j=start;j<end;j++)
    {
        if (Collision(shot_shape, shot_x, shot_y, j)
        {
            // process collisions
        }
    }
}
 

So instead of checking for collisions against 150 sprites I only have to check against 25 or 29 sprites. That's 8 stations + 13 enemy ships + either 4 or 8 stationary objects (depends if the shot straddles 2 zones).

 

Also added some temporary sound effects (borrowed from Space Rocks) and revised ship graphics (the 45° images).

 

ROM

draconian_20140419.bin

 

Source

Draconian_20140419.zip

  • Like 2

2 Comments


Recommended Comments

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...