It's time to take the first big step. In this chapter we're going to acquire Panda3D and get our work environment set up. Once we have all that done, we're going to take a look at the game we'll be creating over the course of this book.
In this chapter we shall:
Download and install Panda3D
Download and install Notepad++
Install all of the content necessary for the game
Demo the game we'll be creating
Install any optional tools desired
Blender and Chicken
Explosion Texture Generator
There's no time to waste, so let's get cracking!
The kind folks who produce Panda3D have made it very easy to get Panda3D up and working. You don't need to worry about any compiling, library linking, or other difficult, multi-step processes. The Panda3D website provides executable files that take care of all the work for you. These files even install the version of Python they need to operate correctly, so you don't need to go elsewhere for it.
I know what you're thinking: "Less talk, more action!" Here are the step-by-step instructions for installing Panda3D:
Navigate your web browser to www.Panda3D.org.
Under the Downloads option, you'll see a link labeled SDK. Click it.
If you are using Windows, scroll down this page you'll find a section titled Download other versions. This book is written for Panda3D version 1.6.2, which is the most current stable version at the time of writing. Find the link to Panda3D SDK 1.6.2 and click it. If you aren't using Windows, click on the platform you are using (Mac, Linux, or any other OS.). That will take you to a page that has the downloads for that platform. Scroll down to the Download other versions section and find the link to Panda3D SDK 1.6.2, as before.
When the download is complete, run the file and this screen will pop up:
Click Next to continue and then accept the terms. After that, you'll be prompted about where you want to install Panda3D.
The default location is just fine. Click the Install button to continue. Wait for the progress bar to fill up. When it's done, you'll see another prompt.
This step really isn't necessary. Just click No and move on.
When you have finished the installation, you can verify that it's working by going to Start Menu | All Programs | Panda3D 1.6.2 | Sample Programs | Ball in Maze | Run Ball in Maze. A window will open, showing the Ball in Maze sample game, where you tilt a maze to make a ball roll around while trying to avoid the holes.
You may be wondering why we skipped a part of the installation during step 7. That step of the process caches some of the assets, like 3D models and such that come with Panda3D. Essentially, by spending a few minutes caching these files now, the sample programs that come with Panda3d will load a few seconds faster the first time we run them, that's all.
Now that we've got Panda3D up and running let's get ourselves an advanced text editor to do our coding in.
The next thing we need is Notepad++. Why, you ask? Well, to code with Python all you really need is a text editor, like the notepad that comes with Windows XP. After typing your code you just have to save the file with
.py extension. Notepad itself is kind of dull, though, and it doesn't have many features to make coding easier.
Notepad++ is a text editor very similar to Notepad. It can open pretty much any text file and it comes with a pile of features to make coding easier. To highlight some fan favorites, it provides language mark-up, a Find and Replace feature, and file tabs to organize multiple open files. The language mark-up will change the color and fonts of specific parts of your code to help you visually understand and organize it. With Find and Replace you can easily change a large number of variable names and also quickly and easily update code. File tabbing keeps all of your open code files in one window and makes it easy to switch back and forth between them.
Now that you're convinced, let's get Notepad++ up and running. If you aren't convinced or want to use some other software to code with, that's fine. Just skip to the next section.
Navigate your web browser to http://notepad-plus-plus.org. Click on the Download tab on the page.
Click the link to Download Current Version.
Click the link that ends with Installer.exe.
When your download is finished run the file and you'll see this screen pop up:
Click Next to get the installation started and accept the terms. You'll be prompted again about where you want to install.
Again, the default directory is just fine. Click Next and you'll find yourself prompted once more, this time about the components you want to install.
The last thing we'll cover in this chapter is how to load a Panda3D game from the command prompt. Until the game is packaged and ready for shipping, this is how we'll run it. Don't worry, it's easy.
Open a command prompt by going to the Start menu | All Programs| Accessories and choosing Command Prompt.
Open Windows Explorer the same way.
In Windows Explorer click on the View menu at the top, highlight toolbars, and if Address Bar does not have a check before it, click on it. This will show your current directory in the window.
Navigate Windows Explorer to
BGP3D/Demoand copy the entire address bar with Ctrl+C or by right-clicking and selecting Copy.
Return to the Command Prompt window and type in
cdfollowed by a space. Then right-click on the Command Prompt window and select Paste. This will insert the directory address you copied from Windows Explorer.
Hit Enter and you'll see the directory in the Command Prompt change. Next, type in
python main.pyand hit Enter. The game will launch.
Not bad, right? We just learned how to run a Python file from the command prompt, something we'll be doing quite a bit. The
python command we used tells the system to use the Python interpreter to run the file we supply.
main.py is the name of the file that starts Panda3D and the game components. We'll go into more depth about how that works in the next chapter, so get ready!
There are a couple of optional tools that you can get for free and are worth pointing out. These tools are great for specific things, but none of them are strictly necessary for this book since all of the content they create is provided with the book. Nevertheless, we'll mention them here and provide tutorials on using some of them in the appendices for later projects when you've finished this book and need to create your own content for your own games. Since these tools are optional we won't go step-by-step through their installations, but we will tell you where you can find them.
Blender is an open source, free to use, 3D modeling and animation package based in Python. It's a full service package that's quite powerful and even used in some professional studios. Furthermore, it has an active community and lots of tutorials available on the web to help get new users up to speed with the program. A significant portion of the Panda3D community uses Blender to create their 3D content as well.
Another feather in Blender's cap isn't part of the core package but bears mentioning. That is Chicken, a plug-in for Blender that exports models and animations in
.egg files, one of the formats that Panda3D uses. Chicken let's you directly export from Blender to Panda3D without any intermediate conversions, and if you have experience with game development you know how nice that sort of simple pipeline from content creation to implementation really is. If you don't have that experience, then take our word for it. It's really nice.
You can find Blender, and some Blender tutorials, at www.blender.org. Blender v2.5 introduces some major changes that Chicken is not currently compatible with, so it may be wise to get an older version. Blender is available in executable installers, and all the default options work just fine. Do note that Blender doesn't come with Python like Panda3D does. To get the most out of Blender, install the version of Python it requires. For example, Blender v2.49 requires Python v2.6. The version of Python that comes with Panda3D is v2.5, so that won't work. Also, the latest version of Python at the time of this writing, v2.7, also won't work. Python does offer older versions on their website, and version 2.6.6 will work with Blender v2.49. Python also comes in executable installers, and again the default options are fine. Having both versions of Python on one computer won't cause any conflicts either. The Blender installer will direct us to the Python website when it fails to detect a Python version that it can use, but that website is at www.python.org if needed. Python documentation can also be found there.
You can find Chicken at http://chicken-export.sourceforge.net/. Chicken doesn't provide an executable installer, but the zip file that it does come in has a text file with installation instructions for various platforms in it. Note that in order for Chicken to work with Blender, the appropriate version of Python must be installed as noted in the previous paragraph.
The next optional tool was created by Alex Peterson and is used for creating sky boxes. If that's a new term to you, a sky box is basically a very large cube placed around an outdoor environment in a game that provides a backdrop. Spacescape in particular is designed for creating space environments, full of stars and nebulas. The nice thing about spacescape is that it exports all six of the images you need for a sky box, one for each face, and they are all seamless and virtually ready to use. For Panda3D, all you need to do is rename the files. Here are a few example of images you can make in Spacescape:
You can find Spacescape by searching for it on sourceforge.net or by going to Alex Peterson's blog at http://alexcpeterson.com/spacescape. Spacescape doesn't require any sort of installation, per se. All that's needed is to extract the zip file it comes in and place the folder that is contained in it somewhere on the computer. Once that's done, the program will run.
This is another tool created by a single author, a gentleman by the name of Sascha Willems. Explosions are pretty common in video games but creating a series of images to turn into an animated "movie" of an explosion can be a real pain. This tool makes it much easier. All that's needed is to input a couple of values for the explosions before and the tool will produce a palette image with every frame of the animation you need. There's a good deal of customization available so you can create gobs of different explosion types. Also, the tool outputs
.png files with the alpha already embedded in them, so you don't have to worry about what parts of the image need to be transparent. It's handled for you. Explosion Texture Generator can be found on Sascha Willems's web page at http://www.saschawillems.de/?page_id=253. Here's an example of the output this tool creates:
Like Spacescape, ExploTexGen doesn't require an installation. Just unzip the file and put the contents in a folder, then it will run as intended.
We spent most of the chapter installing the tools we need to use Panda3D.
We talked about and installed:
We also talked about some helpful optional tools that can be useful for creating game content. Oh, and let's not forget that we took a look at the demo for the game we'll be making over the course of this book!
We've got everything prepared now; it's time to move on to the real deal.