Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.

Slides:



Advertisements
Similar presentations
Everything you ever wanted to know about collision detection
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Working with images and scenes CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.5 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
GENERAL USABILITY CONSIDERATIONS. Overview of usability Aspects of usability – Learnability, memorability, efficiency, error reduction Techniques for.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Geometrical Optics Mirrors and Thin Lenses
Computational Geometry & Collision detection
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Game Mathematics & Game State The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object Overlap.
Mechanics, Dynamics & Aesthetics The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object.
Collision Detection Michael Fuller. Overlap testing Most Common Technique Most Error Prone Test if two bodies overlap.
(An Introduction for Programmers)
PowerPoint: Tables Computer Information Technology Section 5-11 Some text and examples used with permission from: Note: We are.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
INTRODUCTION TO SCRATCH. About Me Resources Scratch Website Learn Scratch Washington-Lee Computer.
CS 4730 Collision Detection CS 4730 – Computer Game Design.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
SOURCE 2006 Presentation by Luke Arntson Game Programming Optimization.
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Week 2 - Wednesday CS361.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. This work is licensed under the Creative.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
B RIDGES T O C OMPUTING General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Motion Planning in Games Mark Overmars Utrecht University.
Sample Video Game & Sound. The Plan 1.Game Theme 2.Game Structure 3.Sprites 4.Trackers 5.Collisions 6.Score 7.Levels 8.Splash Screens 9.Design 10.Implementation.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Collision Detection And Response Jae Chun KyungSoo Im Chau Vo Hoang Vu.
Computer Game Design and Development
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
ROBOTC Software EV3 Robot Workshop
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Starting Out with Games & Graphics in C++ Tony Gaddis Chapter 8 The.
Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.
Introduction to Game Programming & Design III Lecture III.
General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited and encouraged to use.
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Intro & Point-to-Box, Circle-to-Circle, Point-to-Circle
Collision Detection Box-to-Box.
Chapter 4.2 Collision Detection and Resolution
Learn… Create… Program
Learn… Create… Program
Mechanics, Dynamics & Aesthetics
Electrostatics Superposition: Electric Field
Computer Animation Algorithms and Techniques
CO Games Concepts Week 12 Collision Detection
Learn… Create… Program
Learn… Create… Program
GPAT – Chapter 7 Physics.
Presentation transcript:

Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited and encouraged to use this presentation to promote computer science education in the U.S. and around the world. For more information about the Bridges Program, please visit our website at: Disclaimers: All images in this presentation were created by our Bridges to Computing staff or were found online through open access media sites and are used under the Creative Commons Attribution-Share Alike 3.0 License. If you believe an image in this presentation is in fact copyrighted material, never intended for creative commons use, please contact us at so that we can remove it from this presentation. This document may include links to sites and documents outside of the "Bridges to Computing" domain. The Bridges Program cannot be held responsible for the content of 3 rd party sources and sites.

Introduction to Game Programming & Design Lecture 3: Game State and Game Mathematics

Content 1. Player Expectations 1.Efficiency 2. Game Mathematics 1.Collision Detection & Response 2.Complexity 3. Game State 1.Game state 2.Agent state

Player Expectations In general, games are held to a higher standard than other types of programs. People expect "office applications" to fail, and don't expect 100% up-time from business websites. What we are willing to tolerate when "working" is wildly different then what we are willing to tolerate when "playing".

Efficiency Complexity and computability are concepts that are not normally taught on an undergraduate level. BUT game programmers need to consider "efficiency" in everything that they do. Studies have shown that if a player has to wait more than 30 seconds for levels to load in a game (3 sec on handheld devices), their "review" of that game will be greatly reduced.

Game Mathematics "Game Mathematics" refers both to areas of general mathematics (geometry, trigonometry, calculus) as well as specialized areas of mathematics (vectors, matrices). Graphic libraries, game libraries, 2D and 3D libraries exist for programming languages to help simplify the mathematical problems that you will face. But they can't be relied on to do everything. Game players will not tolerate a slow game or a game that crashes. Graphics are expensive (computationally) and prone to bugs.

Collision Detection Figuring out if two objects are touching is an incredibly common problem in a game: ◦ Ball games (pong) ◦ Shooting games. Two basic techniques: ◦ Overlap testing  Detects whether a collision has already occurred ◦ Intersection testing  Predicts whether a collision will occur in the future

