It has been over 10 years since Issue 7! This is a real testament to the now 2 decade old Panda3D game engine. It’s still out there, still maintained, and all of the code in prior issues still works to this day! Lets crack on and complete our arcade shooter game.
1. Completing the Game
Here’s the silver bullet. If you have followed Issues 1 to 7, you already know how to complete this game! We’re going to lean on everything covered so far to complete the game, quickly. Well, sort of quickly. Think of this issue as a test as we end the volume. We won’t be showing that much code, the assumption being – we have shown you the way in the prevous 7 issues. 🙂
2. How to Shoot or be Shot, or Hit
If you recall back in Issue 4, we figured out how to cause the player to collide with the terrain. So off the bat, can we now use a similar approach to know if we have collided with an enemy? We absolutely can! Our terrain is a model in the game world, so are the enemies.
Try to update your code so that a collision with an enemy kills the player!
What about shooting at the enemy? You’re going to need a keyboard control to fire and ideally some sound. We first added keyboard controls in Issue 3.
Add a new key for ‘fire’, make it play a shooting sound.
Again, using the collision techniques we used previously, you should be able to determine if the shot hit the enemy.
Add a visual indication of firing and establish if an enemy is hit.
For the enemy to shoot back, you simply need to use the same approach as the player firing, just positioned correctly in the Finite State Machine implementation (because, as you know, the enemy class inherits from the player!). We first tackled the enemy Artificial Intelligence in Issue 7.
Make the enemies fire back with sound, visuals and damage to the player.
Use variables to track damage on both the player and the enemies to determine when they should die. The player, on death, is a game over and restart, much like colliding with the terrain. If an enemy dies, however, you can do a lot more. First, we’d suggest having it re-spawn (reappear) at a random position on the map with full health. Thereafter, if you maintain a variable to record “enemy deaths”, that can essentially drive the “game level” or “score”. Variables were covered as far back as Issue 2.
Make a dead enemy re-spawn and add extra enemies based on score.
3. Finish the HUD
Add variables to the HUD using the same way we added text previously in Issue 5 and Issue 6. To begin, perhaps add the players speed and altitude. Go to add the score, level, health (damage) or other variables as you see fit.
Position the Stats you care about on the top-right HUD.
4. Ice the Cake
Pimp your game world (terrain and height map) as we did in Issue 1, only spend more time making it your own. Consider adding a Graphical User Interface (GUI) and menu system as described in the offical manual, using DirectGUI.
Add a DirectGUI menu where you can mute the audio to your game.
5. Share the Joy
A finished game should be shared! Read all about distributing Panda3D games.
See you on the app stores!