Lecture 1 Announcements.

Slides:



Advertisements
Similar presentations
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Advertisements

CS 4730 Game Design Patterns CS 4730 – Computer Game Design Credit: Some slide material courtesy Walker White (Cornell)
L ECTURE 1 Announcements. Tic is over! Collaboration policies!
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
A Prezi presentation is like creating a mind map. It is created on a blank canvas and you decide where the information goes on this canvas.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT.
Developing the Game User Interface (UI) Lesson 5.
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.
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.
Learning Unity. Getting Unity
Game Maker Terminology
Session 16 Pinball Game Construction Kit:. Pinball Version 1 Replaced the fire button with a mouse event. Multiple balls can be in the air at once. –Uses.
Game Maker – Getting Started What is Game Maker?.
Games Development 2 Overview & Entity IDs and Communication CO3301 Week 1.
2.3. A RCHITECTURAL D ESIGN I Example approach for game screen management.
Session 13 Pinball Game Construction Kit (Version 3):
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
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.
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.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
CS 106A, Lecture 27 Final Exam Review 1
EEC-693/793 Applied Computer Vision with Depth Cameras
Computer Fundamentals 1
Review Array Array Elements Accessing array elements
Where are we ? Setup Sprites Input Collision Drawing Sprites
Concepts of Object Oriented Programming
Scratch for Interactivity
Exploring Mathematical Relationships Module 5: Investigation 3
Building with Numbers Module 4: Investigation 3
D.Y.O. Web The new and easy way to create and maintain your own professional dynamic website.
EEC-693/793 Applied Computer Vision with Depth Cameras
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Frame Update, Level Representation & Graphics
Creating Vector Graphics
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Chapter 5 Conclusion CIS 61.
Presenting Prezi Michael Pelitera
Week 4 Object-Oriented Programming (1): Inheritance
Stacks Chapter 4.
Intro to PHP & Variables
Stack Data Structure, Reverse Polish Notation, Homework 7
EEC-693/793 Applied Computer Vision with Depth Cameras
MS PowerPoint 2010 Week 2.
Cookies BIS1523 – Lecture 23.
© Paradigm Publishing, Inc.
Learning Objective LO: We’re learning to understand when it is appropriate to use particular data types.
Optimizing Malloc and Free
Microsoft® Office Word 2007 Training
Unreal Engine and C++ We’re finally at a point where we can start working in C++ with Unreal Engine To get everything set up for this properly, we’re going.
Board: Objects, Arrays and Pedagogy
Presentations are a powerful communication medium.
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Game Loop Update & Draw.
2.3. Architectural Design I
Working with Symbols and Interactivity
Introduction to PowerPoint
Stacks.
Week 6: Time and triggers!
HP ALM Test Lab Module To protect the confidential and proprietary information included in this material, it may not be disclosed or provided to any third.
Lecture 9 Announcements.
Tank Game Int 10 Unit 3 – Game Maker.
EEC-693/793 Applied Computer Vision with Depth Cameras
The Iterative Design Recipe
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Presentation transcript:

Lecture 1 Announcements

Tic is over!

Tic Feedback Don’t fall behind! you tic

Tic Feedback Don’t fall behind! you the rest of the course us too

Escape Key Should not be defined engine-side Engine doesn’t know what the game wants to do on escape (deselect, save before exiting, etc.)

Handing In Please include project files ~/course cs1971 tic <login> src bin Hand these in!

Course Scripts They work now! Use /course/cs1971/bin/cs1971_demo <project> You should be added to the cs-1971student group this week

Hours Change Hours on Saturday 6-8 moved to Sunday 2-4 Design check hours shuffled around

This Week: Tac 4 week project 2D dungeon crawler First checkpoint due next week

Lecture 1 Game World

Game World Motivation

Games are busy… All games involve a number of game objects May be many different types of objects May be many instances of the same type of object Maybe both of the above They exist in their own universe If our entire universe is a game, you’re just an object We need to take the burden of representing and organizing these objects off the game code

High Level Representation The GameObjects The GameWorld Small collections of functionality Hold their own logic and state Don’t know much about the rest of the game The overarching collection of GameObjects Responsible for global logic and facilitating entity logic Represents the boundary between program and game

