Windows 8 Game development using HTML5 and JavaScript Martin Beeby Technical Evangelist

Slides:



Advertisements
Similar presentations
More frames in XHTML Please use speaker notes for additional information!
Advertisements

HTML 5 Previous version: HTML4.01, 1999 Still work in progress, most browsers support some of it.
Pivot Animation Tutorial. Tutorial links: Startup Moving your figure Adding new frames Playback Adding a figure Edit figure Load new figures Creating.
Escape A sticky man adventure using TKINTER python module By: Channing Burgess.
Guide to Programming with Python
HTML, HTML5 Canvas, JavaScript PART 3 LOOKING MORE CLOSELY AT FULL BLOWN GAME DESIGN A PATTERNED BACKGROUND (CREATED WTIH LOOPS) WITH A MOVING OBJECT CHALLENGES.
Edge Animate CreateJS is a suite of modular libraries and tools which work together to enable rich interactive content on open web technologies.
Introduction to TouchDevelop
Game Maker Day 2 Making a Maze Game.
Set 7: Events and Animation IT452 Advanced Web and Internet Systems.
Locally Edited Animations We will need 3 files to help get us started at
My First ACCESSIBLE Flash Movie. Course notes Detailed course notes, a printable copy of my slides, and all the samples shown today can be downloaded.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 20 – Dynamic HTML: Path, Sequencer and Sprite ActiveX Controls Outline 20.1Introduction 20.2DirectAnimation.
Programming Games Simulated ballistic motion: cannon ball. Classwork: Final day for midterm project and all projects for first part of class. Homework:
HTML 5 Tutorial Chapter 5 Canvas. Canvas The tag is used to display graphics. The Canvas is a rectangular area we control each and every pixel of it.
HTML5 CANVAS. SAVING INFORMATION BETWEEN FUNCTION CALLS.
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 2 "The games of a.
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.
Dynamic Languages User Group Feb 7, DynApi Javascript Library.
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.
Selling & Deploying Windows 8 Apps. Nick Hodge Professional Geek, Microsoft Australia DEV223.
Videos. Adding Videos to a Web Page Videos can make our pages more interesting and engaging. Most video-hosting services, such as YouTube, will provide.
Programming Video Games
DOM Animation Changing the DOM objects over time.
CS 174: Web Programming October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
Algorithms Writing instructions in the order they should execute.
Programming Games Show your rock-paper-scissors. Demonstrate bouncing ball. Demonstrate and examine Bo the dog. Homework: Modify Bo to make your own.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Action Script 12 "The games of a people.
Getting started with the turtle Find the latest version of this document at
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 12 "The games of.
This screen is showing the animation of a “fly in entrance” You can also modify the effect by selecting the effect either in the window or by clicking.
Midterm: Question 1 (35%) (30 minutes) Write an assembly program to draw a rectangle. – (5%) Show a message to ask for information of the rectangle – (5%)
XNA ● Proprietary Microsoft framework ● C#. Interface.
Game On! With HTML5. AUTHD on oreilly.com How a Game Works Time Passed Frame 1 Frame 2 Frame 3Frame 4.
08 – Canvas(2) Informatics Department Parahyangan Catholic University.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 22 Game Graphics.
Sprite sets. project of the week: bubble popper o objects appear from the bottom and slide up o player needs to avoid objects to earn points (objects.
Graphics in Python On entry: Run Python 2.78 from N: drive/computing and ICT VLE: Computing home page - check your feedback Success criteria: ●Understands.
Collision testing. learning targets Increase awareness of the struggles that of game development; Recognize computer science elements for game logic;
4.3. Code animations by using JavaScript Access data access by using JavaScript. Creating Animations, Working with Graphics, and Accessing Data.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Susan Ibach | Technical Evangelist Sage Franch | Technical Evangelist.
Index Background Costumes Making object walk smoothly Controlling an object with the keyboard Control an object with the mouse Changing costume when hit.
HTML5 ProgLan HTML5 Making a Game on the Canvas Part 1.
Game development.
Basic coding… with TouchDevelop!!
non-native -> native?!
That Gauge is COOL! 
What is a Function Expression?
Animation Frame Animation.
SVG & DOM Manipulation via Javascript
MOM! Phineas and Ferb are … Aims:
Internet of the Past.
WITH PYGAME ON THE RASPBERRY PI
Game Maker Intro to Programming Game Maker Pop Quiz (Both Groups)
An Introduction to Spritesheet Animation
JavaScript Selection Statement Creating Array
The Canvas.
Introduction to TouchDevelop
JavaScript.
Lecture 7: Introduction to Processing
Drawing Graphics in JavaScript
Game Maker Intro to Programming Game Maker Pop Quiz (Both Groups)
Catchup. Work on project.
Online Pogo Game Customer Service
Pogo Game Customer Care Helpline Number

Call Pogo Contact Phone Number and Enjoy Pogo Game
Presentation transcript:

Windows 8 Game development using HTML5 and JavaScript Martin Beeby Technical Evangelist

Agenda

Why Windows 8

Designed for Discovery Unprecedented reach Flexible business models Transparent terms Best economics

One time Purchase Use Your Existing Commerce Purchases over time Ad Supported

Basics of Canvas

document.addEventListner(“DomContentLoaded”, init, false);

DOMContentLoaded()init() draw() exit

Canvas

(function() { var game = {}; var supportsCanvas, canvasElement, canvasContext; game.init = function () { supportsCanvas = !!document.createElement('canvas').getContext; canvasElement = document.getElementById("gameCanvas"); canvasContext = canvasElement.getContext('2d');; console.log('Game Loaded, And canvas support is: ' + supportsCanvas); game.draw(); } game.draw = function () { canvasContext.fillStyle = "rgba(0,0,0,1)"; canvasContext.fillRect(20, 20, 10, 10); } document.addEventListener("DOMContentLoaded", game.init, false); })();

DOMContentLoaded()init() gameLoop() draw() exit

(function() { var game = {}; var supportsCanvas, canvasElement, canvasContext; game.init = function () { supportsCanvas = !!document.createElement('canvas').getContext; canvasElement = document.getElementById("gameCanvas"); canvasContext = canvasElement.getContext('2d');; console.log('Game Loaded, And canvas support is: ' + supportsCanvas); game.startGameLoop(); } game.startGameLoop = function () { window.requestAnimationFrame(game.gameLoop); }, game.gameLoop = function () { game.draw(); window.requestAnimationFrame(game.gameLoop); }, game.draw = function () { canvasContext.fillStyle = "rgba(0,0,0,1)"; canvasContext.fillRect(Math.random() * 400, Math.random() * 300, 10, 10); } document.addEventListener("DOMContentLoaded", game.init, false); })();

DOMContentLoaded()init() gameLoop() draw() exit clear()

(function() { var game = {}; var supportsCanvas, canvasElement, canvasContext; game.init = function () { supportsCanvas = !!document.createElement('canvas').getContext; canvasElement = document.getElementById("gameCanvas"); canvasContext = canvasElement.getContext('2d'); console.log('Game Loaded, And canvas support is: ' + supportsCanvas); window.requestAnimationFrame(game.gameLoop); } game.gameLoop = function () { game.clear(); game.draw(); window.requestAnimationFrame(game.gameLoop); } game.draw = function () { canvasContext.fillStyle = "rgba(0,0,0,1)"; canvasContext.fillRect(Math.random() * 400, Math.random() * 300, 10, 10); } game.clear = function () { canvasContext.clearRect(0, 0, canvasContext.canvas.width, canvasContext.canvas.height); } document.addEventListener("DOMContentLoaded", game.init, false); })();

(function() { var game = {}; var supportsCanvas, canvasElement, canvasContext; var lilSquareList = []; game.init = function () { supportsCanvas = !!document.createElement('canvas').getContext; canvasElement = document.getElementById("gameCanvas"); canvasContext = canvasElement.getContext('2d'); console.log('Game Loaded, And canvas support is: ' + supportsCanvas); window.requestAnimationFrame(game.gameLoop); } game.gameLoop = function () { game.clear(); var square = { w: 10, h: 10, xSpeed: randomXToY(-10, 10), ySpeed: randomXToY(-10, 10), x: canvasContext.canvas.width / 2, y: canvasContext.canvas.height / 2, }; lilSquareList.push(square); game.draw(); window.requestAnimationFrame(game.gameLoop); } game.draw = function () { for (var i = 0; i < lilSquareList.length; i++) { var square = lilSquareList[i]; canvasContext.fillStyle = "rgba(255,3,255,0.5)"; canvasContext.fillRect(square.x, square.y, square.w, square.h); square.x = square.x - square.xSpeed; square.y = square.y + square.ySpeed; square.size = square.size - 0.1; } game.clear = function () { canvasContext.clearRect(0, 0, canvasContext.canvas.width, canvasContext.canvas.height); } function randomXToY(minVal, maxVal, floatVal) { var randVal = minVal + (Math.random() * (maxVal - minVal)); return typeof floatVal == 'undefined' ? Math.round(randVal) : randVal.toFixed(floatVal); } document.addEventListener("DOMContentLoaded", game.init, false); })();

var gravity = -1; game.draw = function () { for (var i = 0; i < lilSquareList.length; i++) { var square = lilSquareList[i]; canvasContext.fillStyle = "rgba(255,3,255,0.5)"; canvasContext.fillRect(square.x, square.y, square.w, square.h); square.x = square.x - square.xSpeed; square.y = (square.y + square.ySpeed) square.ySpeed = square.ySpeed - gravity; square.size = square.size - 0.1; }

game.draw = function () { var square = { w: 10, h: 10, xSpeed: randomXToY(-10, 10), ySpeed: randomXToY(-10, 10), x: canvasContext.canvas.width / 2, y: canvasContext.canvas.height / 2, }; lilSquareList.push(square); for (var i = 0; i < lilSquareList.length; i++) { var square = lilSquareList[i]; canvasContext.fillStyle = "rgba(255,3,255,0.5)"; canvasContext.fillRect(square.x, square.y, square.w, square.h); square.x = square.x - square.xSpeed; square.y = (square.y + square.ySpeed) square.ySpeed = square.ySpeed - gravity; square.size = square.size - 0.1; if (square.y > (canvasContext.canvas.height) - 100) { square.ySpeed = -(square.ySpeed); }

CreateJS A JavaScript library that makes working with the HTML5 Canvas element easy.

_2dPlatformer

var supportsCanvas, canvasElement, canvasContext, imgMonsterARun, stage, spriteSheet, bmpAnimation; game.init = function () { supportsCanvas = !!document.createElement('canvas').getContext; canvasElement = document.getElementById("gameCanvas"); canvasContext = canvasElement.getContext('2d'); stage = new Stage(canvasElement); console.log('Game Loaded, And canvas support is: ' + supportsCanvas); imgMonsterARun = new Image(); imgMonsterARun.onload = game.setupCharacters; imgMonsterARun.onerror = game.error; imgMonsterARun.src = "images/MonsterARun.png"; }

game.setupCharacters = function () { spriteSheet = new SpriteSheet({ images: [imgMonsterARun], frames: { width: 64, height: 64, regX: 32, regY: 32 }, animations: { walk: [0, 9, "walk"] } }); bmpAnimation = new BitmapAnimation(spriteSheet); bmpAnimation.gotoAndPlay("walk"); bmpAnimation.shadow = new Shadow("#454", 0, 5, 4); // Shadows are slow bmpAnimation.name = "monster1"; bmpAnimation.direction = 90; bmpAnimation.vX = 4; bmpAnimation.x = 16; bmpAnimation.y = 32; bmpAnimation.currentFrame = 0; stage.addChild(bmpAnimation); game.gameLoop(); }

game.gameLoop = function () { game.clear(); game.draw(); window.requestAnimationFrame(game.gameLoop); }

game.draw = function () { // Hit testing the screen width, otherwise our sprite would disappear if (bmpAnimation.x >= canvasContext.canvas.width - 16) { // We've reached the right side of our screen bmpAnimation.direction = -90; } if (bmpAnimation.x < 16) { // We've reached the left side of our screen // We need to walk right now bmpAnimation.direction = 90; } // Moving the sprite based on the direction & the speed if (bmpAnimation.direction == 90) { bmpAnimation.x += bmpAnimation.vX; } else { bmpAnimation.x -= bmpAnimation.vX; } stage.update(); }

game.setupCharacters = function () { spriteSheet = new SpriteSheet({ images: [imgMonsterARun], frames: { width: 64, height: 64, regX: 32, regY: 32 }, animations: { walk: [0, 9, "walk", 4 ] } }); SpriteSheetUtils.addFlippedFrames(spriteSheet, true, false, false); bmpAnimation = new BitmapAnimation(spriteSheet); bmpAnimation.gotoAndPlay("walk_h"); bmpAnimation.shadow = new Shadow("#454", 0, 5, 4); bmpAnimation.name = "monster1"; bmpAnimation.direction = 90; bmpAnimation.vX = 4; bmpAnimation.x = 16; bmpAnimation.y = 32; bmpAnimation.currentFrame = 0; stage.addChild(bmpAnimation); game.gameLoop(); }

game.draw = function () { // Hit testing the screen width, otherwise our sprite would disappear if (bmpAnimation.x >= canvasContext.canvas.width - 16) { // We've reached the right side of our screen // We need to walk left now to go back to our initial position bmpAnimation.direction = -90; bmpAnimation.gotoAndPlay("walk"); } if (bmpAnimation.x < 16) { // We've reached the left side of our screen // We need to walk right now bmpAnimation.direction = 90; bmpAnimation.gotoAndPlay("walk_h"); } if (bmpAnimation.direction == 90) { bmpAnimation.x += bmpAnimation.vX; } else { bmpAnimation.x -= bmpAnimation.vX; } stage.update(); }

game.init = function () { supportsCanvas = !!document.createElement('canvas').getContext; canvasElement = document.getElementById("gameCanvas"); canvasContext = canvasElement.getContext('2d'); stage = new Stage(canvasElement); console.log('Game Loaded, And canvas support is: ' + supportsCanvas); var manifest = [ { src: "images/MonsterARun.png", id: "imgMonsterARun" }, { src: "images/MonsterAIdle.png", id: "imgMonsterAIdle" } ]; preload = new PreloadJS(); preload.onComplete = game.setupCharacters; preload.loadManifest(manifest); preload.getResult("imgMonsterARun"); }

game.setupCharacters = function () { var image = preload.getResult("imgMonsterARun").result; spriteSheet = new SpriteSheet({ images: [image], frames: { width: 64, height: 64, regX: 32, regY: 32 }, animations: { walk: [0, 9, "walk", 4] } }); SpriteSheetUtils.addFlippedFrames(spriteSheet, true, false, false); bmpAnimation = new BitmapAnimation(spriteSheet); bmpAnimation.gotoAndPlay("walk_h"); //animate bmpAnimation.shadow = new Shadow("#454", 0, 5, 4); bmpAnimation.name = "monster1"; bmpAnimation.direction = 90; bmpAnimation.vX = 4; bmpAnimation.x = 16; bmpAnimation.y = 32; bmpAnimation.currentFrame = 0; stage.addChild(bmpAnimation); var imgMonsterAIdle = preload.getResult("imgMonsterAIdle").result; spriteSheetIdle = new SpriteSheet({ images: [imgMonsterAIdle], frames: { width: 64, height: 64, regX: 32, regY: 32 }, animations: { idle: [0, 10, "idle", 4] } }); bmpAnimationIdle = new BitmapAnimation(spriteSheetIdle); bmpAnimationIdle.name = "monsteridle1"; bmpAnimationIdle.x = 16; bmpAnimationIdle.y = 32; game.gameLoop(); }

game.draw = function () { if (bmpAnimation.x >= canvasContext.canvas.width - 16) { // We've reached the right side of our screen bmpAnimation.direction = -90; bmpAnimation.gotoAndPlay("walk"); } if (bmpAnimation.x < 16) { bmpAnimation.direction = 90; bmpAnimation.gotoAndStop("walk"); stage.removeChild(bmpAnimation); bmpAnimationIdle.gotoAndPlay("idle"); stage.addChild(bmpAnimationIdle); } if (bmpAnimation.direction == 90) { bmpAnimation.x += bmpAnimation.vX; } else { bmpAnimation.x -= bmpAnimation.vX; } stage.update(); }

Links to EaselJS, and source code of both projects with instructions