Tou has been released!

Similar documents
the gamedesigninitiative at cornell university Lecture 18 Box2D Physics

Physic 602 Conservation of Momentum. (Read objectives on screen.)

Course Announcements. John Jannotti (cs32) Scope, Collections & Generics Feb 8, / 1

Problem Decomposition: One Professor s Approach to Coding

CS 387/680: GAME AI MOVEMENT

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;

ITI Introduction to Computing II

ITI Introduction to Computing II

Intermediate Logic. Natural Deduction for TFL

AP Physics Ch 6 Day 4

CS 387/680: GAME AI MOVEMENT

CS Exam 1 Study Guide and Practice Exam

Please bring the task to your first physics lesson and hand it to the teacher.

( ) and D( x) have been written out in

Reading. w Foley, Section 11.2 Optional

CS 480: GAME AI MOVEMENT. 4/10/2012 Santiago Ontañón

Foundations for Functions

PHYSICS 15a, Fall 2006 SPEED OF SOUND LAB Due: Tuesday, November 14

A N D. c h a p t e r 1 2 M O T I O N F O R C E S

AP Physics 1 Summer Assignment

Uncertainty. Michael Peters December 27, 2013

ASSIGNMENT 2 TIPS AND TRICKS

Aspect-Oriented Refactoring of a Two-Dimensional Single Player Fixed Shooter Game Application Using AspectJ

How many states. Record high temperature

Chapter 1: January 26 January 30

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010

IM3 Unit 1 TEST - Working with Linear Relations SEP 2015

Maps performance tips On server: Maintain DB connections, prepared statements (per thread/request!)

Epsilon-Delta Window Challenge TEACHER NOTES MATH NSPIRED

PHY 111L Activity 2 Introduction to Kinematics

Object Oriented Programming for Python

Conservation of Momentum

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016

Lesson 4 Linear Functions and Applications

Particle Systems. CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2017

MITOCW MIT18_02SCF10Rec_50_300k

Study Resources For Algebra I. Unit 2A Graphs of Quadratic Functions

CSE370 HW6 Solutions (Winter 2010)

3.2 Quadratic Equations by Graphing

Getting Started with Communications Engineering

1 Closest Pair of Points on the Plane

Motivation: Sparse matrices and numerical PDE's

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, Name:

Newton s Third Law and Conservation of Momentum 1 Fall 2017

Object Oriented Software Design (NTU, Class Even, Spring 2009) Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20

Edexcel AS and A Level Mathematics Year 1/AS - Pure Mathematics

DNHI Homework 2 Solutions Recursion

Lecture 14 - Capacitors

CSC236 Week 3. Larry Zhang

Data Structures and Algorithms Winter Semester

Experiment 1: The Same or Not The Same?

Projectile Motion. v a = -9.8 m/s 2. Good practice problems in book: 3.23, 3.25, 3.27, 3.29, 3.31, 3.33, 3.43, 3.47, 3.51, 3.53, 3.

TI-nspire CX Looks like a calc, works like a computer

Elementary Sorts 1 / 18

6.001 Recitation 22: Streams

Lecture 27: Theory of Computation. Marvin Zhang 08/08/2016

The Snowball sprite contains 2 costumes, a normal costume, and one that shows which direction the snowball is facing.

All the examples in this worksheet and all the answers to questions are available as answer sheets or videos.

INF Models of concurrency

UI Implementation. John Jannotti. Mar 21, /course/cs0320/www/docs/lectures/ John Jannotti (cs32) UI Implementation Mar 21, / 26

SCED 204 Sample Activity SCED 204: Matter and Energy in Chemical Systems

STARTING WITH CONFIDENCE

Sequential Logic (3.1 and is a long difficult section you really should read!)

Epsilon-Delta Window Challenge Name Student Activity

ASYMPTOTIC COMPLEXITY SEARCHING/SORTING

2.1 Identifying Patterns

MITOCW MITRES_18-007_Part3_lec5_300k.mp4

Gravity Well Demo - 1 of 9. Gravity Well Demo

Regressions of Olympic Proportions

Solution suggestions for examination of Logic, Algorithms and Data Structures,

CH 66 COMPLETE FACTORING

Data Structures & Database Queries in GIS

Recitation 4: Eventful Tactical KeYmaera X Proofs /15-624/ Logical Foundations of Cyber-Physical Systems

Preptests 59 Answers and Explanations (By Ivy Global) Section 1 Analytical Reasoning

Latches. October 13, 2003 Latches 1