Tac Without a Game World Tile[][] Viewport Unit Unit Projectiles GameScreen Application Unit AIUnit FrontEnd

Tac With a Game World World Viewport Tile[][] Unit Bullet GameScreen AIUnit GameScreen Application World FrontEnd

Game World Responsibilities

What does a world do? Represents all GameObjects in a single space Centralizes object management Maintains list of GameObjects Passes ticks and draws to gameObjects World GameObjects Unit Enemy Unit Bullet Background Boss Player World logic

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

EventHandling Passing events can get cumbersome Combined mouse-key events can get complicated Solution- store input state in GameWorld Array of 256 booleans/enums instead of key events Keep track of mouse position/state

General Contract public void tick(long nanosSinceLastTic); public void draw(GraphicsContext2D g); public void onDDDEEE(DDDEvent e);

Game Worlds Questions?

Lecture 1 Engine Framework

Engine Framework Game objects

What is a game object? Everything your GameWorld holds Your background Your walls Your character Your enemies

They aren’t everything Your screens aren’t Your UI probably isn’t Map generation isn’t

Hierarchical design Consider a simple game with: Player Enemies Destructible terrain Invincible enemies GameObject Player Can move Has health bar

Hierarchical design Start with player and enemies They both move and have health bars Abstract out common code! GameObject Can move Has health bar Player Key controls Enemy AI

Hierarchical design Let’s add in destructible terrain It has a health bar but doesn’t move, time to abstract out some more GameObject Has health bar Units Can move Terrain Pretty sprite Player Key controls Enemy AI

Hierarchical design Now we reach a problem Where do our invincible enemies fit in? They move but don’t have health bars GameObject Has health bar Units Can move Terrain Pretty sprite Player Key controls Enemy AI

Hierarchical design Can make a separate class and re-implement moving Can add below enemies and hide the health bar Both not ideal Only get worse as the game gets bigger GameObject Has health bar Units Can move Terrain Pretty sprite Player Key controls Enemy AI

Solution Component-based design Everything is a game object… and only a game object Leave game objects dumb Let their *components* do all the heavy lifting GameObject ?

Solution GameObjects are just lists of behaviors The behaviors implement all relevant functionality Composition over inheritance GameObject List of behaviors HealthBehavior Health bar MoveBehavior Updates position KeyControlBehavior Responds to key presses DrawBehavior Has a Sprite Can create game objects with any combination of these behaviors. Can do what we couldn’t do before AIBehavior Makes decisions

Component-based design The appearance and logic of each object is defined by its components Making new objects is as easy as adding new components

General Contract An object needs to do the following: Add a component Remove a component Access a component Pass a message to each component

General Contract private ArrayList<Behavior> _behaviors; public void addBehavior(Behavior b); public void removeBehavior(Behavior b); public Behavior getBehavior(String tag);

Expanded Contract An object should also do the following: Tick each tickable component Draw each drawable component

Expanded Contract public void tick(long b); public void draw(GraphicsContext2D b);

Behavior Contract Needs to respond to ticks and draw events (can be empty) public void tick(long nanosSinceLastTick); public void draw(GraphicsContext2D g);

Engine Framework Systems

Systems Organize shared behavior E.g., not all GameObjects will be drawn GraphicsSystem should only hold GameObjects that have drawable behaviors Each System stores a list of interested GameObjects and calls the relevant method on each of them E.g. TimerSystem calls tick(long b) on GameObjects

Systems Your choice of when to register GameObjects with Systems On instantiation On addition to the GameWorld Your choice of how to register GameObjects with Systems Manually, e.g. soundSystem.addObject(obj); Automatically, e.g. have system ask each GameObject if it’s interested

Enforcing Draw Order Use a TreeSet Alternatively, set drawing layers log time lookup/insertion/removal Predictable order (can set priority for drawing) Adding the same GameObject twice won’t leave a duplicate Requires custom comparator Alternatively, set drawing layers

Game Worlds Questions?

Lecture 1 Viewports

Viewports Motivation

Sometimes screen space is hard Theoretically everything can be done in screen space E.g. specifying size of objects in pixels, position in pixel offset But some things can be very hard E.g. panning Imagine four-player split screen Games shouldn’t have to worry about how the screen draws them

