SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Game Programming Patterns Game Loop
SE320: Introduction to Computer Games Week 7: Core Mechanics Gazihan Alankus.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
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.
Applets. An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from a browser You.
29-Jun-15 Threads and Multithreading. 2 Multiprocessing Modern operating systems are multiprocessing Appear to do more than one thing at a time Three.
CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)
Threads II. Review A thread is a single flow of control through a program Java is multithreaded—several threads may be executing “simultaneously” If you.
SE 350 – Programming Games Lecture 1: Introduction Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked with TODO) 2/10/20121.
Fibonacci Problem Solving and Thinking in Engineering Programming H. James de St. Germain.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley This week: Whew!!! The last homework was tough! The homework for this week.
CSE 380 – Computer Game Programming Render Threading Portal, by Valve,
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Introduction to Scratch!
Unit 1 – Improving Productivity Instructions ~ 100 words per box.
SE 320 – Introduction to Game Development Lecture 8: Animations, GUIs, Debugging and IDEs Lecturer: Gazihan Alankuş Please look at the last two slides.
Software Design 4.1 Tell, Don't Ask l Tell objects what you want them to do, do not ask questions about state, make a decision, then tell them what to.
KeyListener and Keyboard Events Another type of listener listens for keyboard entry – the KeyListener which generates KeyEvents –to implement KeyListener,
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
CS107 References and Arrays By Chris Pable Spring 2009.
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
Concurrent Programming and Threads Threads Blocking a User Interface.
Documentation. Your documentation must fit the needs of your audience. It’s always better to say one thing that is useful, as opposed to many things that.
Grade Book Database Presentation Jeanne Winstead CINS 137.
1 Frisbee Physics Simulation Charles George Advisor: Brian Postow 03/05/05.
1 CS161 Introduction to Computer Science Topic #9.
Understand the difference between applets and applications Identify meaningful applet resources for academic subjects Create and demonstrate a basic Java.
Introduction to visual programming C#. Learning Outcomes In this chapter, you will learn about :  Event-Based Programming  The Event Based Model  Application.
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
Game Programming Patterns Game Loop From the book by Robert Nystrom
A Puzzle for You. Puzzle Someone is working for you for 7 days You have a gold bar, which is segmented into 7 pieces, but they are all CONNECTED You have.
Week 61 Introduction to Programming Ms. Knudtzon C Period Tuesday October 12.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
CompSci Introduction to Jam’s Video Game Package.
CRE Programming Club Class 8 Robert Eckstein and Robert Heard.
Chapter 5 Interaction: Events and Event Handling.
Computer Science I Share plans for virtual something. Text. Show my virtual dog. Classwork: Plans for your virtual something. Homework: start implementation.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
Threads and Multithreading. Multiprocessing Modern operating systems are multiprocessing Appear to do more than one thing at a time Three general approaches:
CHAPTER Agenda Applets Servelets Browsers HelloWorld.
SE 350 – Programming Games Lecture 5: Programming with Unity Lecturer: Gazihan Alankuş Please look at the last slide for assignments (marked with TODO)
CompSci 44.1 Game Package Introduction to Jam’s Video Game Package.
Introduction to: Python and OpenSesame FOR PROS. OpenSesame In OpenSesame you can add Python in-line codes which enables complex experiment. We will go.
SE320: Introduction to Computer Games Week 3 Gazihan Alankus 10/4/20111.
Comp1004: Introduction III Java. Content How Java Works: The JVM Writing a Class in Java – Class – Member Variables – Method – Statement Magic incantations.
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
FOP: Multi-Screen Apps
Game Loops + Part II Reference:
Introduction to Events
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Game Loop Frame Rate.
AN INTRODUCTION TO: POWERPOINT.
Game Loop Update & Draw.
CSCI1600: Embedded and Real Time Software
Lecture 7: Introduction to Processing
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Threads.
Software Development Techniques
Presentation transcript:

SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus

Outline Brief chat about projects Game programming

Outline Brief chat about projects Game programming

