This is my exploration of Panda3D, in which I try to make a simple third-person shooter game. I will hopefully continue to update this post as the code improves.
At the moment, the game consists of a PacMan character who runs around the map and shoots moving Ghost NPCs. Not much, but then again, not too long ago it wasn’t anything at all.
Unfortunately, all my attempts at integrating physics into my own designs have failed miserably, at times because I don’t seem to understand some of the functions being called, and at times because strange things happen without me knowing why. So this code doesn’t use physics.
That said, I would be happy if more experienced users were to comment on any inadequacies, irregularities or inefficiencies you might see in the code. I like to comment a lot, so much of the code is comments, though there is a dearth of comments in the blast classes right now, as well. First, though, there are a couple of things worth noting:
-
All the models I use are custom, made in Blender.
-
The environment has three subsets - a “terrain” piece for display, a “floorcollider” piece for floor collisions, and a “wallcollider” piece for wall collisions. I think all three of them, including the terrain, are collision-enabled, however.
-
This is a work in progress; it’s improving, but there are still alot of funky things going on.
LATEST UPDATE: There is now a semi-functional minimap/radar at the bottom-right of the screen (see my third post for a description of its limits), and I have somewhat improved ghost pathfinding when faced with walls.
FEATURES:
- Camera and actor control
- Collisions for actor, terrain, projectiles, and NPCs (not camera)
- Animation for the actor and for other NPCs
- Jumping, and shooting (using a different class)
- NPCs that move randomly, flee from or pursue the player, and are destroyed when shot
- Switching between weapon types
- A score counter that notes the number of ghosts shot
- A semi-functional radar map
DOWNLOAD
I would recommend you download the models along with the code, which I have put up here. The full code is massively huge, so I’m afraid I’m going to stop posting it here directly; in any case, there are a lot of custom models and textures in use.
filefront.com/17136148/Shoot … nment.zip/
INSTRUCTIONS:
WASD - character movement
E - jump
Space - shoot
ESC - exit
Up & Down Arrows - Change the actor’s pitch
Left & Right Arrows - Rotate camera around actor
T and H - Zoom in and out
Q - switch ammo types
TO-DO LIST
- Improve the NPCs’ pathfinding algorithm
- Implement spawn points for the player and the ghosts
- Add ammunition, in the form of collectible PacPoints
- Add special power-ups
- Make the Red Ghosts attack the player
- Create an all-around prettier GUI
- Fix the issues with the radar’s proportionality
- Make the number of Red Ghosts relative to the number of Blue Ghosts slowly increase over time, thus increasing difficulty (once they are made to attack)
KNOWN ISSUES:
-
Sometimes, the actor stops being able to jump at all, presumably because self.jump has become stuck at 0. This can be rectified by falling off ledges, jumping while standing on the edge of a platform, or sometimes by repeatedly pressing the jump key. I am not sure why this happens, or how to fix it.
-
Occasionally colliding with corners will cause the actor to become temporarily stuck, unable to turn and forcing you to retreat; I am not sure why this happens, or how to fix it.
-
Shooting at the ramps or other parts of the floor doesn’t destroy the projectiles; this is because the projectiles are only set to collide with the floor mask.
-
The game sometimes crashes if the ghosts are herded into a corner and try to flee through walls. I am trying to set the algorithm up such that they avoid getting stuck like this at all.
-
Ghosts will occasionally become stuck at corners, even though they are supposed to avoid walls. I am considering a few different fixes for this.
-
If starting the game with the menu, there is a slight performance drop in a period shortly after the game loads, before performance returns to normal. I am considering why this might be.
-
The minimap does not provide an exactly proportional representation; pips only move towards the center when the ghost gets extremely close, meaning it would not be very useful if you really needed to watch your back with it. I’m not sure why this is, and I’m trying to fix it.