2D Physics and Camera Systems For CSE 3902 By: Matt Boggus.

Slides:



Advertisements
Similar presentations
Kinematics.
Advertisements

By: Nahdir Austin Honors Physics Period 2
Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
Visual Basic: ballistics
Chapter 3: Motion in 2 or 3 Dimensions
11.4 Tangent Vectors and Normal Vectors Find a unit tangent vector at a point on a space curve Find the tangential and normal components of acceleration.
Department of Physics and Applied Physics , F2010, Lecture 5 Physics I LECTURE 5 9/20/10.
L-4 constant acceleration and free fall (M-3)
Motion in Two and Three Dimensions
Computer Graphics Programming: Matrices and Transformations CSE 3451 Matt Boggus.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
College Physics, 6th Edition
Projectile Motion I 11/7/14. Throwing a ball in the air On the way up: At the top of the throw: On the way down: velocity decreases acceleration stays.
Free Body Diagram. Force Vectors  Force is a vector.  A block sliding on an inclined plane has forces acting on it.  We know there is a force of gravity.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
UNIT - 5 3D transformation and viewing. 3D Point  We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented.
Math – Getting Information from the Graph of a Function 1.
1D Kinematics. Distance Time (DT) Graph Slope of a DT graph gives speed D This is a graph of an object not moving. No slope = No speed T.
One Dimensional Motion
Acceleration: the rate of change of velocity with respect to time a avg = Δv/Δt = (v f –v i )/(t f -t i ) Notice how this form looks similar to that of.
PhysicsPhysicsPhysicsPhysics Unit 1 One-Dimensional Kinematics Reference Glencoe Chapter 2, Chapter 3.
Kalpaware, Inc presents.... SimNetwork Game overview Genre: Real Time Strategy Similar to SimCity Player is a network designer of a large telecommunications.
One Dimensional Motion. Distance How far something has moved.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Week 2 - Wednesday CS361.
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.
SECTION 1.3 PROPERTIES OF FUNCTIONS PROPERTIES OF FUNCTIONS.
Projectile motion.
12.3 Velocity and Acceleration. Projectile Motion.
Kinetic and Potential Energy Physics 6(B). Learning Objectives Explain the differences between kinetic and potential energy and their sources Describe.
Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
Control flow for interactive applications CSE 3541 Matt Boggus.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Kinematics in Two Dimensions AP Physics 1. Cartesian Coordinates When we describe motion, we commonly use the Cartesian plane in order to identify an.
CSE 380 – Computer Game Programming Player Controls & Scrolling Mega Man, by Capcom, released 1988.
Forces in Two Dimensions
Integration for physically based animation CSE 3541 Matt Boggus.
Quiz 1. An object is dropped from a height of 6.5 meters. How long does it take to reach the ground? 2. An object is moving at a constant velocity of.
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.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Accelerated Motion. is changing either the speed or direction, or both, of motion. Acceleration is the rate of change of velocity, in other words, how.
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
Physics 111 Projectile Motion 2.0.
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 22 Game Graphics.
1 Vector Decomposition y x 0 y x 0 y x 0. 2 Unit vector in 3D Cartesian coordinates.
Processing Images and Video for An Impressionist Effect Automatic production of “painterly” animations from video clips. Extending existing algorithms.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
CHAPTER Scalar & Vector Quantities Scalar Quantity = gives magnitude, quantity/how much of something you have. Examples: 30m/s, 50mph, 17N, $20,
Motion in Two and Three Dimensions Chapter 4. Position and Displacement A position vector locates a particle in space o Extends from a reference point.
Modeling One- Dimensional Motion W o r d s P i c t u r e s Graphs D a t a t a b l e s E q u a t i o n s.
Wednesday, February 15, 2017 Day 1
Game and animation control flow
Introduction to Game Physics
2D Physics and Camera Systems
Chapter 11 Motion.
Graphs of Motion KL PT/Physics 09.
Lesson 3: Physics 150 / 215 Projectile Motion
Wednesday, February 15, 2017 Day 1
Game and animation control flow
Updating an Animated Scene
Projectile motion Projectile Motion Subject to Gravity Assumptions:
Motion Maps.
Game Loop Update & Draw.
1.6 Acceleration Due to Gravity.
Rendering – Basic Concepts
Key Areas covered Terminal velocity.
2 types of scale factor problems
Window to Viewport Transformations
Presentation transcript:

2D Physics and Camera Systems For CSE 3902 By: Matt Boggus

Outline 2D game physics – Terms – Equations – Updating position and velocity Scrolling cameras – Graphics pipeline – Transforming between coordinate systems

2D GAME PHYSICS

Physics of motion terms Position – vector indicating the location of a point relative to the coordinate system origin Velocity – the rate of change of the position of an object Acceleration – the rate at which the velocity of an object changes with time

Physics of motion equations No acceleration Constant acceleration v ave v m f a a v’

Position update code Assuming controls modify the velocity of an object, its position Update is: position += velocity * dt, where dt is the amount of time passed since the last Update (set manually or via GameTime)

Friction and damping With no acceleration velocity will only change based on user input To slow objects down without acceleration, after updating position, velocity *= speedDecayRate, where 0 < speedDecayRate < 1

Clamping Keeping a value within a specified range – Prevent objects from moving off-screen – Prevent objects from moving too fast Minimum clamping – if (value < min) value = min; Maximum clamping – if (value > max) value = max;

Other physics issues User control for jumping height – Input tracking Sequence on keys/buttons Controller’s currentState and previousState – State driven JumpingState (velocity can continue to decrease) FallingState (velocity can only decrease) Stuck on ground – Ground plane (y > upperLimit triggers playerDeath) – Grounded state don’t apply gravity but can transition to falling/jumping

COORDINATE SYSTEMS, WINDOWING, AND CAMERAS

3D Computer graphics The graphics pipeline is a series of conversions of points into different coordinate systems or spaces

2D SpriteBatch based graphics Sprite data -> local space Move based on position in the level -> world space Move based on position with respect to camera -> screen space

Example (scaled) Super Mario Bros. Level 1-1 modified from

Example (not scaled)

Example (windowed) Camera’s top left corner is at (227, 57) in world space For the leftmost question block, Top left corner is at (256, 127) in world space When drawn using the camera, top left corner is at (29, 70) in screen space In general, Screen space or position to draw = ( worldSpacePosition.x – cameraPosition.x, worldSpacePosition.y – cameraPosition.y )

On camera functionality Data could include – position, height, width Methods could include – MoveLeft, MoveRight, MoveUp, etc. – IncreaseHeight, DecreaseWidth, etc. May want a CameraController to determine when/how to call these methods