Download presentation
Presentation is loading. Please wait.
Published byElwin Cook Modified over 9 years ago
1
Introducing your Game Engine Part 1 Games Fundamentals © by Jarek Francik Kingston University, London February 2008
2
KU Games Fundamental Classes A skeleton for: –a windowed application –full-screen application –applet Organising your animation loop –drawing your screen –updating your screen Providing Sprites
3
KU GFC Library Structure Package: kingston.gamefx –class: Game –class: GamePanel –class: GameWinApp –class: GameApplet –class: GameGraphics Package: kingston.sprite –class: Sprite subclasses: RectSprite, CircleSprite, BitmapSprite –class: SpriteList
4
Structure of a Windowed Game Game GameWinApp GamePanel
5
Structure of a Windowed Game GameWinApp – creates Game Window you just need to create an instance GamePanel – displays and controls the game a game panel is created automatically and you'll rarely use this class directly Game – the Game Engine that's what's you're going to do: develop a Game-derived class to implement your very own class
6
A Windowed Game – what to do? Develop your Game Class Add your main function to: –Create an instance of your Game Class –Create an instance of GameWinApp –Start your game
7
A Windowed Game – what to do? public static void main(String[] args) { Game game = new MazeGame(800, 600); GameWinApp app = new GameWinApp(); app.openWindow("Crazy Maze", game); }
8
Full Screen Games GameWinApp objects can run them, too! to open a windowed game: app.openWindow("Crazy Maze", game) to open a full-screen game: app.openFullScreen(game)
9
Full Screen Games final static boolean bFullScreen = false; public static void main(String[] args) { Game game = new MazeGame(800, 600); GameWinApp app = new GameWinApp(); if (bFullScreen) app.openFullScreen(game); else app.openWindow("Crazy Maze", game); }
10
Applets GameApplet class derived from JApplet, standard java applet class Every applet class must be initialised 1.Create a GameApplet derived class 2.Write a simple init() method
11
Applets public final class Maze extends GameApplet { // mandatory... private static final long serialVersionUID = 1; // Applet Initialisation goes here... public void init() { setGame(new MazeGame(800, 600)); super.init(); }
12
Universal Games Combine them both: –create a regular Applet class –add the main method for the windowed game
13
package kingston.games.maze; import kingston.gamefx.Game; import kingston.gamefx.GameApplet; import kingston.gamefx.GameWinApp; public final class Maze extends GameApplet { private static final long serialVersionUID = 1; final static boolean bFullScreen = false; // Applet Initialisation goes here... public void init() { setGame(new MazeGame(800, 600)); super.init(); } public static void main(String[] args) { Game game = new MazeGame(800, 600); GameWinApp app = new GameWinApp(); if (bFullScreen) app.openFullScreen(game); else app.openWindow("Crazy Maze", game); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.