<< Chapter < Page Chapter >> Page >

You learned how and why you should extend the BasicGame class instead of implementing the Game interface directly.

You learned about the behavior of the constructors for the AppGameContainer class.

You learned that the start method of the AppGameContainer class calls the followingthree methods:

  • setup
  • getDelta
  • gameLoop

You learned about the behavior of the setup and getDelta methods in this module.

What's next?

I will provide an explanation of the gameLoop method in the next module.

Miscellaneous

This section contains a variety of miscellaneous information.

Housekeeping material
  • Module name: Slick0120: Starting your program
  • File: Slick0120.htm
  • Published: 02/04/13
  • Revised: 06/09/15
Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.

In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. Ineither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please beaware that it is a copy of a module that is freely available on cnx.org and that it was made and published withoutmy prior knowledge.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

Complete program listing

Listing 6 provides a complete listing for the skeleton program named Slick0120a .

Listing 6 . Source code for Slick0120a.java.
/*Slick0120a.java Copyright 2012, R.G.BaldwinSkeleton code for a basic game. Tested using JDK 1.7 under WinXP*********************************************************/ import org.newdawn.slick.AppGameContainer;import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer;import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException;public class Slick0120a extends BasicGame{ public Slick0120a(){//Call to superclass constructor is required. super("Slick0120a, Baldwin.");}//end constructor //----------------------------------------------------//public static void main(String[] args)throws SlickException{ AppGameContainer app =new AppGameContainer(new Slick0120a()); app.start();//this statement is required}//end main //----------------------------------------------------//@Override public void init(GameContainer gc)throws SlickException { //No initialization needed for this program.}//end init //----------------------------------------------------//@Override public void update(GameContainer gc, int delta)throws SlickException{ //Put game logic here}//end update //----------------------------------------------------//public void render(GameContainer gc, Graphics g) throws SlickException{//Put drawing code here. }//end render}//end class Slick0120a

-end-

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