Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, 2015. Chapter 6 Examples 1,

Slides:



Advertisements
Similar presentations
Our Friend the Dot Product
Advertisements

Introduction Games have always been a fundamental part of human life. Space storm “ عاصفة الفضاء” is a 3D SCI-FI game that consists of two stages presented.
CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Computational Geometry & Collision detection
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
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 Mathematics & Game State The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object Overlap.
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 12 Chapter 12: Making the Applications Interesting.
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 7 Chapter 7: Graphical Primitives.
AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
Week 1 - Friday.  What did we talk about last time?  C#  SharpDX.
Antigone Engine Kevin Kassing – Period
Mouse-Based Viewing & Navigation Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 3, 2003.
A Spring 2005 CS 426 Senior Project By Group 15 John Studebaker, Justin Gerthoffer, David Colborne CSE Dept., University of Nevada, Reno Advisors (CSE.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
Description, Classes, Interfaces, Hierarchy, Specifics George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
(Interactive) Cinematography Ref: Chap. 16 (Core Techniques and Algorithms in Game Programming)
User Input and Collisions COSC 315 Fall 2014 Bridget M. Blodgett.
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.
Web Games Programming An Introduction to Unity 3D.
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
Cohesion and Coupling CS 4311
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Neo-Breakout Sonhui Schweitzer CS 470 Spring 2005.
Guide to Programming with Python Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Guide to Programming with Python Week 15 Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
Chipmunk Physics Remember that we talked about this a bit when we did collision handlers for the space ship integration task (SpritesActionsPhysicsSound).
Sky Boxes and Vector Math 2 Course Information CVG: Programming 4 My Name: Mark Walsh Website:
Collision Detection And Response Jae Chun KyungSoo Im Chau Vo Hoang Vu.
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
1 Sage Demo 4 Collisions SAGE Lecture Notes Ian Parberry University of North Texas.
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
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.
UFCFSU-30-13D Technologies for the Web An Introduction to Unity 3D.
Introduction to Game Programming & Design III Lecture III.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 7 Manipulating.
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.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 1.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 4 Implementing.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 7 Examples 3.
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 3.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 8 Illumination.
Chapter 1 Introduction.
Implementing Common Components of Video Games
Textures, Sprites, and Fonts
3D Game Development and Computer Animation Collision Detection
EEC-693/793 Applied Computer Vision with Depth Cameras
Chapter 8 Illumination.
The Basics: HTML5, Drawing, and Source Code Organization
Chapter 3 Drawing In the World.
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
CS451Real-time Rendering Pipeline
© University of Wisconsin, CS559 Fall 2004
Defining Behaviors and Detecting Collisions
.NET and .NET Core 7. XAML Pan Wuming 2017.
CIS 488/588 Bruce R. Maxim UM-Dearborn
Lecture 2 Announcements.
UMBC Graphics for Games
Introduction to Computer Graphics with WebGL
Unity Game Development
Resources and interactions
Chapter 1 Introduction.
Presentation transcript:

Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 6 Examples 1, 2, and 3 Defining Behaviors and Detecting Collisions

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, This Chapter Start thinking about behavior Implement autonomous, controlled, gradual turning and target-locked chasing behaviors Needs for collision detection Simple: Axis-Aligned BBOX Collide textured objects accurately Per-Pixel-accurate collision Understand algorithm and efficiency Derive and implement general solution

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Review: Where are we? Chapter 2+3: Hides Drawing GLSL Shader, SimpleShader, Renderable Chapter 4: Utility components Loop, Keyboard input Scene object: API interface Resources management, Audio Chapter 5: Drawing of “objects” as textures and animation TextutreShader and TextureRenderable Sprite animation Font Need: Abstract behavior wrapping

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : GameObjects Project

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Goals Define the GameObject: To begin abstract/hide behavior implementation Clean up drawing interface: should pass in Camera

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, New sprite element

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Draw: with a Camera (instead of vpMatrix)

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, GameObject: capturing behaviors! update() Implements object behaviors Has a renderable Can be drawn Has a xform Can be maniuplated

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, GameObjectSet: Set of GameObjects Set maintenance Add/Size/Access GameObjects support update/draw

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Work with GameObject Custom object: DyePack

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, The Hero The Definition Behavior! Hidden from MyGame Avoid code clustering in MyGame

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Minion

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Minion’s interesting behavior MyGame: no need to have any knowledge of how minion’s behave!

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame::initialization()

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame draw() draw() Init camera Pass camera to GameObjects

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame update() Core of game logic: Each object updates state No object interact: So, that’s that! Notice: MyGame does not know anything about each object Control/Behavior: all hidden inside each object MyGame: will take care of interaction of objects (to come)! For objects to interact: need to be aware of other objects!

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Vectors: Review From point to point Has a size Magnitude, length, distance

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Vectors: direction and size

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Vector: rotation

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Vectors: normalization

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Vectors: normalization

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Vector: dot product

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Vector: cross product

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Front and Chase Project

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Goals work with velocity: as speed and direction practice traveling along a predefined direction implement chasing or home-in behavior

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, GameObject: initial state Initial front direction

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, GameObject::rotateObjPointTo(p) this.getXform().getPosition() len (length of dir) Position: p dir: towards p

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, GameObject::rotateObjPointTo(p) this.getXform().getPosition() len (length of dir) Position: p dir: towards p fdir: front of object

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, GameObject::rotateObjPointTo(p) cont … this.getXform(): set rotation

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame: set/get Update speed Set Front Dir: maintain normalized vector!

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, GameObject: update and draw

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Testing rotate towards object: the Brain

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Brian: private behavior Drive the brain Change speed Direction and Speed are independent

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame::update Default is: 1.0

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : BBOX and Collision Project

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Goals understand bounding box and its implementation experience working with bounding box of a GameObject compute and work with the bounds of a Camera WC window program with collisions

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Bounding Box Always major-axis aligned 4 floats in 2D Point + Dimension Center + W x H Lower Left + W x H 2 points Lower Left + Upper Right “Easy” (efficient) to compute overlaps!!

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, BoundingBox class

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Bounds tests (minX, minY) (maxX, maxY)

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Bbox: Collision status eCollideLeft eCollideTop eCollideLeft | eCollideBottom eOutside eCollideRight eCollideBottom

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Using Bbox in GameObject Design decision: compute on the fly! Good: No state to maintain (no need to update after xform change)! Bad: Not free to create Bbox inquiry should be done no more than once per object per update

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Using Bbox in Camera Collide a xform with WCBounds Zone: a percentage of WC Bounds eOutside eCollideLeft zone WC Center Camera WC Bounds

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Testing Bbox Stop brain Print status as a number:

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Try Hero bound status: 16 is outside What is 6? = How about 12? = Try change the bound % from 0.8 to 0.2 rate in MyGame Try change from 0.02 to something much slower (like 0.001) Notice the tendency/potentials of “orbiting” Increase/decrease Brain speed (Up/Down arrows) To see different orbiting behaviors

Ch 6: Behaviors and CollisionsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Important limitation of Bbox Axis aligned Void space Our implementation no support for rotation!