This is March's entry to my 1 game per month challenge, it's a simple game of Asteroids.
I spent March focusing on Object allocation, physics and collision detection.
Memory management is accomplished by two linked lists, called free and active. Creating an entity involves moving the memory out of the free list and into the active list, vica-verca for destruction. As the entities are stored in a singly linked list, destruction only occurs in the final entity pass (Render).
Collision detection is done through bounding-box collision testing. There are three types of entities, Players, NPCs, Projectiles.
For speed purposes the system will only check for collisions between:
Unfortunately with how I've arranged things, the system can only process 65 Asteroids, 1 Player and 3 Projectiles before hitting slowdown. That will occurs at level 6 if the player doesn't destroy all of the small asteroids, therefore I've caped the level to 7.
I tried to get the game to mirror-wrap the asteroids (where half the asteroid is on the left and the right at the same time), but I couldn't find an easy way to do bounding box-collisions for when the asteroid is wrapped. I tried twice and couldn't tighten the collision loop.
Instead I just simplified the whole problem and extended the playfield by 32 off-screen pixels. I've played the game a few times and it hasn't bothered yet. I'm not going to code another game that does this.
As usual, the same is licensed under the MIT license and the source is available at https://github.com/undisbeliever/asteroids
---
I still can't test this real SNES yet. I'm having issues interfacing my computer with the SNES. Maybe when I have more free time I'll figure it out.
Attachment:
File comment: Asteroids Screenshot
Asteroids (v01)[HB].png [ 2.72 KiB | Viewed 2088 times ]
Asteroids (v01)[HB].png [ 2.72 KiB | Viewed 2088 times ]
I spent March focusing on Object allocation, physics and collision detection.
Memory management is accomplished by two linked lists, called free and active. Creating an entity involves moving the memory out of the free list and into the active list, vica-verca for destruction. As the entities are stored in a singly linked list, destruction only occurs in the final entity pass (Render).
Collision detection is done through bounding-box collision testing. There are three types of entities, Players, NPCs, Projectiles.
For speed purposes the system will only check for collisions between:
- The Player and NPCs
- The NPCs and Projectiles.
Unfortunately with how I've arranged things, the system can only process 65 Asteroids, 1 Player and 3 Projectiles before hitting slowdown. That will occurs at level 6 if the player doesn't destroy all of the small asteroids, therefore I've caped the level to 7.
I tried to get the game to mirror-wrap the asteroids (where half the asteroid is on the left and the right at the same time), but I couldn't find an easy way to do bounding box-collisions for when the asteroid is wrapped. I tried twice and couldn't tighten the collision loop.
Instead I just simplified the whole problem and extended the playfield by 32 off-screen pixels. I've played the game a few times and it hasn't bothered yet. I'm not going to code another game that does this.
As usual, the same is licensed under the MIT license and the source is available at https://github.com/undisbeliever/asteroids
---
I still can't test this real SNES yet. I'm having issues interfacing my computer with the SNES. Maybe when I have more free time I'll figure it out.