4

GAME CONCEPT

Every game is a subclass of Game class.

   public class YourGame extends com.golden.gamedev.Game {

   }

Game has 3 abstract methods to implement:

  1. Initialization game resources
  2. : Init game variables (all that usually belong to constructor)
    Note: Game is prohibited to have any overloading constructor. see Game Constructor
  3. Update game
  4. : Update game variables such as sprite position, animation, etc.
  5. Render game
  6. : Display the game to the screen.
   public void initResources() { }
   public void update() { }
   public void render(Graphics2D g) { }

New game skeleton code (Tutorial1.java):

    import java.awt.Graphics2D;

    import com.golden.gamedev.Game;  // import GTGE Library

    public class Tutorial1 extends Game {

        public void initResources() {
            // place for game initialization
        }
        public void update() {
            // update game variables
        }
        public void render(Graphics2D g) {
            // display to the screen
        }

    }
See above template in action !
Note: tutorial source code is located in <GTGE path>\tutorials\code.

The skeleton show empty game running in applet environment
    Next we'll see other game environment available....

1 2 3 4 5 6 7
<< Previous Page Next Page >>