Exercise 1 (15 points)

Lab 8 Impulse and Momentum

MITOCW Investigation 3, Part 1

Solving Linear Systems of ODEs with Matlab

MURA Office hours Thurs at 12-1pm in CIT 546 Contact for more info.

Hoare Logic: Reasoning About Imperative Programs

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018

Chapter 1 Review of Equations and Inequalities

Introduction to Algebra: The First Week

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

Unit 2 Linear Equations and Inequalities

Introduction to Programming (Java) 3/12

Moving away from Happy Physics World

How to Make or Plot a Graph or Chart in Excel

This is the third of 3 parts detailing my experience of auto guiding for astrophotography.

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany

Lab 5 for Math 17: Sampling Distributions and Applications

MATH 135 Fall 2006 Proofs, Part IV

Basics of Proofs. 1 The Basics. 2 Proof Strategies. 2.1 Understand What s Going On

Bayesian Classifiers and Probability Estimation. Vassilis Athitsos CSE 4308/5360: Artificial Intelligence I University of Texas at Arlington

Equalities and Uninterpreted Functions. Chapter 3. Decision Procedures. An Algorithmic Point of View. Revision 1.0

Matter & Interactions I Fall 2016

Unit 10 Parametric and Polar Equations - Classwork

CS 480/680: GAME ENGINE PROGRAMMING

Projectiles: Target Practice Teacher Version

Transcription:

Tou has been released! Shoot- em-up, heavy use of collision detection Much more open-ended than previous projects Easier than previous projects if you work smart Should help those of you combating the snowball of death

Behind on Tac? Don t worry! You re not alone. Incomplete on Tac2? Use an extra retry this week! Incomplete on Tac3? Do Tou1 first, then try to catch up. If you don t catch up, it s ok! You can still get an A!

Engine Requirements If a requirement is listed as an engine requirement, then the implementation should be in the engine Otherwise you will get an incomplete There is more flexibility about game requirements

Announcements QUESTIONS?

Game Worlds MOTIVATION

Viewport How you probably did Tac

How does this scale? Imagine implementing four-player split-screen: Viewports Normal UI element

Solution: separate world+screen Viewport World

Game Worlds RESPONSIBILITIES

What does a world do? Represents all game objects ( entities ) in a single space Owns game coord system Centralizes entity management Maintains list, add/remove via queues or iterating over copy Passes through ticks and draws to entities Handles global logic Anything beyond the scope of a single entity E.g. providing collision detection callbacks to entities Entities World World logic

Single logical object within the game Stores all state relevant to itself, e.g. draw shape, collision shape, HP, attack cooldown Should always know what World it s in Lightweight superclass High-level subclasses in engine, low-level in game Receives events from World More than just tick+draw! Entities Background Boss Enemy Entity Physics Entity Damagable Player Bullet

Entity vs Shapes Shapes are not Entities Entities are not Shapes No inheritance between them Entities should contain Shape(s) Entity Shape

Entity responsibilities May draw, may not Spawners, timers, force fields May use ticks, may not Static environment objects, background Most will probably do both though Player, items/pickups, Player input? Might be better handled by World, your call Effects on other entities? Might be better handled by World, your call

Ticking and drawing entities in the wrong order leads to undesirable behavior Drawing background over everything else Entities removing themselves during collision detection World can selectively update state in order E.g. tick all entities so they update position, *then* check for collisions Could have a way for specifying draw order Multi-pass logic

Game Worlds QUESTIONS?

Collision Detection I MOTIVATION

Collisions have consequences Object collisions are extremely important in everyday life Extremely important in games too Games that use collision detection vastly outnumber those that don t

What do we want to collide? Points Circles Axis-Aligned Boxes Convex polygons Covered next week Compound shapes Other shapes Not covered P P 3 P 2 P 1 C r P 4 P 5 y min dim = (w,h) w h max x

Collision Detection I DETECTION ALGORITHMS

Point-Circle Check if the distance between the point and the center is less than or equal to the radius P C 2 r 2 P d C r P C d r

Circle-Circle Check if the distance between the two centers is less than or equal to the sum of the radii C 2 C 1 2 r 1 + r 2 2 C 1 r 1 d C 2 r 2 C 1 r 1 C 2 r 2 d

Point-AAB Check if point is within range on each axis min x P x max x AND min y P y max y min x min x P P max max y y

AAB-AAB Ensure overlap on each axis: A xmin B xmax AND A xmax B xmin A ymin B ymax AND A ymax B ymin

