2D Collision Detection For CSE 3902 By: Matt Boggus.

Slides:



Advertisements
Similar presentations
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Advertisements

Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
2.3. B OUNDING V OLUMES Bounding volumes of use for collision detection.
Hidden Surface Removal Why make the effort?  Realistic models.  Wasted time drawing. OpenGL and HSR  OpenGL does handle HSR using the depth buffer.
Space Partitioning for Broad Sweep Collision Detection Part 2 - Quadtrees Game Design Experience Professor Jim Whitehead February 13, 2009 Creative Commons.
Quad Trees By JJ Shepherd. Introduction So far we’ve only used binary trees to solve problems – Sort data – Search data – Confuse students Trees are not.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Binary Image Compression Using Efficient Partitioning into Rectangular Regions IEEE Transactions on Communications Sherif A.Mohamed and Moustafa M. Fahmy.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
Lattice Multiplication is an alternative way of doing higher level multiplication.
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.
2D Collision Detection For CSE 3902 By: Matt Boggus.
Some Cool Tricks.  We can consider the screen as high school graph paper.  Each sprite or object is located somewhere in the coordinate system.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 23 Game Graphics II.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
(C) 2010 Pearson Education, Inc. All rights reserved. Omer Boyaci.
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.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
By: James Ross. Outline  Collision Conecpts  Axis Aligned Bounding Box  ECMs  Objective  Methodology  Expected Results.
Scratch Programming Lesson 2 First glance to programming logic.
Tkinter Canvas.
Collision Detection and Response. Motivation OpenGL is a rendering system OpenGL is a rendering system OpenGL has no underlying knowledge of the objects.
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
Collision Detection Kaboo m!. The Plan ● What is collision detection? ● Why is collision detection important? ● Classification of collision detection.
Collision Detection And Response Jae Chun KyungSoo Im Chau Vo Hoang Vu.
Tessellations You will need two pieces of computer paper and a small piece of thick paper and your final paper.
Implementation of a Renderer Consider Programs are processd by the system line & polygon, outside the view volume Efficiently Understanding of the implementation.
1.Begin by opening VB 2.Click New Project or the icon Hello World Tutorial NOTE: depending on your version of VB – the images might be slightly different.
Computer Game Design and Development Collision Detection Havok Destruction.
© 2001 – All Rights Reserved – Page 1 Selections Selections.
2D drawing basics For CSE 3902 By: Matt Boggus. Overview 2D coordinate systems Raster images Sprite drawing in XNA.
Sprite sets. project of the week: bubble popper o objects appear from the bottom and slide up o player needs to avoid objects to earn points (objects.
1 compares each element of the array with the search key. works well for small arrays or for unsorted arrays works for any table slow can put more commonly.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
13. Sprites. Outline 1.Game Things in Pygame (again) 2.The Pygame sprite Module 3.The Sprite Class 4.Groups of Sprites 5.Types of Collision Detection.
2D Graphics Optimizations
MORE Genre Specific Physics
Surface Area I can calculate the surface area of a prism Direction:
Surface Area Tutorial Read and answer the questions on each slide.
2D Physics and Camera Systems
Additional Design Patterns for Games
Introduction to Collision Detection
2D drawing basics For CSE 3902 By: Matt Boggus.
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Intro & Point-to-Box, Circle-to-Circle, Point-to-Circle
Collision Detection Box-to-Box.
Graphics Fundamentals
CHAPTER 11 AREAS OF PLANE FIGURES
Sit-In Lab 1 Ob-CHESS-ion
Learning Intention I will learn how a computer stores graphics.
1. Encode binary value using PCM
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
13. Sprites Let's Learn Python and Pygame
2D Collision Response For CSE 3902 By: Matt Boggus.
Bitwise Operators CS163 Fall 2018.
Objective of the lesson
Find the volume of the solid obtained by rotating the region bounded by {image} and {image} about the x-axis. 1. {image}
Let’s Learn 7. Sprites Saengthong School, June – August 2016
Collision Detection Platforms.
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Rendering – Basic Concepts
Collision Detection.
Section 11-1 Areas of Rectangles.
The coordinate system Susan Ibach | Technical Evangelist
David Johnson Cs6360 – Virtual Reality
The Image The pixels in the image The mask The resulting image 255 X
7.1 Area of a Region Between Two Curves.
CMPT 120 Lecture 22 – Unit 4 – Computer Vision
Chapter 7 The Game Loop and Animation
CoE Software Lab II , Semester 2, Sprites.
Presentation transcript:

2D Collision Detection For CSE 3902 By: Matt Boggus

Outline Collision tests Collision detection loops Pixel-pixel Square-square Axis-aligned bounding box (rectangle) testing Collision detection loops Exhaustive comparison Static objects vs. dynamic objects

Collision Detection tests

Pixel-pixel test Given sprite pixel data and position on screen, make a binary mask for each sprite Detection test (XOR == 1) Not intersecting (XOR == 0) AND (OR == 1) Intersecting Pro: Accurate Con: Slow; requires working with image data Raster graphic sprites (left) and masks (right)

Square-square test

Square-square test

Square-square top-bottom collision

Square-square left-right collision

Non-square collision example (values indicate top-bottom)

Axis-aligned bounding box testing

Axis-aligned bounding box testing

XNA rectangle and methods Given two rectangles rectangleA and rectangleB Rectangle.Intersects(Rectangle) Returns true if the rectangles are intersecting, otherwise false Example call: rectangleA.Intersects(rectangleB); Rectangle.Intersect Method (Rectangle, Rectangle) Returns the area where the two rectangles overlap, an empty rectangle if there is no overlap Example call: Rectangle.Intersect(rectangleA,rectangleB);

Rectangle Intersect left-right

Rectangle Intersect top-bottom

Types of Collision loops

Exhaustive comparison Given mario, enemyList (length n), and blockList (length m), test mario vs. enemyList[0] through [n-1] mario vs. blockList[0] through [m-1] enemyList[0] vs. enemyList[1] through [n-1] enemyList[1] vs. enemyList[2] through [n-1] … blockList[0] vs. blockList[1] through [m-1] ?

Static vs. Dynamic Non-moving, or static, objects only need to be compared against dynamics, not other static objects foreach static object, test against all dynamic objects foreach dynamic object, test against all other dynamic objects, taking care not to duplicate tests

More resources A few pseudocode examples on gamedev stackexchange Also look into tutorials on XNA subpage