<< 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

Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
Sanket Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





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