Game space vs. Screen space In nearly all games, it makes sense to think of the game as existing in its own “space” Add a UI element that has “view” into the GameWorld This is a viewport 0,0 1,0 2,0 0,1 1,1 2,1 0,2 1,2 2,2 Game-space Screen UI 0,0 1,0 2,0 0,1 1,1 2,1 0,2 1,2 2,2

Space Conversions Needs: Game point to screen: Screen point to game: Upper left corner in screen space Upper left corner in game space Scale/zoom/pixels per game coordinate Game point to screen: Minus upper left in game space Multiply by scale Add viewport upper left Screen point to game: Do the OPPOSITE of the steps IN REVERSE Conversion is called a transform 0.5, 0.8 Scale: 100 px/unit 1.5, 2.0 0,0 1,0 2,0 2,1 0,2 1,2 2,2 120, 20 1.5, 2.0 1.0, 1.2 100, 120 220, 140 220, 140 Viewport should know how to convert objects in world space to objects in screen space. Accomplish this by converting world space positions to screen space positions.

Viewports Implementation

Implementing viewports Set the clip (g.clipRect() ) You will draw outside the bounds of the viewport otherwise Set the transform Draw the game-space in its own coordinates Restore the transform Restore the clip (g.setClip(null) )

The Transform This could be implemented as follows: Don’t do this Create a wrapper for Graphics2D with a method like setViewport() When drawing a viewport, toggle a flag inside your Graphics2D wrapper that you need to transform game to screen coordinates whenever a shape is drawn Do separate game object transforms in each object’s own onDraw() call Unmark your wrapper when finished drawing the viewport Don’t do this Summary Before we draw each shape, convert it’s vertices from world space to screen space But we already have a way to do this…

Affine Transforms Java’s AffineTransform keeps track of geometric transformations for drawing Uses concepts from linear algebra Haven’t taken it? No problem! Can create an AffineTransform that converts from world space to screen space Check out translate(), scale(), and others How to use the AffineTransform once we have it A Graphics2D instance maintains an internal transform The transform is applied to objects before they are drawn Use setTransform() and getTransform() to modify the current AffineTransform Similar to other 2D and 3D graphics pipelines In this case, we can create an AffineTransform object that converts world space positions to screen space “Maintains an internal transform” which it applies to objects before they are drawn

Viewports Questions?

Warnings! Viewports are essential to the rest of the class – every assignment from here on will depend on using your viewport! Hard to test your game if you can’t display it correctly Design well Test thoroughly Don’t put off bugs until later weeks The TA staff requires the use of AffineTransform If you do not feel comfortable with using AffineTransforms, come to hours!

Lecture 1 Tips for Tac I

Viewports Zooming is multiplicative, not additive Rolling mouse wheel should * or / the scale factor Some zoom levels don’t make sense Optional: set zoom in/out limits! Most maps don’t go on forever Optional: set pan limits!

Tips for Tac I Java Tip Of The Week

Generics are cool! You’ve used generics before… but have you ever written them? It’s as easy as: public class SimpleContainer<T> { private T object; public void setObject(T ob) { object = ob; } public T getObject() { return object; } }

Generics are cool! Can use extends to bound the type public class AnimalHouse<A extends Animal> { private A animal; public void houseAnimal(A a) { animal = a; } public void feedAnimal() { animal.eat(); } } AnimalHouse<Dog> kennel; // okay AnimalHouse<Rock> mountain; // compile error

Want to know more? Effective Java by Jeff Hao has an excellent chapter on generics Gives examples of where advanced generics are useful Can be found in the back of the SunLab

Tips for Tac I Questions?

Game Design 1 Introduction

Video game creation is an art, a science, and a feat of engineering Video game creation is an art, a science, and a feat of engineering. -Jeffries van Dam

Supplement to 2D Games More “high-level” concepts, less technical Visualize game creation from a more artistic perspective Inspire ideas and concepts for the final project Perhaps influence coding style and engine design

Help create better Final Projects Ultimate Goal Help create better Final Projects

This Week The Juice Video www.youtube.com/watch?v=Fy0aCDmgnxg

Game Design: Genres Questions?

Tic Playtesting Yay!