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

Slides:



Advertisements
Similar presentations
The Web Warrior Guide to Web Design Technologies
Advertisements

Aim: Use the given examples to record examples and our own ideas in our journal 1.Write technical examples in journal and/or participate in full.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
1 L45 Multimedia: Applets and Applications. 2 OBJECTIVES  How to get and display images.  To create animations from sequences of images.  To create.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
“But I don't want to be a “programmer!” ActionScript for journalists Presentation by Mindy McAdams Flashjournalism.com.
Chapter 11 Adding Media and Interactivity. Flash is a software program that allows you to create low-bandwidth, high-quality animations and interactive.
JQuery CS 268. What is jQuery? From their web site:
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Introduction to AJAX AJAX Keywords: JavaScript and XML
Databases.  Multi-table queries  Join ▪ An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them. 
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Games Development 2 Resource Management CO3301 Week 3.
Advanced Level Course. Site Extras Site Extras consist of four categories: Stationeries Site Trash Designs Components.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
 2005 Pearson Education, Inc. All rights reserved Multimedia: Applets and Applications.
Chapter 17: Applets, Images, and Sound. Objectives Learn about applets Write an HTML document to host an applet Use the init() method Work with JApplet.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Web Programming Brian Toone 8/27/2014. Outline for today 1.Understanding the architecture of the web 2.Overview of programming languages – Client-side.
AJAX Compiled from “AJAX Programming” [Sang Shin] (Asynchronous JavaScript and XML)
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Creating Dynamic Webpages
ANDROID AND MODEL / VIEW / CONTROLLER. Slide 2 Design Patters Common solutions to programming problems are called design patterns Design patterns are.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
Chapter 12: Accessing the Web URL (Uniform Resource Locator) class Applet methods –for audio clips –for images –context interface.
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
 An essential supporting structure of any thing  A Software Framework  Has layered structure ▪ What kind of functions and how they interrelate  Has.
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Understanding JavaScript and Coding Essentials Lesson 8.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript and Ajax Week 10 Web site:
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,
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 7 Manipulating.
Day 22, Slide 1 CSE 103 Day 22 Non-students: Please logout by 10:12. Students:
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.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
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.
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.
Introduction to AJAX Pat Morin COMP Outline What is AJAX? – History – Uses – Pros and Cons An XML HTTP Transaction – Creating an XMLHTTPRequest.
Sprites (Images) and Sounds
Implementing Common Components of Video Games
Textures, Sprites, and Fonts
Chapter 4: Scalable Vector Graphics (SVG)
The Basics: HTML5, Drawing, and Source Code Organization
Programming the Web using XHTML and JavaScript
AJAX.
AJAX.
Interpreting Example 3.5.
DHTML Javascript Internet Technology.
.NET and .NET Core 7. XAML Pan Wuming 2017.
DHTML Javascript Internet Technology.
JavaScript CS 4640 Programming Languages for Web Applications
PHP and JSON Topics Review JSON.
Web Programming and Design
Web Programming and Design
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 4 Implementing Common Components of Video Games

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Game Loop Typical structure Notice: the input() update!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Game Loop: Implementation Input() inside vs outside of the real-time loop? Responsiveness when game is lagging Fixed update rate: Simple physics implementation (later in Chapter 9)

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Game Loop Project New Engine component (similarity to gEngine.VertexBuffer!!)

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, _runLoop function requestAnimationFrame().call(class)  syntax! mIsLoopRunning not checked Will do so later No input() checking yet update() and draw() Separated!! No update in draw No draw in update!!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Trigger to start the loop Note the initializations

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Starting the loop: MyGame.Initialize()

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame: update()

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame: draw()

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Keyboard Input Events and event handlers HTML5 Event registration and handlers window.addEventListener(“Event”, handler) Keycodes: ‘A’ = xx ‘B’ = xx+1 …

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, The Engine.Input component

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Input: variables for key states

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Event handlers and initialization

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Keyboard update() and support

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine.Core: to init Input

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine.Loop: to update input

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine initialization (from MyGame)

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Testing Keyboard input: MyGame.update()

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Resource Management Synchronous load: Issue load and wait Stops web browser!! May seem “hang” to user Asynchronous load: Issue load, provide “Callback” and continue “Callback” is called when load is completed Pro: Efficient, support interactivity Con: Complex, requires synchronization

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : ResourceMap Project ResourceMap: Key-value pair of “string=id” and resource E.g., file name and content of file

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, ResourceMap: functions Load synchronization support Create/Store-to EntryMap Nothing else! Asset assessing support Check and retrieve Misc support (e.g., call back)

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, TextFileLoader: An Engine Component Working with ResourceMap isAssetLoaded(): Check before (re)-load! Call to: asyncLoadRequest() Filename (path) as ID onreadystatechange() Status report: next slide onLoad() When loaded: next slides

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, TextFileLoader: status check Status check!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, TextFileLoader: onLoad() Successful loaded If loading XML Create DOMParser() If plain textfile Return the entire text source Work with ResourceMap asyncLoadCompleted()

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine DefaultResoruces Notice SimpleShader is shared by all Renderables!! There will be many other examples Define DefaultResources engine component

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Default SimpleShader engine resource

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, SimpleShader: user default resource

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine: starting sequence Index.html Engine_Core.js

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Testing async loading: MyGame No need to worry about initialization Game Engine Core (good!) MyGame Constructor simple again! Access shader from default resource

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Scene File The “assets” folder A convention for ourselves (NOT defined by anything!!) XML format and parsing (not cover here)

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame class Constructor: declaring var and defining constants Game specific resources (assets) MAY NOT be there!! Initialize(): allocate and instantiate, setting up states Game specific resources are loaded!! update()/draw(): Seen this before … again: update(): DO NOT try to draw anything draw(): DO NOT make any changes to game state! loadScene()/unloadScene(): loading/unloading of scene specific information!!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame: construct and load!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, MyGame:initialize() Game specific resources are now loaded!!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine: starting sequence with new MyGame Index.html Engine_Core.js

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine Core: startScene() Engine_Core.js Engine_Loop.js

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Scene Objects Define GameEngine (Core and Loop) interface protocol with game developer (our API user) Abstract class for subclass by clients

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Support for “sub-classing” Engine_Core.js

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Game Loop: stop to unload resources Engine_Loop.js

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Loading the next Scene …

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, : Audio support Audio: files Just another example of external resource! Support for mp3 and wav formats HTML5: AudioContext Load/Decode audio resources Play audio resources!! Two important categories Audio as music: e.g., background Continuous playing, need control Audio as cue: Short, no need for control

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Engine_AudioClip: Component

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Loading of AudioClips Exact same structure as TextFile loader Work with ResourceMap isAssetLoaded() asyncLoadRequested() NEW: incAssetRefCount() In case loaded multiple times!! req.onLoad() … next slide

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, req.onLoad(): once loaded … Store the entire file content to ResourceMap asyncLoadCompleted()!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Audio as Cue Each Cue must be a separate file! Start and no more control!

Ch 4: Common ComponentsBuild your own 2D Game Engine. Sung, Pavleas, Arnez, and Pace, Background music support Keep reference for future control