(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.

Slides:



Advertisements
Similar presentations
Sprite-visual object (actor on the stage) Scripts- Tells actors (sprites) what to do.
Advertisements

Introduction to Macromedia Director 8.5 – Lingo
Create a Simple Game in Scratch
Computer Organization. The Nature of Data Spreadsheets give us a way to create processes that manipulate data We can think of a piece of data as a quantity.
Create a Simple Game in Scratch
Game Programming Patterns Game Loop
How do games work? Game Workshop July 4, Parts Sprites/pictures Map/background Music/sounds Player character Enemies Objects.
CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)
Games Development Practices Semester 2 Overview CO2301 Games Development 1 Week 14.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
GameMaker.  A lot of Different Definitions  Easier to Say What is NOT a Game  Movie is Not a Game  No Active Participation  Final Outcome is Fixed.
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Guide to Programming with Python
PacMan by Midway, released 1980 CSE 380 – Computer Game Programming Real-Time Game Architecture.
CSE 381 – Advanced Game Programming 3D Game Architecture.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
Art 315 Lecture 4 Dr. J. Parker AB 606 Today’s class: Programming! We are going to write some simple programs. We will use a tool called GameMaker –It.
Lecture 02: Intro to SDL Topics: Downloading / Installing SDL Linking (in general and for SDL) SDL basics References:
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Visual Basic .NET BASICS
CS350 – Windows Programming Formerly and more properly named: Event Driven Programming Dr. Randy Ribler.
References: Wikipedia PHYSICS + VECTORS.  Why physics?  Good for every game developer to know.  Physics formulae are often vector-based  A good chance.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
PowerPoint Basics Tutorial 4: Interactivity & Media PowerPoint can communicate with the outside world by linking to different applications, managing different.
CSE 380 – Computer Game Programming GUIs for Games.
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
Geena Prior Event 3 : User Interface Presentation.
11 General Game Programming Approach. The program is event-driven The program is event-driven –Messages = events –So as all windows system (for example.
Game Programming Patterns Game Loop From the book by Robert Nystrom
Physics + Vectors References: xyz. Variable frame rates (review) Two options for handling it: – Option1: Cap frame rates When moving / rotating express.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Game program main loop.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Tutorial 7 Creating Animations. XP Objectives Learn about animation Create a timeline Add AP divs and graphics to a timeline Move and resize animation.
CRE Programming Club Class 8 Robert Eckstein and Robert Heard.
Application software- programs that let you do things What are some computer programs that you or your parents use on the computer?
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 15 Event-Driven Programming and.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Pac Man Game To make the pac man game. I created sprites for the pac man character so he could move in all directions. I also created sprites for the wall.
PyGame - Unit 2 PyGame Unit – – Animation.
Trigonometry and Applications References: xyz. Review (?) from ETGG1801 Angles – As a measure of rotation and/or orientation – Radians & Degrees (and.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Chapter 1 – Expressions, Equations, and Functions Algebra I A - Meeting 4 Section 1.6 – Represent Functions as Rules and Tables Function – is a pairing.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Section06: Sequences Chapter 4 and 5. General Description "Normal" variables x = 19 – The name "x" is associated with a single value Sequence variables:
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
SCREEN CAPTURE 532CS: eLearning Fall 2015 Submitted to Dr. Namdar Presented by Khaled Alamer.
Section06: Sequences Chapter 4 and 5.
CS345 – Event-driven Programming
Animations.
Part II Reference:
PYGAME.
Let’s Learn 2. Installing Pygame
8. Installing Pygame
Keyboard Input.
Event-driven programming
Game Loops + Part II Reference:
Lesson 1: Buttons and Events – 12/18
Windows Desktop Applications
Event Driven Programming
CS 106A, Lecture 14 Events and Instance Variables
8. Starting Pygame Let's Learn Python and Pygame
10. User Input Let's Learn Python and Pygame
Games Development Practices Semester 2 Overview
CoE Software Lab II 1. Pygame Intro , Semester 2,
Presentation transcript:

(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 window: – Move mouse – Press a key – Close the window – Resize the window – Minimize / maximize The window notifies the program when these first happen. The application can respond to these (event handling)

Input and Windowed OS’s What we've been using so far… device-polling: get the current state of an input device. – “Is the ‘a’ key currently pressed? – Where is the mouse cursor?

Event handling in pygame A second way… Event Handling The pygame.event.get() function returns a list of new event objects. – Each object has a.type attribute (a variable) You can compare it to pygame.XYZ variables to determine its type. Depending on the type, the event object may have other Calling pygame.event.get() empties the event queue for your window.

Examples Write a program which: – Can be closed by clicking the ‘X’ or by pressing escape. – Can be resized / fullscreen-ed – Mouse-over and click-release on a "quit button".

A few more pygame tidbits Clock objects – tick – get_fps Sounds / Music – loading and playing

A Game Loop "problem" So…a game loop run on these would be faster / slower. Character moving at 100 pixels / s. – Suppose we write it on the IIgs – What would it look like on the Alienware? IIgs image: Alienware image: Do these run at the same speed?

A Game Loop "problem", cont. Solution #1: Insert pauses – Set a desired frame rate (60fps == 1/60s per frame) – Calculate time since last frame – Insert a time.sleep if necessary. – Advantage: simple – Disadvantages: If the computer can't reach 60fps, there will be differences. time.sleep pauses everything. We could do useful work during that pause – AI calculations – physics – etc.

A Game Loop "problem", cont. Solution #2: Adjust movements based on dt – Let the computer run as fast as possible – Calculate dT (the time since last frame) – Express desired movments speeds as a velocity (e.g. 100 pixels / s) – Each frame, velocity * dT is the distance to move. On a slow computer… On a fast computer… – This is what's done on most PC games and most modern consoles.