Gameprogrammeren: Game states

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag Dallas one-wire interface Opgave:
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Constructor and New Fields // Don't synch draw() with vertical retrace of monitor graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = true;
Craps. /* * file : Craps.java * file : Craps.java * author: george j. grevera, ph.d. * author: george j. grevera, ph.d. * desc. : program to simulate.
 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
COMPUTER PROGRAMMING 2 Chapter 7 Sound. Objectives Find out how to prepare sounds for inclusion in Microsoft XNA projects. Incorporate sounds into XNA.
2D Graphics in XNA Game Studio Express (Modeling a Class in UML) Game Design Experience Professor Jim Whitehead February 5, 2008 Creative Commons Attribution.
Hoofdstuk 13 Object-georiënteerd ontwerp. Methode-aanroep: Type van parameters void paint(Graphics g) { g.drawRect( ); class Graphics { void drawRect(int.
2D Graphics in XNA Game Studio Express (Plus, Random numbers in C#) Game Design Experience Professor Jim Whitehead January 16, 2009 Creative Commons Attribution.
More Game GUI and methods. This is where we left off.
Console I/O in C# 2D Graphics in XNA Game Studio Express (Modeling a Class in UML) Game Design Experience Professor Jim Whitehead January 14, 2009 Creative.
Crossword Puzzle Solver Michael Keefe. Solver structure.
Display 480x800 QVGA 320x480 HVGA Capacitive touch 4 or more contact points Camera 5 mega pixels or more Dedicated camera button Hardware buttons.
Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience January 14, 2010 Arnav Jhala.
CHAPTER 4 Images XNA Game Studio 4.0. Objectives Find out how the Content Manager lets you add pictures to Microsoft XNA games. Discover how pictures.
COMPUTER PROGRAMMING 2 Timers. Game Idea: Mob Reaction Timer Use a timer variable to keep track of time and a variable for each player to measure the.
Getting Started. XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to XNA Game.
Using Namepsaces  This section lists the namespaces that the application will be using frequently. Saves the programmer from specifying a fully qualified.
Developing the Game User Interface (UI) Lesson 5.
Architectures Classic Client/Server Architecture Classic Web Architecture N-tier (multi-tier) Architecture FEN Databaser og Modellering.
1 Useful Tools for Making Video Games Part V An overview of.
9.3. P ARTICLE S YSTEMS Development of a particle system.
Rob Miles. Creating a Working MoodLight We know that colours in XNA are stored as values which represent the amount of red, blue, green and transparency.
CHAPTER 10 Using C# Methods to Solve Problem XNA Game Studio 4.0.
11 Working with Images Session Session Overview  Find out more about image manipulation and scaling when drawing using XNA  Start to implement.
Object Oriented Design COSC 315 Fall 2014 Bridget M. Blodgett.
XNA Game Studio 4.0 Keyboard and Mouse Controls + more on Animated Sprites.
11 Making a Sprite Session 4.2. Session Overview  Describe the principle of a game sprite, and see how to create a sprite in an XNA game  Learn more.
2.3. A RCHITECTURAL D ESIGN I Example approach for game screen management.
Aaron Yuen 1 Outline 9.1Storyboarding & Charting Method for Game Design 9.2Game State in Game Development 9.3Game State Management 9.4GUI Assets for Gameplay.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
CHAPTER 6 Multiplayer XNA Game Studio 4.0. Objectives Discover how to detect and use individual button-press events in a game. Learn how to create and.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
CHAPTER 2 The Game Loop - Variables, Types, Classes and Objects in XNA XNA Game Studio 4.0.
Objects and Classes Engineering 1D04, Teaching Session 9.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
Playing with Sprites. XNA Game Lifecycle In the faceBall demo program we bounced a smiley face around the graphical display against a background image.
XNA ● Proprietary Microsoft framework ● C#. Interface.
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
Rob Miles. Using data in an XNA game program An XNA game program Draw and Update methods that are called to run the game Colours are held in XNA as four.
11 Adding Vibration Effects Session Session Overview  Describe how the vibration feature of the gamepad works  Show how an XNA program can control.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Cosc 4735 Activities, fragments, callbacks/listeners/interfaces.
XNA Sound Effects. float volume, pitch, pan; SoundEffect boing1; SoundEffect boing2; boing1 = Content.Load ("boing1"); boing2 = Content.Load ("boing2");
Rob Miles. Creating a Broken MoodLight An XNA game contains game data which is used by the Draw and Update methods – Update updates the game data – Draw.
Rubber vloeren in de aanbieding online
CHAPTER 5 Text XNA Game Studio 4.0. Objectives Discover how text is drawn using Microsoft XNA. Add some font resources to your XNA program. Draw some.
XNA 4.0 Side Scrolling.
Lecture 4 Using SpriteFonts
Sprite Sheets, Game States
Using and Creating Sprites
Gameprogrammeren: Klassen en objecten in Painter
(H9.1) CirkelKlikker ARRAY int x, y; [ ] int n=0;
Gameprogrammeren: Edit states
Gameprogrammeren: Menu’s in Penguin Pairs
Implementing Polymorphism
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
null, true, and false are also reserved.
Collision Detection.
Animated Sprites.
Side Scrolling Game Development.
Die MP3 Speler.
Generics in C# / Anders Børjesson
2.3. Architectural Design I
Gameprogrammeren: Interactie in Penguin Pairs
Player preferences, Loading Scenes, Activating and Enabling
MTA-4201 Game Programming Chapter 8 : Scrolling Background & Font
Development of a particle system
Collisions with Static Objects
Presentation transcript:

Gameprogrammeren: Game states Arjan Egges Paul Bergervoet Wouter van Toll

Game states Veel games hebben verschillende game toestanden Hoofdmenu Optiemenu Helpmenu Aan het spelen Game over Highscore …

goede klassenstructuur! Game states Noemen we ook wel: Game states Hoe representeren we die toestanden? Hoe wisselen we tussen toestanden? Maak gebruik van een goede klassenstructuur!

Ad hoc manier in Jewel Jam public override void HandleInput(InputHelper inputHelper) { if (title.Visible) { if (inputHelper.KeyPressed(Keys.Space)) title.Visible = false; } else if (this.GameOver) this.Reset(); else ... Per game state andere invoer afhandelen.

Ad hoc manier in Jewel Jam Zelfde idee in Update. public override void Update(GameTime gameTime) { if (this.GameOver && !gameover.Visible) gameover.Visible = true; JewelJam.AssetManager.playSound("snd_gameover"); } else if (!helpFrame.Visible && !title.Visible) base.Update(gameTime); Kan tot verwarring leiden!

Algemeen game loop object Definieer een interface met daarin alle belangrijke game loop methoden. interface IGameLoopObject { void HandleInput(InputHelper inputHelper); void Update(GameTime gameTime); void Draw(GameTime gameTime, SpriteBatch spriteBatch); void Reset(); }

Klassen implementeren de interface Ook de GameObject klasse! class GameObject : IGameLoopObject { protected GameObject parent; protected Vector2 position, velocity; protected int layer; protected string id; protected bool visible; ... }

Game state manager class GameStateManager : IGameLoopObject { protected Dictionary<string, IGameLoopObject> gameStates; protected IGameLoopObject currentGameState; public GameStateManager() gameStates = new Dictionary<string, IGameLoopObject>(); currentGameState = null; } ...

Game state manager public void AddGameState(string name, IGameLoopObject state) { gameStates[name] = state; } public IGameLoopObject GetGameState(string name) return gameStates[name]; public IGameLoopObject CurrentGameState get return currentGameState;

public void SwitchTo(string name) { if (gameStates.ContainsKey(name)) currentGameState = gameStates[name]; }

Game state manager public void HandleInput(InputHelper inputHelper) { if (currentGameState != null) currentGameState.HandleInput(inputHelper); } public void Update(GameTime gameTime) { currentGameState.Update(gameTime); public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { currentGameState.Draw(gameTime, spriteBatch); ...

In PenguinPairs Static membervariabele: Met property: protected static GameStateManager gameStateManager; public static GameStateManager GameStateManager { get { return gameStateManager; } }

class TitleMenuState : GameObjectList { protected Button playButton, optionButton, helpButton; public TitleMenuState() { // create the game objects... } public override void HandleInput(InputHelper inputHelper) { base.HandleInput(inputHelper); if (playButton.Pressed) PenguinPairs.GameStateManager.SwitchTo("levelMenu"); else if (optionButton.Pressed) PenguinPairs.GameStateManager.SwitchTo("optionsMenu"); else if (helpButton.Pressed) PenguinPairs.GameStateManager.SwitchTo("helpState");

class OptionsMenuState : GameObjectList { protected Button backButton; protected Slider musicVolumeSlider; protected OnOffButton onOffButton; public override void HandleInput(InputHelper inputHelper) { base.HandleInput(inputHelper); if (backButton.Pressed) PenguinPairs.GameStateManager.SwitchTo("titleMenu"); } public override void Update(GameTime gameTime) { base.Update(gameTime); MediaPlayer.Volume = musicVolumeSlider.Value; ...

In PenguinPairs protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); screen = new Point(1200, 900); this.SetFullScreen(false); gameStateManager.AddGameState("titleMenu", new TitleMenuState()); gameStateManager.AddGameState("optionsMenu", new OptionsMenuState()); gameStateManager.AddGameState("levelMenu", new LevelMenuState()); gameStateManager.AddGameState("helpState", new HelpState()); gameStateManager.SwitchTo("titleMenu"); }

In PenguinPairs protected void HandleInput() { inputHelper.Update(); if (inputHelper.KeyPressed(Keys.Escape)) this.Exit(); if (inputHelper.KeyPressed(Keys.F5)) SetFullScreen(!graphics.IsFullScreen); gameStateManager.HandleInput(inputHelper); }

In PenguinPairs protected override void Update(GameTime gameTime) { HandleInput(); gameStateManager.Update(gameTime); } protected override void Draw(GameTime gameTime) GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, spriteScale); gameStateManager.Draw(gameTime, spriteBatch); spriteBatch.End();