Game On! With HTML5. AUTHD on oreilly.com How a Game Works Time Passed Frame 1 Frame 2 Frame 3Frame 4.

Slides:



Advertisements
Similar presentations
What is jQuery Mobile? How to use it? Doncho Minkov Telerik Corporation Technical Trainer.
Advertisements

JQuery A Javascript Library Hard things made eas(ier) Norman White.
Web Development & Design Foundations with XHTML Chapter 7 Key Concepts.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
WinJS Priorities max: 15 high: 13 aboveNormal: 9 normal: 0 belowNormal: -9 idle: -13 min: -15.
The Web Warrior Guide to Web Design Technologies
Dreamweaver Review ROB SCHWARTZ IS GONNA FEEL MY WRATH!
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Create a Web Site with Frames
Chapter 6 Working with Frames.
XP Tutorial 5New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Designing a Web Site with Frames Using Frames to Display Multiple Web Pages Tutorial.
1 Advanced HTML Joshua S. Simon Collective Technologies.
TUTORIAL 8: Enhancing a Web Site with Advanced CSS
 jQuery Mobile An Introduction. What is jQuery Mobile  A framework built on top of jQuery, used for creating mobile web applications  Designed to make.
CIT 256 Mobile Web Development Dr. Beryl Hoffman.
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
® IBM Software Group © 2006 IBM Corporation Creating JSF/EGL Template Pages This section describes how to create.JTPL (Java Template Pages) using the Page.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
UNIT 6 JAVASCRIPT EVENT HANDLERS &WEB BROWSERS DETECTION.
Win8 on Intel Programming Course Modern UI : Features Cédric Andreolli Intel Software.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
XP 1 Tutorial 5 Using Frames in a Web Site. XP 2 Tutorial Objectives  Describe the uses of frames in a Web site  Lay out frames within a browser window.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
WEB DESIGN USING DREAMWEAVER. The World Wide Web –A Web site is a group of related files organized around a common topic –A Web page is a single file.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Getting Started. XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to XNA Game.
HTML history, Tags, Element. HTML: HyperText Markup Language Hello World Welcome to the world!
DUE Hello World on the Android Platform.
CHAPTER 4 LINKS Creating links between pages Linking to other sites links.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 6: Links.
App Inventor MIT App Inventor.
An Introduction To Websites With a little of help from “WebPages That Suck.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Web hosting in app Creating a Windows Store app with web assets.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 7 Key Concepts 1 Copyright © Terry Felke-Morris.
Week 11 Creating Framed Layouts Objectives Understand the benefits and drawbacks of frames Understand and use frame syntax Customize frame characteristics.
Lesson 02 // Elements & Attributes. There are different types of elements, but the 2 most important ones are BLOCK and INLINE. Block elements flow from.
Tutorial #6 – Creating Fixed Width Layouts. Tutorial #5 Review – Box Model Every html element is surround by a box Content, Padding, Border, Margin Can.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
audio video object Options: controls autoplay Need to define height and width Options: controls autoplay.
Use CSS to Implement a Reusable Design Selecting a Dreamweaver CSS Starter Layout is the easiest way to create a page with a CSS layout You can access.
Computer Science and Software Engineering© 2014 Project Lead The Way, Inc. HTML5 Evolving Standards JavaScript.
Web Design (8) Images (2). My Holiday Photos An exercise in adding and linking images. Create a new website folder calling it ‘My Holiday Photos’. In.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 7 Key Concepts 1 Copyright © Terry Felke-Morris.
CSCI 6962: Server-side Design and Programming Facelets and User Interface Design.
Internet Explorer 10 IE9 hardware-accelerated platform CSS 2D Transforms CSS Backgrounds & Borders CSS Color CSS Fonts CSS Media Queries CSS Namespaces.
Responsive vs. Adaptive Web Design A responsive web design will "fluidly change and respond to fit any screen or device size" An adaptive design will "change.
| imodules.com How to Use Encompass like an iModules Designer Presented by Craig Juneau, Erin Messel & John Stringer iModules Design Team.
Microsoft FrontPage 2003 Illustrated Complete Creating a Frames Page.
Model View ViewModel Architecture. MVVM Architecture components.
Adding Interactivity Comp 140 Fall Web 2.0 Major change in internet usage –From mostly static pages Text Graphics Simple links –To new paradigm.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 6 1 Creating Dynamic Pages.
1 Company Confidential Need a Mobile DotNetNuke Site? Get One the Quick and Easy Way Using CSS Media Queries Amelia Marschall Partner & Creative Director.
HTML5 and CSS3 Illustrated Unit F: Inserting and Working with Images.
Elements & Attributes. There are different types of elements, but the 2 most important ones are BLOCK and INLINE. Block elements flow from top to bottom.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Developing Windows 8 Style Application With HTML and JavaScript
Dreamweaver – Setting up a Site and Page Layouts
5/2/2018 1:53 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS.
Building high performance Metro style apps using HTML5
JQuery UI Plug-ins, Object Models & the Window Object
Tutorial 6 Creating Dynamic Pages
Responsive Framework.
Building responsive apps and sites with HTML5 web workers
Build polished collection and list apps in HTML5
Game Loop Update & Draw.
Floating and Positioning
Catchup. Work on project.
Presentation transcript:

Game On! With HTML5

AUTHD on oreilly.com

How a Game Works Time Passed Frame 1 Frame 2 Frame 3Frame 4

The Canvas Element

DOM Structure # container # game_canvas # snowball_btn DOM Structure

DOM – Code Example

Resize with { width: device-width; height: device-height; } screen and (orientation: portrait) { width: 768px; height: 1366px; } /* CSS for portrait layout goes here */ }

