Game Development Reference
In-Depth Information
make sure that you adhere to the license. People put a lot of work into their songs. If the license
doesn't fit your project (that is, if your game is a commercial one), then you can't use it.
Implementing Super Jumper
Implementing Super Jumper will be pretty easy. We can reuse our complete framework from
Chapter 8 and follow the architecture of Mr. Nom on a high level. This means we'll have a class
for each screen, and each of these classes will implement the logic and presentation expected
from that screen. Besides that, we'll also have our standard project setup with a proper manifest
file, all our assets in the
assets/
folder, an icon for our application, and so on. Let's start with
our main
Assets
class. Just set up the project as you did before, copy over all the framework
classes, and you are ready to code this marvelous game.
The Assets Class
In Mr. Nom, we already had an
Assets
class that consisted only of a metric ton of
Pixmap
and
Sound
references held in static member variables. We'll do the same in Super Jumper. This time,
we'll add a little loading logic, though. Listing 9-1 shows the code, with comments mixed in.
Listing 9-1. Assets.java, Which Holds All Our Assets Except for the Help Screen Textures
package
com.badlogic.androidgames.jumper;
import
com.badlogic.androidgames.framework.Music;
import
com.badlogic.androidgames.framework.Sound;
import
com.badlogic.androidgames.framework.gl.Animation;
import
com.badlogic.androidgames.framework.gl.Font;
import
com.badlogic.androidgames.framework.gl.Texture;
import
com.badlogic.androidgames.framework.gl.TextureRegion;
import
com.badlogic.androidgames.framework.impl.GLGame;
public class Assets {
public static
Texture
background
;
public static
TextureRegion
backgroundRegion
;
public static
Texture
items
;
public static
TextureRegion
mainMenu
;
public static
TextureRegion
pauseMenu
;
public static
TextureRegion
ready
;
public static
TextureRegion
gameOver
;
public static
TextureRegion
highScoresRegion
;
public static
TextureRegion
logo
;
public static
TextureRegion
soundOn
;
public static
TextureRegion
soundOff
;
public static
TextureRegion
arrow
;
public static
TextureRegion
pause
;
public static
TextureRegion
spring
;
public static
TextureRegion
castle
;
public static
Animation
coinAnim
;