<< Chapter < Page Chapter >> Page >

You will learn how to write a minimal Java application in conjunction with a set of Slick2D jar files to create your own Slick2D game engine. Using that programas an example, you will learn about the overall structure of the Slick2D game engine.

You will learn that game engines are typically service provider programs and you will learn about a common set of services that is provided bymany game engines.

You will learn about the two cooperating objects that form the heart of the Slick2D game engine.

You will learn about the methods declared in the interface named Game .

What is a game engine?

The term "game engine" is jargon for something that is more properly called a "software framework."

A software framework

Here is part of what Wikipedia has to say about a software framework:

A software framework , in computer programming, is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality .

Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined API, yet they contain some key distinguishing features that separate them from normal libraries.

Software frameworks have these distinguishing features that separate them from libraries or normal user applications :

  1. inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework.
  2. default behavior - A framework has a default behavior. This default behavior must actually be some useful behavior and not a series of no-ops.
  3. extensibility - A framework can be extended by the user by selective overriding of framework code in order to provide specific functionality
  4. non-modifiable framework code - The framework code, in general should not normally be modified by the user. Users can extend the framework, butnormally should not modify its code.

In short, a framework is a computer program that helps you to write computer programs.

Not a game engine

Under this definition, Slick2D in its raw form is not a game engine nor is it a framework. Instead, it is a library of Java classes that you can use to create aframework or game engine.

In particular, if you combine the contents of the files named slick.jar and lwjgl.jar with the minimal Java application shown in Listing 1 and described in Figure 1 , you will have created a game engine. That combination is what I will refer to hereafter as the Slick2D game engine .

Having done that, the framework description given above is a good match for the Slick2D game engine.

Background information

Listing 1 shows a very simple Java application program.This is possibly the simplest program that can be written using Slick2D that will run as a Java application.

(A different approach is used to create a Slick2D program that will run as a Java applet, but I probably won't get into Java applets in this collection ofmodules.)

I will use this program to explain the overall structure of the Slick2D game engine in this module. I will explain the inner workings of the game engine in more detail infuture modules.

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