Initialize, Update, Draw pattern All systems in the game have an Initialize, Update, and Draw method: Initialize, Update, Draw pattern

Drawing the Snowball to the canvas. canvascontext.drawImage( image, //image (‘snowball.png’); 0, 0, //source position 256, 261, //source size 50, 100, //destination position(canvas) 256, 261); //destination size 256px 261px 50px 100px 256px 261px Source Drawing Images to a Canvas Example

Keyboard Input Animation Logic Inputs Entities Collision Building Blocks

Entities

Update Collision Not colliding.Colliding.

var audiosample = new Audio("media/Sounds/path.mp3"); audiosample.play(); Sound

Only Draw what you Need: Any call to the canvas draw is expensive. The best way to optimize drawing is to draw less. Hikers are composited with their custom face image to make only one draw call instead of two. The sky is just applied to the background-img property because it is static. Re-use Objects: Re-using objects instead of deleting them minimizes calls to the garbage collector. Pass only integers to the canvas draw API: Floats cause anti-aliasing to trigger. Performance

Watch out for Audio: Audio tags take up memory that could be used for gameplay Read as little as possible, and never read from the same canvas Using image data is much faster than drawing Test, test, test: Test on many devices with different processors (don’t forget about Atom and ARM) test, test, test: Really, test at every stage! Performance

demo

Page Structure

Navigation Project Template

WinJS

WinJS.Utilities.query("a").listen("click", function (evt) { // dont load this link in the main window evt.preventDefault(); // get target element var link = evt.target; //call navigate and pass the href of the link WinJS.Navigation.navigate(link.href); }); Overriding Link Behavior

WinJS.UI.Pages.define WinJS.UI.Pages.define("/home.html", { // This function is called whenever a user navigates to this page. ready: function (element, options) { //run code unique to this page } }); WinJS.UI.Pages.define

Data Binding with WinJS.Binding.List var hikerArray = [{ title: 'John Smith', color:'#333333', body_img:'/images/body_ png', face_img:'/images/default_face.png', }, { title: 'Erin Dodge', color:'#00c0ac', body_img: '/images/body_00c0ac.png', face_img:'/images/default_face.png', }, { title: 'James Parker', … } ]; var hikerBindingList = new WinJS.Binding.List(hikerArr); Data Binding with WinJS.Binding.List

WinJS.Namespace.define var publicMembers = { itemList: hikerBindingList }; WinJS.Namespace.define("DataHikers", publicMembers); WinJS.Namespace.define

WinJS.UI.ListView

<div id="hikerListView" data-win- control="WinJS.UI.ListView" data-win-options="{ itemDataSource: DataHikers.itemList.dataSource, itemTemplate: select(‘#hikersTemplate’) }“ > WinJS.UI.ListView

Define the template Define the Template

WinJS.UI.processAll(); Define the template Define the Template

WinJS.UI.AppBar WinJS.UI.AppBar

Adding commands to the AppBar Adding Commands to the AppBar

Command options Command Options

Adding Functionality // get add command element var cmdAdd = document.getElementById('cmdAdd'); cmdAdd.addEventListener('click', function (ev) { // respond to add hiker command }); Adding Functionality

The Accelerometer accelerometer.addEventListener("readingchanged", function(evt){ // handle change });

When the Application loads, we need to setup the accelerometer device. This is done in the app.onactivated event. The report interval specifies in milliseconds how often the device will update the accelerometer data. accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault(); if (accelerometer !== null) { //accelerometer available on device // Establish the report interval var minimumReportInterval = accelerometer.minimumReportInterval; var reportInterval = minimumReportInterval > 16 ? minimumReportInterval : 16; accelerometer.reportInterval = reportInterval; } Accelerometer Setup

Displaying Snapped View #snappedview { display:none; screen and (-ms-view-state: snapped) { #contentHost {/*hide main content*/ display:none; } #snappedview {/*show snapped view content*/ display:block; }

var viewStates = Windows.UI.ViewManagement.ApplicationViewState; var newViewState = Windows.UI.ViewManagement.ApplicationView.value; if (newViewState === viewStates.snapped) {... //Application is in snapped view }; Custom Logic for Snapview

var userInformation = Windows.System.UserProfile.UserInformation; var userPic = userInformation.getAccountPicture(); var img = new Image(); var imgurl = URL.createObjectURL(userPic); img.src = imgurl; Getting User Profile Data

The contact picker launches a UI that will return a single contact. Using ContactPicker

// get reference to ContactPicker var picker = Windows.ApplicationModel.Contacts.ContactPicker(); // open the picker picker.pickSingleContactAsync().then(function (contact) { // handle contact information }); Open the contact picker and handle the result

Getting contact thumbnails contact.getThumbnailAsync().done(function (thumbnail) { // generate a URL for the thumbnail image thumbURL = URL.createObjectURL(thumbnail); // use thumbURL to update the src of an image for // display face_img.src = thumbURL; }); Getting contact thumbnails

Download the Microsoft Ad SDK: <div id="ad_bottom_rail“ data-win-control="MicrosoftNSJS.Advertising.AdControl" data-win-options="{applicationId: 'd25517cb-12d bdc-52040c712cab', adUnitId: ' '}"> Implementing Ads using the Microsoft SDK

var notifications = Windows.UI.Notifications; var template = notifications.TileTemplateType.tileWideSmallImageAndText02; var tileXml = notifications.TileUpdateManager.getTemplateContent(template); var line1 = tileXml.getElementsByTagName("text")[0]; line1.appendChild(tileXml.createTextNode(“Yeti Stats")); Live Tile

var tileNotification = new notifications.TileNotification(tileXml); notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification); Creating a Notification