2D Physics and Camera Systems

Slides:



Advertisements
Similar presentations
Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
Advertisements

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.
Projectile Motion. What Is It? Two dimensional motion resulting from a vertical acceleration due to gravity and a uniform horizontal velocity.
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)
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.
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.
2D Physics and Camera Systems For CSE 3902 By: Matt Boggus.
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.
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.
One Dimensional Motion. Distance How far something has moved.
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.
Project 6 Tumbling Cube Fri, Nov 21, 2003 Due Mon, Dec 8, 2003.
References: Wikipedia PHYSICS + VECTORS.  Why physics?  Good for every game developer to know.  Physics formulae are often vector-based  A good chance.
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.
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.
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.
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.
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.
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.
Game development.
Three Dimensional Viewing
Game and animation control flow
Motion in Two Dimensions
Introduction to Game Physics
Chapter 11 Motion.
Introduction & Rectilinear Kinematics:
(Constant acceleration)
Graphs of Motion KL PT/Physics 09.
VIDEO.
1.3 Graphs of Functions Pre-Calculus.
Kinematics in Two Dimensions; Vectors
Game and animation control flow
Motion in Two Dimensions
WINDOWING AND CLIPPING
Three Dimensional Viewing
Updating an Animated Scene
Physics 111: Mechanics Lecture 2
Galileo Galilei (2.6 Free Fall)
Tutorial on using Java Sprite Animation
WINDOWING AND CLIPPING
Digital Control Systems Waseem Gulsher
Reference Frames Galilean Transformations Quiz Outline.
Motion Maps.
1.6 Acceleration Due to Gravity.
Motion in Two Dimensions
Histograms Lecture 14 Sec Fri, Feb 8, 2008.
Rendering – Basic Concepts
Physics 111: Mechanics Lecture 2
Window to Viewport Transformations
The coordinate system Susan Ibach | Technical Evangelist
Projectile Motion and Relative Velocity
Chapter 7 The Game Loop and Animation
Presentation transcript:

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

Outline 2D game physics Scrolling cameras 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 f a m Constant acceleration a v’ v vave

position += velocity * dt, 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)

velocity *= speedDecayRate, 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 Minimum clamping 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 Stuck on ground 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 “Vibrating” objects Source rectangle origins aren’t consistent

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 http://ian-albert.com/games/super_mario_bros_maps/

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