Brief Chat about Projects How is it going? Three weeks left for your first presentation (December 13). What I expect: – A simple but playable version of your game – An in-class demo – (Optional) User tests (what you learned, etc.) Meetings that you want me in Help session

Outline Brief chat about projects Game programming

Game Programming Games – Multimedia – Interactive How you are used to program – Sequential – Text-based – Input/output

Game Programming High level, code independent, pseudo-code Low level, using a specific library Ideas Program

Anatomy of a Game Multimedia – Continuously changing visuals – Sound and music – Other forms of feedback Interactive – User input affects the program – Immediate results of user input

Let’s try to approach it the old way How you are used to program – Sequential – Text-based – Input/output Let’s think: how would you code a game? – Multimedia – Interactive – 10min practice int main() { printf(“hello world”); return 0; }

What should the computer do? Render many times every second, like a movie Between the render calls, update what needs to be updated – Advance animations – Simulate physical things (velocity, acceleration, gravity) Whenever user does something, take the appropriate action

What should the computer do? State (variables) Render (visualize the state) Update (change the state) Handle input (let user change state)

When should these be done? Render time Update

When should these be done? Render time Update Handle input int main() { printf(“hello world”); return 0; } How can I make this happen? void render() void update() void handleInput()

Sample game main loop while(1) { wait for some time so you don’t loop too fast. did enough time pass since last render? render(); did enough time pass since last update? update(); did the user press a key or moved the mouse or something? handleInput(); } Problem? Where do you get the input here?? Instead, need to listen to input. If we do that it blocks (stops and waits) Need a thread that is listening for user input.

Sample game main loop and event listener while(1) { wait for some time so you don’t loop too fast. did enough time pass since last render? render(); did enough time pass since last update? update(); } while(1) { wait for user input handleInput(the input that I got); } One extra thread Things are getting complicated… That’s why we like to use libraries that do the dirty work for us This way we can concentrate on what’s important: the game logic These run at the same time

What should the computer do? State (variables) Render (visualize the state) Update (change the state) Handle input (let user change state) void render() void update() void handleInput()

Game Libraries All game libraries should somehow do these three things – Find how the game handles these three things – Find where it provides you functions to fill in – Fill them in, remember how they work and where you should do what void render() void update() void handleInput()

Some rules of thumb Determine which variables, objects, etc. are your game state. Code your render function so that you only reflect the game state on screen – Do not change the game state in the render function! Use time in your update function to update your state. – Do not assume that the update function will be called with regular time intervals. Never change things with fixed values. Always make changes depending on the current time, or duration since last update. – Do not draw anything in your update function Make your input handler very simple. Only change values of game state. – Do not do any rendering in the input handler – Do not make any long update work such as simulating physics. Updates to state should be done in the update function.

Some rules of thumb Determine which variables, objects, etc. are your game state. When you add new state variables, make sure you know it is a part of game state Initialize your state well State (variables)

Some rules of thumb Make your render function simple – Only reflect the game state on screen. – Do not change the game state. – Do not make it depend on time. Render (visualize the state)

Some rules of thumb Make your update function depend on time. – Do not assume that it will be called with regular time intervals. Never change values with fixed values. Always make value changes depend on the current time, or duration since last update. – Location = Location + timeSinceLastUpdate * speed Do not do any rendering in your update function. Update (change the state)

Some rules of thumb Make your input handler very simple. – Only change values of game state. – Do not make any long update work such as simulating physics. – Updates to the actual state should ideally be done in the update function. (unless they are very simple changes) Do not do any rendering in the input handler. Handle input (let user change state)

The library can take over some work State (variables) Render (visualize the state) Update (change the state) Handle input (let user change state) Game Object

“Smart” objects Add me to the game and don’t worry about anything! – I’ll render myself when the time comes. Just tell me how I look. – I’ll update my animations. Just give me the high level details. – I’ll follow the mouse, if you want. Fill my own render(), update(), handleInput() functions – They will be called from the actual ones automatically Game Object

Exercises on the board Side-scroller space shooter Platform

Let’s actually implement them! Next week, if no time is left.

Help Session After Class You are welcome to stay for the Java + Slick2D help session