Game resources

Images, sounds, and other game data files are called resource files. For this game, we will need quite a few. With Monkey, all resource files have to be stored inside a subfolder of your project with a name such as yourGameName.data. For CometCrusher, we will need the following types of resource files:

  • Player ship image
  • Shield image
  • Comet images
  • Bullet image
  • Explosion particle image
  • Background star image
  • Bitmap font image to draw game stats
  • Explosion sound
  • Shot sound

So, let's go over these different types of resources, and how you could create them.

Images

Almost every game needs some graphics. In the initial chapters, we have used graphical primitives such as rectangles, circles, and lines. Monkey can draw these out of the box. For CometCrusher, we will now use images.

Inkscape is a very good freeware software. It's a vector drawing program in the style of Adobe Illustrator. The graphics for CometCrusher were created with it and then exported from it in the PNG file format. To get more information about it, visit its homepage at http://inkscape.org/.

Another good freeware program is GIMP. Instead of drawing in the vector style, you draw with pixels just like in Adobe Photoshop. GIMP is available at http://www.gimp.org.

Sounds

CometCrusher is the first game we will create, that will support sound effects. To create these sounds, we can use a simple recording program, a microphone, and your voice. But you could also use a nice freeware program such as SFXR to create some nice arcade sound effects.

You can get the Windows version of SFXR at http://www.drpetter.se/project_sfxr.html.

The OSX version is called CFXR, and is available at http://thirdcog.eu/apps/cfxr.

Both programs export the sounds as WAV files. To convert them into the sound formats you need, you can use Audacity, which is available at http://audacity.sourceforge.net/.

To play games inside the web browser, the OGG file format is the best at the moment. For FLASH games, you should use the MP3 file format. With the LAME plugin, Audacity can export sound files to the MP3 format.

Of course, you can also use any other sound/music program to create the sound effects and music for your game. Just try!

Bitmap fonts

To draw text well on the screen and with good performance, you should use bitmap fonts. There are several good programs on the Web to create them. A bitmap font is usually a combination of a font texture image, and a description file, which stores the position, size, and other information for each character inside the texture.

The fantomEngine initially supports bitmap fonts, which are stored in the EZGui font file format. One of the programs that can export to this file format is called GlyphDesigner and is available for OSX at http://glyphdesigner.71squared.com/.

The font file which is included in this chapter was also created and exported from GlyphDesigner. This app will create a single texture map with all the characters on it. Then it will also create another file, which describes where exactly each character is located on this texture map. It looks something similar to the following:

info face="Orbitron-Bold" size=18 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2
common lineHeight=18 base=14 scaleW=256 scaleH=128 pages=1 packed=0
page id=0 file="cc_font.png"
chars count=94
char id=106 x=2 y=2 width=8 height=19 xoffset=-3 yoffset=-1 xadvance=4 page=0 chnl=0 letter="j"
char id=36 x=12 y=2 width=14 height=18 xoffset=1 yoffset=-2 xadvance=14 page=0 chnl=0 letter="$"
char id=124 x=28 y=2 width=3 height=18 xoffset=1 yoffset=-2 xadvance=4 page=0 chnl=0 letter="|"

Don't worry about it, fantomEngine is able to interpret the file and load the font correctly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.19.251