Circle-AAB Check if closest point to circle on AAB is in circle Closest point: clamp C.x, C.y to [min.x, max.x], [min.y, max.y] Then just do point-circle collision min P=C d=0 r min P C d r min C d P r max max max

Compound-anything Compound shape checks against sub-shapes Only compound shapes should ever need to iterate over children

Collision Detection I QUESTIONS?

Write a collision debugger Collision math is tricky You will make mistakes Test your collision code before even putting it in a game This is required

Watch out for key ghosting Due to the way keyboards are built, sometimes keys don t work while others are being held down In many cases, as few as 3 can be held at a time Hardware issue (can t fix it), you must design around it E.g. use mouse for some actions More info, interactive demo: http://www.microsoft.com/applie dsciences/antighostingexplained.m spx

Double dispatch If you have a Circle and an AAB but only know that they re Shapes, how do you determine which method to call? void testcollide() { Shape s = new Circle(); Shape s2 = new AAB(); s.collides(s2); } abstract class Shape { collides(circle c); collides(aab aab); collides(comp m); collides(shape o); } boolean collides(shape o) { if (o instanceof Circle) { return collides((circle) o); } else if (o instanceof AAB) { return collides((aab) o); } else if (o instanceof Comp) { return collides((comp) o); } else { throw new IllegalArgumentException(); } }

Double dispatch interface Shape { collides(shape o); collidescircle(circle c); collidesaab(aab aab); collidescomp(comp m); } public class Circle implements Shape { collides(shape o) { return o.collidescircle(this); } collidescircle(circle c) { /*code*/ } collidesaab(aab aab) { /*code*/ } collidescomp(comp m) { /*code*/ } } public class AAB implements Shape { collides(shape o) { return o.collidesaab(this); } collidescircle(circle c) { /*code*/ } collidesaab(aab aab) { /*code*/ } collidescomp(comp m) { /*code*/ } } public class Comp implements Shape { collides(shape o) { return o.collidescomp(this); } collidescircle(circle c) { /*code*/ } collidesaab(aab aab) { /*code*/ } collidescomp(comp m) { /*code*/ } }

Tips for Tou I JAVA TIP OF THE WEEK

Variable arguments! Wouldn t it be nice if instead of this: List<Shape> l = new ArrayList<Shape>(); l.add(new Circle()); l.add(new AAB()); l.add(new AAB()); Compound c = new Compound(l); Or this: Compound c = new Compound(new Shape[] {new Circle(), new AAB(), new AAB()}); You could do this? Compound c = new Compound(new Circle(), new AAB(), new AAB());

Well you can! The type of the last argument of a constructor/method may end in to indicate any number of arguments public Compound(Color c, Shape... shapes) The variable argument will actually be an array of arguments (it s really just wrapping array creation): public Compound(Color c, Shape... shapes) { for (int i=0; i < shapes.length; ++i) { add(shapes[i]); } }

Passing arrays as varargs Since it s really just an array, it s possible to just pass in an array if you already have one: static void printallonaline(object... objs) { for (Object o : objs) System.out.print( ( +o+ ) ); System.out.println(); } public static void main(string[] args) { printallonaline(args); List<?> ents = new World().getEntities(); printallonaline(list.toarray()); }

Tips for Tou I QUESTIONS?

Juice it or lose it (Video) https://www.youtube.com/watch?v=fy0acdmgnxg Demo Available at: http://grapefrukt.com/f/games/juicy-breakout/

You should only add juice to your game in one situation: when your engine and game requirements are completed! Exception: particles for the final project A warning

Juice in 195n Basic juice: Color Mouse hover effects Sprites Sound* Advanced juice: Tweening Screen shake Screen freeze Particles* (Less programming effort) (More programming effort) *options for your final project

Feedback Loops The player wants to know When damage is done If things collide (especially projectiles) If an action triggered or failed Good place to use Juice

Juice QUESTIONS?

Game Design 3 GAME DESIGN TIPS FOR TOU

General gameplay Two standard schemes for shoot em ups: Player can only shoot in one direction and enemies approach from that direction Player can aim freely and move freely

Major design decisions How will the player aim at enemies? With the mouse? By lining up with enemies? How freely can the player move? One or two axes of movement? How does the player s weapon work? One bullet at a time? A spread? Upgrades? What will the collision shape of my player be? What is fair?

Suggestions Allow the player to hold the fire button to continue firing Use the mouse to fire to avoid keyboard ghosting