Overlap Testing Facts: ◦ Most common technique used in games ◦ Exhibits more error than intersection testing Concept ◦ For every simulation step, 1.Move (update) all objects. 2.Test objects to see if they now overlap. 3.If objects overlap, make adjustments or corrections. ◦ Easy for simple volumes like dots, boxes and spheres, but harder for polygonal models.

Simple Overlap Testing Easiest example is of a particle interacting with a square. This will still require 4 logical tests in a 2D game. Depending on the type of game that played, the order of those 4 tests can have a profound effect on efficiency.

Complex Shape OOT How many tests would be required now? We should get fairly good results just testing the 16 green points against the box (4 tests each, 64 total tests)

Bounding Circles For some complex shapes we can use “bounding circles”: circles centered on the object that enclose all (or nearly all) of the object. To test whether or not two objects are colliding we can then just compare the distance between the centers of the circles to the sum of the radii of the circles (1 test). Bounding circles can be smaller than the object the enclose to help reduce error. Green Star bounding circle radius = 4.5 Red Star bounding circle radius = 7 If distance between center of stars is less than 11.5 stars can be assumed to be touching. We can find the distance between the center of the stars using the Pythagorean theorem. This will NOT give “pixel perfect” accuracy, but is usually “good enough”.

Bounding Boxes Some long and/or thin shapes don’t lend themselves to bounding circles, we can then use Bounding Boxes instead. Bounding Boxes can be used to reduce the complexity of shapes to simplify overlap testing. Note that secondary testing may need to be done if the bounding box is found to overlap. How many test now? (Hint: green dots)

Minkowski Sum In our previous example we will still need about 32 (8 dots *4) tests to determine if the boxes overlap. There exists a simple technique for reducing the number of tests necessary even further. By taking the Minkowski Sum of two complex volumes and creating a new volume, overlap can be found by testing if a single point (the center of one of our shapes) is within the new volume (4 tests). Variations on the Minkowski Sum include calculating the x, y and z distances between the two objects that are being tested.

Minkowski Sum

Minkowski Sum for bounding boxes Find the center point of the two bounding boxes. Add ½ the height of the 1 st boxes height to the top and bottom of the 2 nd box. Add ½ the width of the 1 st boxes width to each side of the 2 nd box. This new box you have created is Qm (Q1 on Q2). Test the center of Q1 against Qm (4 tests).

OT – Determining Collision Time If we detect overlap we need to "go back" to the moment of time immediately before the objects overlapped; then calculate where the object should now be. Collision time is calculated in OOT by moving the object backward until right before the collision occured. ◦ Bisection is one effective technique. Θ(log n) ◦ Storing Minkowski values to have a standard "collision distance" another.

Collision Response Having captured the exact moment and position of collision (O), and determined how far the object has left to move (Q) We can then use geometry, and trigonometry to calculate the objects resulting trajectory ( Θ r ).

Limits of OT OT is relatively easy and fast but limited. 1.Difficult with very complex shapes 2.Fails with objects that move too fast ◦ Unlikely to catch time slice during overlap Possible solutions 1.Accept that "pixel perfect" accuracy usually not necessary 2.Constrain size/speed of objects or system:  Make objects really big ( halo sniper bullets... really long )  Design constraint on speed of objects  Reduce simulation step size (test physics more often than graphics) If none of those solutions work.. use Vectors

Vectors "Vector images" are images created by a math formulas. We can represent objects (and their velocity) with formulas Special vector mathematical operations can then be applied to reveal information about where objects will be and whether or not they will collide (at any time, past or future). Vector CD/CR (collision detection / collision response) is costly and slow. We won’t be using Vectors in this class OOT is good enough. Pv[ 10, 5, 12, 6]; // A particle vector.

Game Mathematics In SCRATCH But you won’t even need to use OOT!!! SCRATCH simplifies game mathematics for you, with a couple of handy blocks. ◦ Object collision detection in SCRATCH can be done with a simple "touching" block. ◦ Objects can be kept on screen with a simple "if on edge, bounce" block. ◦ Most other functions we would usually need Trig or Geometry for (point towards) also have simple solutions.

Game State All games consist of a sequence of states. Each state is characterized by a combination of visual, audio and/or animation effects, as well as a set of rules that are being applied.

Object State Objects in the game proceed through their own states as well. These states are defined by the behavior and functionality applied at that time.

Game State in Scratch At typical game in Scratch might use the following state transition diagram.

Object State in Scratch In a typical game in Scratch, all of your normal sprites (not stage or any control sprites like buttons) will work very well with only 4 scripts. These scripts (and any associated variables) will control the objects state.

The End