11 General Game Programming Approach. The program is event-driven The program is event-driven –Messages = events –So as all windows system (for example.

Slides:



Advertisements
Similar presentations
Game Programming Patterns Game Loop
Advertisements

GUI Programming Alex Feldmeier.
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
3.3. G AME I NPUT Handling input within games. In lecture exploration of answers to frequently asked student questions.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2010/2011.
How do games work? Game Workshop July 4, Parts Sprites/pictures Map/background Music/sounds Player character Enemies Objects.
Game Design and Programming. Objectives Classify the games How games are design How games are implemented What are the main components of a game engine.
Based on slides created by Edward Angel
Interaction Models I Marti Hearst (UCB SIMS) SIMS 213, UI Design & Development March 9, 1999.
AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development.
Week 1 - Friday.  What did we talk about last time?  C#  SharpDX.
Prof. Roger Crawfis Computer Science & Engineering The Ohio State University Advanced Game Design.
PacMan by Midway, released 1980 CSE 380 – Computer Game Programming Real-Time Game Architecture.
Using C++ and OpenGL George Georgiev Telerik Corporation
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.
Town Defenders Strategy Game prepared by: Osama N
Input/ Output By Mohit Sehgal. What is Input/Output of a Computer? Connection with Machine Every machine has I/O (Like a function) In computing, input/output,
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Design Document Presentation. Review Quoridor – a board game played on a grid where players must advance tokens across a board to win. Our basic objective:
1 ETC. 2 Sounds FX Sounds FX –WAV audio files –Load into memory and play it »Load »Play »Stop »Pause –2D or 3D »3D should be integrated into scene management.
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
Computer Graphics I, Fall 2010 Input and Interaction.
CS 480/680 Computer Graphics Programming with Open GL Part 7: Input and Interaction Dr. Frederick C Harris, Jr. Fall 2011.
CS350 – Windows Programming Formerly and more properly named: Event Driven Programming Dr. Randy Ribler.
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
Control flow for interactive applications CSE 3541 Matt Boggus.
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
1 Contents  Audio  Sprite  Input devices  Game production milestones  Course summary.
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
CSE 381 – Advanced Game Programming User Interface & Game Events Management.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
University of New Mexico
Game Programming Patterns Game Loop From the book by Robert Nystrom
Programming Games Show your rock-paper-scissors. Demonstrate bouncing ball. Demonstrate and examine Bo the dog. Homework: Modify Bo to make your own.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Game program main loop.
Introduction to Game Programming Pertemuan 11 Matakuliah: T0944-Game Design and Programming Tahun: 2010.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
 objects in Client  What is Event?  Event Handlers  programming.
02 |Introduction to Game Engine Eriq Muhammad Adams J |
Microsoft Foundation Classes
Enhancing JavaScript Using Application Programming Interfaces (APIs), Lecture #3.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
(More) Event handling. Input and Windowed-OS’s Windowed OS’s (Windows, OSX, GUI-linux’s) send messages (events) when the user does something “on” the.
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
2D Game Programming with XNA 4.0. Principles of Game Programming Game Programming Basics Mouse & Keyboard Controls Sounds Sprites and Animation Collision.
MORE Genre Specific Physics
Game Engine Architecture
Part II Reference:
Let’s Learn 2. Installing Pygame
8. Installing Pygame
Event-driven programming
Game Loops + Part II Reference:
Goals Give student some idea what this class is about
CSC461 Lecture 8: Input Devices
Game Engine Architecture
Game and animation control flow
Advanced Game Design Dr. Matt Boggus
8. Starting Pygame Let's Learn Python and Pygame
Isaac Gang University of Mary Hardin-Baylor
Input and Interaction Ed Angel
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
University of New Mexico
Input and Interaction Ed Angel
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
CoE Software Lab II 1. Pygame Intro , Semester 2,
05 | Capturing User Input Michael “Mickey” MacDonald | Indie Game Developer Bryan Griffiths | Software Engineer/Game Developer.
Presentation transcript:

11 General Game Programming Approach

The program is event-driven The program is event-driven –Messages = events –So as all windows system (for example : X window) We need a loop to check all incoming events We need a loop to check all incoming events The Loop The Loop –Check all incoming events (messages) –Handle the events –Check timing and do something in regular Incoming Events Incoming Events –Interrupts –System requests 2 Event-driven Programming (1/3)

Timers (do something in regular timing) Timers (do something in regular timing) –The sub-system to handle timing –Must be precise to at least 1 ms or less »30fps = 1/30 second = … ms –On win32 platform, we can use “performance counter” instead of the win32’s “WM_TIMER” message »For windows9x, WM_TIMER = 18.2 fps (maximum) Events Events –Input devices »Mouse »Keyboard –Something coming from network –System requests »Re-draw »Losing/getting the input focus »…»…»…»… 3 Event-driven Programming (2/3)

Therefore, we have two types of jobs: Therefore, we have two types of jobs: –In regular »Timers callbacks –By requests »Input device callbacks Same as a game main program Same as a game main program –A game is an interactive application –A game is time-bound »Rendering in 30fps or 60fps »Motion data in 30fps »Game running in 30fps »…»…»…»… 4 Event-driven Programming (3/3)

Single Player Single Player 5 Check game over Peek player input Implement timer callback Exit the loop Rendering Loop y n Game Loop (1/2)

Network Client Network Client 6 Check game over Peek user input Receive messages Send messages Timer callbacks Rendering Exit y n From network To network Loop Game Loop (2/2)

Check Win/Loose Check Win/Loose Check Quit Check Quit Objects Moving … Objects Moving … Play Character’s Motion to Next Frame Play Character’s Motion to Next Frame Play Animation to Next Frame Play Animation to Next Frame –Models –Textures –…–…–…–… Perform Some Game Calculation Perform Some Game Calculation Perform Geometry Calculation Perform Geometry Calculation –LOD Perform AI “Thinking” Perform AI “Thinking” Perform Collision Detection Perform Collision Detection Perform the 3D Rendering Perform the 3D Rendering … 7 Jobs in Regular (Typically)

Mouse Input Mouse Input –Press/release the mouse button –Drag –Double-click –Move Keyboard Input Keyboard Input –Hotkey –Typing Gamepad Gamepad –Same as the hotkey Network Network System System 8 Jobs By Request (Typically)