segunda-feira, 14 de novembro de 2011

Make a Game - "Avoiding Game"

So let's talk about our game.

I've put it up on Google Code. You're gonna need a subversion client like Tortoise to download the files. But you can browse the sources code in the web.
If you wanna run the project, you're gonna to import them on Eclipse and fix up some folder problems that will. It's basically properties => Java Build and changing the folders of some Jar files of libGDX. If it doesn't work, just copy the codes in to another project.

Project in Google Code

Screen of the Game. Can Raphael survive this?

So now let me talk about the 3 packages(basically folders) in which I've divided the source code:

Game Package
This package is more libGDX oriented, featuring the Game class and two Screens. The first screen is for the actual game stuff, avoiding the devils and getting the feathers. The other screen is what happens when you lose the game. You can see your highest score yet there and also restart the game.

The main screen will basically draw what the Setup of the Logic Package tells it to draw, and will also send input information to the Setup class.

Logic Package
Handles what actually happens in the game.

  • The Setup class will receive interaction from the Game Package and will handle the main logic of the things, like managing all the beings in the game, including the player. 
  • Every being in the game is an GameObject, which is basically the enemies, the feathers and the player's avatar. 
  • The Board class handles movement of the GameObjects and collision detection
  • The Drawable class holds information on how the objects should be drawn in the screen
  • The GameObjectFactory class allows you to create GameObjects from Beans of the Bean Package. By messing around with this class you can add new enemy behaviors or object behaviors. You could make the feather move around or let the enemy stand still. Anything.
  • The Global class is used to hold the highest score.
  • ScoreListener is an interface to handle changes in score.
  • CollisionResponse is an interface used with collision detection
Collision detection is an important aspect of game programming. It's basically a way of knowing if two objects are touching or not.

In our game, detection collision is pretty simple, since all objects are treated as rectangles, so it's just code that checks if the two rectangles are colliding.

Bean Package
This package holds information about enemies and objects, so the GameObjectFactory can create GameObjects with the properties described by the bean.
The ObjectBean class holds all the possible behavior description for an enemy or an object. By tweaking those objects, the GameObject created later will behave differently.
The SpawnBean holds information about which object beans will be used in the game.

Play with the Code
Mess around with the code, specially the objectBean and the GameObjectFactory, so you can tweak the enemies or create new things.

Understand libGDX and make your own game! :)

Coming up next...
We're going to see sounds next.

Look forward to it!

Nenhum comentário:

Postar um comentário