L ECTURE 6 Announcements. Tou II Feedback handins look varied and fun! Write a Range or Interval class – makes math code easier to read write modify –

Slides:



Advertisements
Similar presentations
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Advertisements

Extreme Programming Alexander Kanavin Lappeenranta University of Technology.
Coding and Debugging. Requirements and Specification Recall the four steps of problem solving: Orient, Plan, Execute, Test Before you start the implementation.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
11-Jun-15 Exceptions. 2 Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a.
Game Inception and Design Project 1 Due dates: –Wednesday, January 18th: First-draft –Monday, January 23rd: Peer Review due –Thursday, January 26th: Final.
16-Jun-15 Exceptions. Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Exceptions. Errors and Exceptions An error is a bug in your program –dividing by zero –going outside the bounds of an array –trying to use a null reference.
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 Inception and Design Project 1 Due date: –Wednesday, May 24 th (in class)
DRY. 11: DRY—Don’t Repeat Yourself Every piece of knowledge should have a single, unambiguous, authoritative representation within a system Duplication.
A Technical Game Project 4 Due dates: Game Idea Friday, March 16 th Game Plan Friday, March 23 rd Web Page Sunday, April 9 th First Playable Wednesday,
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
Computer graphics & visualization Collision Detection – Narrow Phase.
CS 4730 Physical Simulation CS 4730 – Computer Game Design.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
Notes on the Game Development Process
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
CS 4730 Level Design CS 4730 – Computer Game Design Credit: Several slides from Walker White (Cornell)
Programmer Defined Functions Matthew Verleger. Windows It’s estimated that Window’s XP contains 45 million lines of code (and it’s over 10 years old).
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
Mark Nelson What are game engines? Fall 2013
Introduction to the WebBoard Terry Dennis. The WebBoard - Our Connection The WebBoard URL is
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
11 A First Game Program Session Session Overview  Begin the creation of an arcade game  Learn software design techniques that apply to any form.
L ECTURE 5 Announcements. Tou II Feedback handins look varied and fun! write a Range or Interval class – makes math code easier to write read modify –
Art 315 Lecture 5 Dr. J. Parker AB 606. Last time … We wrote our first program. We used a tool called GameMaker. The program we wrote causes a ball to.
Description, Classes, Interfaces, Hierarchy, Specifics George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
CS 4730 Action vs. Interaction CS 4730 – Computer Game Design Credit: Several slides from Walker White (Cornell)
Problem of the Day  Why are manhole covers round?
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Problem of the Day  Why are manhole covers round?
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.
Programming in Java CSCI-2220 Object Oriented Programming.
L ECTURE 6 Announcements. Next week will be great! Three major things are happening next week: – Zynga guest lecture – Your game pitches (more details.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.
Introduction to Particle Simulations Daniel Playne.
Chipmunk Physics Remember that we talked about this a bit when we did collision handlers for the space ship integration task (SpritesActionsPhysicsSound).
Debugging Computer Networks Sep. 26, 2007 Seunghwan Hong.
 A plan of attack for your games content  Or (more specifically)  A detailed description of all games mechanics, objects, characters, stats, ect… that.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
Static?. Static Not dynamic class Widget { static int s; int d; // dynamic // or instance // variable }
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Session 7 Introduction to Inheritance. Accumulator Example a simple calculator app classes needed: –AdderApp - contains main –AddingFrame - GUI –CloseableFrame.
ECE297 TA GUIDE Project supervision. Agenda M0 feedback Project overview M1 overview Project supervision.
11 Adding a Bread Bat Session Session Overview  We have created a cheese sprite that bounces around the display  We now need to create a bread.
INF3110 Group 2 EXAM 2013 SOLUTIONS AND HINTS. But first, an example of compile-time and run-time type checking Imagine we have the following code. What.
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.
Tou II Feedback Handins look varied and fun! Write a Range or Interval class – Makes math code easier to: read write modify – Makes M I easier to build.
CS 134 Design Documents.
Game Project IMGD 4000 Due Dates: Form Teams Treatment Website
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Lecture 3 Announcements.
© Paradigm Publishing, Inc.
Exceptions 10-Nov-18.
Overview of Eclipse Lectures
Lecture 2 Announcements.
Lecture 3 Announcements.
Lecture 5 Announcements.
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
GPAT – Chapter 7 Physics.
Presentation transcript:

L ECTURE 6 Announcements

Tou II Feedback handins look varied and fun! Write a Range or Interval class – makes math code easier to read write modify – makes M I easier to build on top of Tou

Note about README’s Detail in README’s means we have an easier time verifying requirements – Saves you from ing us about what we miss – Helps us grade (A LOT)

M: Your last project (kinda) Platformer game – 3 weeks – Physics – More physics – Externalizing game logic

QUESTIONS? Announcements

L ECTURE 6 Physics I

INTEGRATION Physics I

Velocity

Acceleration

Which order to update? Position first (Euler) pos = pos + vel*time vel = vel + acc*time Velocity first (“Symplectic Euler”) vel = vel + acc*time pos = pos + vel*time

Which order to update? Position first (Euler) pos = pos + vel*time vel = vel + acc*time Velocity first (“Symplectic Euler”) vel = vel + acc*time pos = pos + vel*time stabler than Euler; use this

COLLISION RESPONSE Physics I

Collision response You know how to detect whether 2 objects collide How do we make objects respond in a physically believable way? General strategy: 1.Move objects out of collision 2.Change their velocities

Moving out of collision Many ways to move the ball out of the wall We want the minimum “Minimum translation vector” (MTV) Same as overlap For now, assume we can find MTV

Changing velocity for collision

2-moving-object collisions Reverse both velocities? Doesn’t always work Apply equal and opposite forces An instantaneous force is called an impulse

Units Without mass With mass

Implementing force and impulse applyForce(…) accumulates force applyImpulse(…) accumulates impulse onTick(…) applies force and impulse, clearing them for next frame applyForce(…) and applyImpulse(…) only take effect on next onTick(…) “Static” (immovable) objects can override applyForce (…) and applyImpulse (…) and make them noops class PhysicsEntity { float mass; Vec2f pos, vel; Vec2f impulse, force; void applyForce(Vec2f f) { force += f; } void applyImpulse(Vec2f p) { impulse += p; } void onTick(float t) { vel += t*force/m + impulse/m; pos += t*vel; force = impulse = 0; } }

Impulse collision response Translate objects out of collision – Each by MTV/2 – Or proportional to velocity in direction of MTV Apply some impulse proportional to MTV to each object – How much? – This week: guess/hack – Next week: more realistic

Collision callbacks Pass in other Entity Separate Collision info object (really a struct) Pass in the MTV Maybe pass in which shapes collided – Enemies with weak points Maybe allow callback to prevent solid collision response – One-way platforms Double dispatch is your friend! class PhysicsEntity { boolean onCollide(Collision); } class Collision { final PhysicsEntity other; final Vec2f mtv; final Shape thisShape; final Shape otherShape; } void onCollide(PhysicsEntity); void onCollide(Collision);

Can we do better? abstract class PhysicsEntity > { boolean onCollide(Collision collision); } abstract class PhysicsWorld > { List void onTick(float seconds) { for (T entity1, entity2: physEntities) { // check if entity1 collides entity2, construct a collision object, // and pass that object to both entities } } } class Collision > { final T other; final Vec2f mtv; final Shape thisShape; final Shape otherShape; } // MEntity extends PhysicsEntity, and MWorld extends PhysicsWorld - done, with all callbacks generated in the engine!

MINIMUM TRANSLATION VECTOR Physics I

MTV in one dimension In 1D, convex shapes are line segments (intervals) These have a 1D MTV – Similar to overlap – But it has a sign Write a method that computes this Use it to find shapes’ MTV

Computing MTV 1.For each (normalized!) axis, find 1D MTV of shapes’ projections 2.Find the axis giving minimum 1D MTV 3.2D MTV is 1D MTV times that (normalized) axis

MTV interactive demo Same as last week Arrows are potential MTVs for box against triangle Purple arrows are the actual MTV SAT guarantees that MTV is on a separating axis

Computing intervals’ MTV Float intervalMTV(Interval a, Interval b) Float aRight = b.max - a.min Float aLeft = a.max - b.min if aLeft < 0 || aRight < 0 return null if aRight < aLeft return aRight else return -aLeft

Computing polygons’ MTV Vec shapeMTV(Shape a, Shape b) Float minMagnitude = +infinity Vec mtv = null for Vec axis in allAxes Float mtv1d = intervalMTV(a.proj(axis), b.proj(axis)) if mtv1d is null return null if abs(mtv1d) < minMagnitude minMagnitude = abs(mtv1d) mtv = axis.smult(mtv1d) return mtv

Computing circles’ MTV Circle vs Circle – Compare dist(center1, center2) and sum of radii – MTV is parallel to line connecting centers Circle vs Poly – Use the same set of axes you did last week: Poly’s edge normals Vector from circle center to closest vertex

Computing circles’ MTV (ctd) Circle vs Box – If Box contains circle center Use Box’s axes – Otherwise Clamp circle center to Box Compare dist(center, clampedPoint) and radius MTV is parallel to line connecting

Computing boxes’ MTV Easy but inefficient way: – Box converts itself to a Poly Efficient way: – Use (0, 1) and (1, 0) as the only 2 axes

MTV pitfalls Be careful with signs and argument order – Especially when reversing args for double dispatch Can use asserts: – MTV of shape A to move it out of shape B should point from B to A – assert dot(MTV, A.center – B.center) > 0

QUESTIONS? Physics I

L ECTURE 6 Tips for M I

Gravity On each tick, for each entity e, e.applyForce(g.smult(e.mass)) Static objects’ applyForce() does nothing – Consider how collision with a static object differs from collision with dynamic object

Player motion Set velocity while left or right is held? – Too sudden – Can interact badly with other physics Apply force while left or right is held? – Asteroids!

Goal velocity

QUESTIONS? Tips for M I

JAVA TIP OF THE WEEK Annotations

Pitfalls of inheritance Entity onTick(long) PhysicsEntity onTick(long) Player onTick(long) Enemy onTick(long) Bullet onTick(long) What if you Change name? Change arg types? Might forget to change a subclass (if not using Eclipse’s refactor tools) Subclass’ method no longer overrides anything! How can we avoid this? onTick(float)

annotation Whenever you override a method, mark If superclass changes, you get a compile error Eclipse can insert these for you public class Entity { public void onTick(float t) { //... } public class Bullet extends PhysicsEntity public void onTick(long t) { //... } Bullet.java:2: method does not override or implement a method from a supertype

Other standard annotations Annotations can mark: – classes – methods – fields – variables – parameters Can create your own… – See Oracle’s tutorial if you’re – Alternative to removing a method entirely – Compile warning when marked method is – Tells the compiler not to catch you when you fall – Avoid if at all possible – Typically an indication of a larger problem

QUESTIONS? Annotations

L ECTURE 6 Final Project Overview

Overview Can be any 2D game You should work in groups! Each person is responsible for 10 “points” worth of new engine features – More members in a group means more engine features – More details in the final project handout

Timeline 4 main parts: – Week 1: Idea – Week 2: Form groups and get approved – Week 3: Design – Weeks 4-8: Code, playtest, polish, present

Week 1: Idea A ½ to 1 page document Describe basic gameplay idea – How is your game fun? – Why should someone want to help make it? Describe engine feature(s) you plan on implementing Give a 60-second “elevator pitch” of your game in class Everyone must give a pitch, even if you already know your group and which project you’re working on

Week 2: Groups Form a group (or decide to work alone) Finalize game and engine features Each group must meet with a TA to present the following: – A more polished idea of the game – Breakdown of member responsibilities for engine

Week 3: Design Research new engine features Design the engine and game Exact breakdown of member responsibilities Choose someone’s engine to use or integrate engines For groups of 3 or more – Explain how you will use version control

Weeks 4-8 Week 4: – Engine should be mostly done – Game exists Week 5: – Engine should be done – Game is playable – 5 playtests per member from people not in CS195n

Weeks 4-8 Week 6: – Game should be mostly done – 5 more playtests per member from outsiders Week 7: – Game should be done – 5 playtests per member – Powerpoint slideshow for postmortem presentation

Weeks 4-8 Week 8: – Polish up your game, bug fixes, etc – Create an executable and put it in /contrib – Make a video demo of your game from gameplay footage It is now December 19 th And then you’re done!

QUESTIONS? Final Project Overview

G AME D ESIGN 3 CS195n – 2012, 2013

Brief Summary Focuses on past video games developed by students in: – CS32 – CS195n What went right? What went wrong? Discuss final project ideas

Sunlab Games Fun for the first five minutes… …Then you remember you have other work to do

Common Themes Overstretching – More than what can be created in a 4 week time period No polish – Focused too much on content development NOTE: These are post-mortem summaries; your post-mortems should be more in-depth

Reject Wars Network platform shooter Java sockets and Threads Similar to Super Smash Bros.

Reject Wars – What went right? Networking – Understood Java Sockets and Threads a lot better Basic gameplay – done! Character sprites – Zach Davis! Lump Space Princess! Magikarp!

Reject Wars –What went wrong? Networking – Serialized the game world… – Scaling issues Environmental sprites Staged-based strategy

Prismatic 2D top down puzzle game (Castle Crashers theme) Based upon interacting with light rays 20+ different entities to interact with (enemies, objects, etc…)

Prismatic– What went right? 4-man team – excellent division of labor – Level editor, gameplay, UI, file system Good expectations Users have own profiles, can upload levels for each other to play

Prismatic–What went wrong? Lack of playtesting Some, but not much, polish Not much else…

Student Demos! Izaak! Galaxy Ferret (Jake) Havoc Under Blade (Dan) Monochrome (Luke/Max)

Avoiding problems… Organize; know your abilities Be reliable to your teammates Settle on a coding convention – Follow it! Take initiative – There’s always that one guy who says: “Doesn’t matter to me, I’ll do anything” FIX BUGS!!! – Don’t put it off till later!

Making it better… Find creative ways to extend gameplay time – Reuse level, change lighting and enemies – If you must, grinding works (only for final projects) Make a main menu – Often first thing the player sees – You want to make a good impression!

What we don’t see… Simulation (Rollar Coaster Tycoon, Civilization series) Visual novels (Clannad) Rhythm (Dance Dance Revolution) Racing (Mario Kart) Fighting (Street Fighter) Horror (Clocktower) Games with networking Games with advanced 2D graphics – Per-pixel lighting, lightmaps, shadows, raytracing

What we get A LOT of Platformers RPGs Platformers

Single-player games Advantages – Easier to balance Disadvantages – You have to keep the player going – Think of all the design challenges involved in four weeks

Multiplayer games Advantages – It’s fun to beat other people – Increased bang for your buck, content-wise Disadvantages – Networking can be tricky to debug

T OU 2 PLAYTESTING ! Hooray!