scottschiller / ArmorAlley

A browser-based interpretation of Armor Alley, a combat strategy game originally released in 1990 for the Macintosh and MS-DOS PCs.
https://armor-alley.net/
Other
91 stars 25 forks source link

Shooting goes through parachute #5

Closed supercobra closed 1 year ago

supercobra commented 1 year ago

When trying to shoot a pilot with a parachute, it seems that many bullets go through him before taking him down. Maybe it is a visual effect only not sure.

MacOS Ventura + Safari.

scottschiller commented 1 year ago

Ah yes, I've noted this myself - the collision detection logic could be improved, here.

Currently, sprites move with "vX" and "vY" velocities - e.g., gunfire might move 8 pixels on the X axis per frame. To optimize and reduce CPU use (and/or be lazy), I only check for collision at the new position, e.g., from 32 to 40 pixels; I don't "step" through each pixel traveled between frames. This has been OK for most cases, but gunfire -> parachute is a good example of where things can clearly miss and shouldn't.

I could probably get away with adding a "half-point" collision check, or maybe splitting it into thirds. This could apply to and improve the accuracy of all munitions - bombs, smart missiles and such.

scottschiller commented 1 year ago

This turned out to be easier than I thought, assuming I got it right. 😅 Bullets can collide with bullets mid-air, and that seems to be happening more now with this check. Additionally, infantry and parachutes ("paratroopers") should be hit more reliably now. Let me know if you're still seeing bullets flying through, missing or skipping over.