Jump to content
  • entries
    657
  • comments
    2,699
  • views
    900,426

He shoots*, he scores


SpiceWare

769 views

* 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

Aiming at the non-45° 45° angles takes a little getting used to, but seems to be working fine.

 

The vertical/horizontal/diagonal speeds need some tweaking. Vertical seems a bit too slow, horizontal seems a bit too fast, and diagonal is much too fast.

Link to comment

When I slowed down the horizontal speed we got that fugly judder problem. That's is why I decided to just ignore the non-square pixel issue.

 

Maybe making vertical faster would work OK, though I suspect it'll just reintroduce the judder.

Link to comment
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...