Before we begin…
What this tutorial is, and what it is not
What it is:
An introduction to game development using Panda3D. It will teach the basic principles of the engine, and techniques for using it–enough to make a simple game.
Indeed, over the course of these lessons we’ll build up exactly that: a basic arena-based, top-down score-shooter. If the genre of the game isn’t to your tastes, that’s fair enough: it’s merely an example–a lens through which to teach Panda3D. The principles taught with it should apply to a wide variety of game-types (even non-action games).
What it is not:
A Python tutorial. This tutorial assumes a basic knowledge of Python (and ideally of object-oriented programming). You don’t have to be an expert, but if you’re entirely new to the language then I recommend picking up a Python tutorial before taking on this one!
A game design tutorial. The game built up in these lessons is intended to teach the basics of Panda3D, rather than to be a great game. (Although I do think that it is somewhat fun.) Furthermore, the focus is on teaching the use of Panda3D–while there will be some mention of game design, I intend to somewhat skim over it.
An advanced Panda3D Tutorial. Panda3D is capable of much more than is shown here: advanced physics, custom shaders, complex logic, and more besides!
- The fundamentals of Panda3D
- Lights and automatic shading
- Tasks and “update” methods
- Simple collision-detection
- Music and sound effects
- GUI construction
- Building a distributable version
- And more besides!
Each lesson provides example code–but these are often fragments (for brevity’s sake). If you want to see the code in context, compare it with your own, you can find the full code as of the end of each lesson in the “ReferenceCode” directory. In there you should find one directory for each lesson, containing the full code.
The reference code directory should be available here:
The assets for the tutorial
This tutorial makes use of a variety of assets, from a variety of sources.
The intended location for each asset should be as indicated in the tutorial-code that loads it, with paths assumed to be relative to the root-directory of the project on your system.
As to where to place their textures, that varies somewhat:
The textures for the models found in the “Panda Sample Models” repository (see below) are stored simply in a common folder called “tex”, located in the same directory as the model-file.
That is, if a model-file were stored in the folder “myProject/Models/”, then its textures would go into a folder called “myProject/Models/tex/”.
(And while the repository gives the textures for each model separately, that’s just a matter of organisation, I believe–simply lump all the textures into a single “tex” folder.)
The “Panda-chan” model is similar, but instead of the “tex” folder used by the above, it uses a folder named “texture”.
And finally, the UI-textures are stored in a folder named “UI”. Note that they have no associated models, and the “UI” folder is intended to simply be placed in the base project directory (i.e. the same directory that holds the game’s Python-files).
So that you can build the tutorial game yourself, let me link to these assets here.
Note that each set of assets has its own license. If you intend to use any of the following in your own works, and especially if you plan on distributing them in any way, I recommend that you check those licenses! (But I am not a lawyer, and this is not legal advice.)
The models and textures:
Environment, simple enemy, laser, and hit-flashes:
Panda-chan, by wezu:
- (The same as the first model-repository above; they’re in the “UI” directory)
- I’m using “Defending the Princess Haunted”.
- The music offered there is in MP3 format, but can be converted to OGG format via free tools. I used Sound Converter: http://soundconverter.org/
When these assets are mentioned in the tutorial, take note of the directories that I reference. You may want to either adopt the same folder-structure, or adapt the folder-references in the code to whatever structure you use!