140 likes | 370 Views
Nguyễn Trung Hải. Game Development basic. Outline. Game Structure Animation using Sprite Demo. Reference. [1]: http://en.wikipedia.org/wiki/Game_programming [2]: Mummy Game Project. Game Structure. Game Structure. Game loop: While (1) { check for user input run AI
E N D
Nguyễn Trung Hải Game Development basic
Outline • Game Structure • Animation using Sprite • Demo
Reference • [1]: http://en.wikipedia.org/wiki/Game_programming • [2]: Mummy Game Project
Game Structure • Game loop: While (1) { check for user input run AI move enemies resolve collisions draw graphics play sounds }
Game Structure • Game States: • Splash • Main Menu • Loading • In Game • In Game Menu • Win Over
Game Structure • Implement: Run() { switchState(beginningState); while(!exitState) { updateState(State,Mode); repaint(); } }
Game Structure • Implement: • switchState(): is a function that will change Game State from this state to another one. switchState() { Call Old-State’s destructor(); Call New-State’s constructor(); }
Game Structure • Implement: • updateState(): every Game State has its update() function such as: updateSplash(), updateMainMenu(),... • General upadateState() function has 4 modes: • Constructor • Destructor • Paint • Update (update information cause gamer interaction)
Game Structure • Implement: • Repaint(): will call paint() function of every game state. Paint() { updateState(currentState, mode=Paint); }
Game Structure • Frame Per Second (FPS): Const FPS = 25; Const Timer = 1000/FPS; ... while(!exitState) { updateState(State,Mode); repaint(); compute sleeptime; if (sleeptime>0) wait sleeptime; }
Animation using Sprite • Code Implement: • Create new Sprite Object: • Image Path • Sprite Width & Heigh • Transparency process • Set Frame Sequence. • Draw Sprite object.
Demo • Mummy Game