Reworked the stations to fire from the 2 closest pods. For that I revised the closest pod to player tests from before, it now shows the 2 pods it'll fire from as well as the targeting line from the closest pod:
Additionally I finally tracked down a bug where you could shoot a station pod that you shouldn't be able to. For that I built another test build (though I forgot to save a copy of the bin, sorry) which would show the last pod destroyed, and the shot that destroyed it. I also had it show the shot further down using another missile, and once more below that using a sprite to show which collision image was used (as the image data to draw a missile is different than the image data for collision detection)*.
In reviewing the results the collision didn't make sense - unless the pod image was being treated as a 2X sprite. One of the things I'd recently done was revamp the sprite state to hold flags for various things like 2x, whereas before I used a ranges of image ID values to denote things like sprite sizes. I made the change to use bits in the state variable as those are much faster to check for than a range of values:
// constants for gSpriteState, bits fedcba9876543210 // f = sprite is onscreen // e = sprite is deadly if it collides with player's ship // d = sprite is deadly if it collids with enemy ship // c = sprite is an explosion (for animation logic) // b = fast animation speed // a = use 4x player // 9 = use 2x player // 8 = show bonus points when explosion finished // 54 = frame countdown for explosions #define SPS_SPRITE_ONSCREEN 0x8000 #define SPS_DEADLY_TO_PLAYER 0x4000 #define SPS_DEADLY_TO_ENEMY 0x2000 #define SPS_EXPLOSION 0x1000 #define SPS_FAST_ANIMATION 0x0800 #define SPS_4X_SPRITE 0x0400 #define SPS_2X_SPRITE 0x0200 #define SPS_SHOW_BONUS 0x0100 #define SPS_FRAME_COUNTDOWN 0x0030 #define SPS_EXPLOSION_TIME_MASK 0x000f #define SPS_4_FRAME_EXPLOSION 0x0030 #define SPS_3_FRAME_EXPLOSION 0x0020 #define SPS_DECREMENT_FRAME 0x0010
The sprite info is stored in arrays:
unsigned short int gSpriteState[MAX_SPRITES]; unsigned char gSpriteImageID[MAX_SPRITES+1]; // +1 is used for Station Pod collision detection unsigned short int gSpriteX[MAX_SPRITES+1]; // +1 is used for Station Pod collision detection unsigned short int gSpriteY[MAX_SPRITES+1]; // +1 is used for Station Pod collision detection unsigned char gSpriteColor[MAX_SPRITES];
Key thing to note there is the +1 used for Station Pod Collision detection - gSpriteState didn't have it as it wasn't needed before. This caused the revised collision routine to fetch data beyond the bounds of gSpriteState when it was testing a pod collision. A quick fix solved that problem:
unsigned short int gSpriteState[MAX_SPRITES+1]; // +1 is used for Station Pod collision detection unsigned char gSpriteImageID[MAX_SPRITES+1]; // +1 is used for Station Pod collision detection unsigned short int gSpriteX[MAX_SPRITES+1]; // +1 is used for Station Pod collision detection unsigned short int gSpriteY[MAX_SPRITES+1]; // +1 is used for Station Pod collision detection unsigned char gSpriteColor[MAX_SPRITES];
Lastly I created all new station arrangements for the Gamma Quadrant (these may be revised by Nathan at a later date).
* This is the data to draw a horizontal shot:
MG_ShotHorizontal: .byte HMOVE_0 | ON, 0 | WIDTH_4 .byte HMOVE_0 | ON, 0
While this is the data used for collision detection with the horizontal shot:
ShotHorizontal: .byte %11110000 .byte %11110000 ShotHorizontalHeight = * - ShotHorizontal
- Nathan Strum likes this