3.3. G AME I NPUT Handling input within games. In lecture exploration of answers to frequently asked student questions.

Slides:



Advertisements
Similar presentations
Structured Design The Structured Design Approach (also called Layered Approach) focuses on the conceptual and physical level. As discussed earlier: Conceptual.
Advertisements

Understanding an Apps Architecture ASFA Computer Science: Principles Fall 2013.
In put Devices and Media In order for a computer to do anything it must be told what to do.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Microsoft® Small Basic
Lecture 2Slide 1 Event Driven Computing Basic Interaction Handling –Interactive programs - must pay attention to the user interface.
CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 1 Tariq Aziz and Kevin Jones.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Event-Driven Programming and Access Events
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Software Development. Chapter 2 – Programming on Windows 8.
CHAPTER 1 XNA Game Studio 4.0. Your First Project A computer game is not just a program—it is also lots of other bits and pieces that make playing the.
Event-driven programming. Most modern computer programs that people use have Graphical User Interfaces (GUIs). A GUI has icons on the computer screen.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
Unit 20: Event Driven Programming
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
Lecture 2 Event driven programming Mobile and Handheld Applications1 Programming of Handheld and Mobile Devices Lecture 2: Event driven programming concepts.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Event Driven Programming
Unit 1_9 Human Computer Interface. Why have an Interface? The user needs to issue instructions Problem diagnosis The Computer needs to tell the user what.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Developing the Game User Interface (UI) Lesson 5.
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
Basic Computer and Word Functions, part 1 Read the information and use to answer the questions in the Basic Computer and Word Functions Study Guide.
Martin Schmidt / The Silent Revolution Mobile Java.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
11 Using the Keyboard Session Session Overview  Introduce the keyboard device  Show how keys on a keyboard can be represented by enumerated types.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 14 Event-Driven Programming.
Lecture 11: Exam Revision 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271  Coursework.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
2.1. T HE G AME L OOP Central game update and render processes.
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,
MIT 6.893; SMA 5508 Spring 2004 Larry Rudolph Lecture 4: Graphic User Interface Graphical User Interface Larry Rudolph MIT 6.893; SMA 5508 Spring 2004.
2.3. A RCHITECTURAL D ESIGN I Example approach for game screen management.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Event-Driven Programming 1.
Programming in the Simple Raster Graphics Package (SRGP) Chapter 2.
11 General Game Programming Approach. The program is event-driven The program is event-driven –Messages = events –So as all windows system (for example.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
Event Handling Tonga Institute of Higher Education.
7th Meeting TYPE and CLICK. Keyboard Keyboard, as a medium of interaction between user and machine. Is a board consisting of the keys to type a sentence.
Software 3 See Edmodo for images Group name: topcat Group code: i4qf9a 11/03/11.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Creating User Interfaces Event-Driven Programming.
Understanding JavaScript and Coding Essentials Lesson 8.
Introduction to Computing Slides By ADEELA MUSTAFA.
Menu A list from which the user may select an operation to be performed. I look at the menu to see what I want to do.
CHAPTER 7 TouchGestures. Chapter objectives: To code the detection of and response to touch gestures. Patterns of common touches to create touch gestures.
2D Graphics CMT3311. This covers... How to make a transparent sprite How to add a sprite to your project and draw it Properties of sprites and how to.
Lecture Input Devices Keyboard. Mouse Microphone Digital Camera Scanner.
Events and Event Handling
CS 134 Alternate Inputs.
Introduction to Event-Driven Programming
Event-driven programming
System Design Ashima Wadhwa.
CSC461 Lecture 8: Input Devices
Understanding an App’s Architecture
Understand Windows Forms Applications and Console-based Applications
Lesson 1: Buttons and Events – 12/18
Introduction to Events
Event Driven Programming
Introduction to Computing Using Java
Hands-on Introduction to Visual Basic .NET
Explain what touch develop is to your students:
Explain what touch develop is to your students:
Object-Oriented Programming (OOPs)
Presentation transcript:

3.3. G AME I NPUT Handling input within games

In lecture exploration of answers to frequently asked student questions

Different input devices and their use within games

There are a wide range of different devices used to provide input into games. Some devices are platform specific, e.g. mice are mostly the preserve of PCs, etc. Devices tend to provide different usability profiles and will differ in terms of their suitability to some types of game. A game should best exploit the various input devices it is designed to run with.

Input devices need not restrict themselves to the press of a button or movement of some stick (e.g. touch screen, gamepad, driving wheel, joystick). Novel forms of game interface can include: Bit of fun: You have 5 minutes to come up with an interesting form of gameplay for any of these novel forms of interface. Distant motion recognition Speech input Emotion/thought recognition 5 mins4 mins3 mins2 mins 1 min 30 secFinished Start

Games on this module will likely use a keyboard, mouse or gamepad controller, from which the following types of input are possible: Pressing a key/button Releasing a key/button (key press+release = typed) Moving the mouse/thumbstick Pressing a mouse button Released a mouse button (press+release = click) Squeezing a trigger Aside: Buttons and keys are examples of 2-state discrete (on/off, in/out) input. Thumbsticks, mouse location and triggers are examples of ranged input (float/integer return value). To do: Apply to own game

Event driven input vs. input polling

Event-driven input assumes that one, or more, event handlers will handle a defined range of event types. Given an input event, the designated call-back event handler is executed, consuming the event and taking whatever associated action is necessary. In contrast, input polling operates by getting the state of the input device a regular sampled intervals and checking for change. Most games use input polling.

Low level of control, fits well with the frequent update-draw loop in games Input polling provides a snap-shot at an instant in time. Events occurring over a period of time must be inferred from changes in the snap-shots. This includes ‘basic’ events such as a typed key or more sophisticated events such as a mouse drag. Time 15ms 30ms 45ms 60ms 75ms 90ms 105ms State Up Up Down Down Down Down Up Typed Event Pressed +Released

update() { if( ‘Launch’ key is pushed down) LaunchProjectile(); } At 60 updates per second, there are some things you do not want to do every update (and maybe only twice per second) Sometimes you might only want to do something once an animation has finished playing: update() { if( input event detected ) if( event execution requirements passed ) ExecuteEvent() } In general:

Many games support multiple input devices and/or user configurable controls. Within such games it is advantageous to decouple input from input event checking. Decoupling enables input mapping logic to be separated from the code that responds to input events. More generally, decoupling helps promote software extensibility and reusability. update() { ConsiderInput() } ConsiderInput () { if( ‘A’ button pressed ) DoAction() } update() { CheckForInput() ConsiderInput() } CheckForInput () { if( ‘A’ button pressed, or ‘J’ key ) set JumpInputEvent = true } ConsiderInput () { if(JumpInputEvent == true ) DoAction() }

Overview of game input using XNA/Java

The Java Code Repository makes available a GameInputEventManager which offers basic keyboard and mouse input (including key/button pressed, new key presses, etc.)

XNA provides GamePad, Keyboard and Mouse classes each with a GetState() method that returns a GamePadState, KeyboardState or MouseState respectively. When using XNA it is common to store the previous input state (from the last update) and compare this against the current input state to detect input event occurrence (e.g. button just pressed, etc.) Aside: XNA4.0 also provides support for touch-screen devices and gestural input

To do: Consider Input In relation to your project, you should: For each layer, determine the needed user input (e.g. for navigating a menu, or controlling a character, etc.) Decide the emphasis that will be placed upon input in your design. Important: Marks will be given for designs that decouple input, enable user customisation, etc. This may be of interest for projects weighting the ‘Extent of game features’ section highly. Balance the implementation cost of this vs. what you hope to achieve in your game.

To do: Continue to explore image repository and select graphics Continue to write code that loads and displays images. Determine necessary input and how it will be implemented Today we explored: Different input devices and their use Event driven vs. Input polling Project input design consideration