<< Chapter < Page Chapter >> Page >

Two primary objects

You learned in an earlier module that a Slick2D game that runs as an application (not an applet) consists of at least two cooperating objects:

  1. An object instantiated from a subclass of the Slick2D class named GameContainer .
  2. An object instantiated from a class that implements the Slick2D interface named Game .

Behavior of an object of the AppGameContainer class

The GameContainer object ( item 1 above ) manages the program startup and the game play after the game program starts running. For example, this is the object that managesthe game loop.

As shown in Listing 1 , for the program named Slick0120a , this object is an object of the class named AppGameContainer , which extends the class named GameContainer .

The AppGameContainer class provides many public methods (including the method named start , which is called in Listing 1 ) by which you can manipulate the behavior of the container object. Theauthors of the Slick2D library did not intend for you to physically modify the source code in the GameContainer class or the AppGameContainer class.

Behavior of an object that implements the Game interface

The behaviors of the methods of the Game object ( item 2 above ) are what distinguishes one Slick2D game from another Slick2D game.

You need not implement the Game interface directly. The authors of the Slick2D libraryprovided a helper class named BasicGame that implements the Game interface and provides a number of useful methods. They intended for you to extend the BasicGame class and to override at least three of the methods declared in the Game interface in order to provide the desired behavior for your game..

As mentioned earlier, the class named Slick0120a extends the BasicGame class, thereby implementing the Game interface and getting the benefit of methods defined in the BasicGame class.

The code in the main method in Listing 1 instantiates an object of the Slick0120a class and passes that object's reference to the constructor for the class named AppGameContainer . Therefore, Listing 1 instantiates both of the required objects and connects them in the manner intended by the authors of the Slick2D library.

Starting the game

The main purpose of this module is to analyze the behavior of the Slick2D game engine when you start aSlick2D game running.

Listing 1 calls the start method on a reference to the AppGameContainer object. The source code for the start method is shown in Listing 2 .

Listing 2 . The start method of the AppGameContainer class.
public void start() throws SlickException { try {setup();getDelta(); while (running()) {gameLoop(); }} finally { destroy();}if (forceExit) {System.exit(0); }}//end start

Copyright and license information

Copyright and license information:

I was unable to find any copyright or license information in the zip file that I downloaded from (External Link) . I acknowledge that I am not the author of the code in that zip file and the copyrights for thatmaterial are held by someone other than myself.

Constructors and methods

This and the next few modules will explore and discuss the constructors for the AppGameContainer class (see Listing 1 ) along with salient aspects of the following methods that are called in Listing 2 :

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Anatomy of a game engine. OpenStax CNX. Feb 07, 2013 Download for free at https://legacy.cnx.org/content/col11489/1.13
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Anatomy of a game engine' conversation and receive update notifications?

Ask