SlideShare a Scribd company logo
1 of 29
Introduction to HTML5 game development (with Phaser)
valerio.riva@gmail.com
@ValerioRiva
http://it.linkedin.com/in/valerioriva/
Valerio «Lotti» Riva
Who am I?
• Web developer @ past life
• Game developer @ Interactive Project
• MyGPTeam (http://www.mygpteam.com/)
• MyGPTeam Turbo (http://www.mygpteam.com/turbo/)
• OverVolt: crazy slot cars (coming soon!)
ROME 11-12 april 2014 – Valerio Riva
2
Intro
• Core game development concepts
• Phaser: Desktop and Mobile HTML5 game
framework
• Few useful tools
• Deployment
ROME 11-12 april 2014 – Valerio Riva
3
HTML5 is the new Flash
• No plugin needed!
• Available on all mobile devices
• Low performances on almost
every mobile devices
(especially on Android)
• Flash game frameworks ported
to HTML5 (Flixel -> Phaser!)
ROME 11-12 april 2014 – Valerio Riva
4
To develop an HTML5 game you
need…
• Any OS
• Any editor
• Any web server
Or you can just use Brackets! http://brackets.io/
ROME 11-12 april 2014 – Valerio Riva
5
Phaser (http://phaser.io/)
• Easy to use 2D game framework
• Focused on mobile
• Use pixi.js for WebGL & Canvas rendering
(http://www.pixijs.com/)
• Supports WebAudio & HTML Audio
• Various physics engine supported
• “arcade”: simple AABB physics engine
• p2.js: complete physics engine
(http://schteppe.github.io/p2.js/)
ROME 11-12 april 2014 – Valerio Riva
6
Core Game Development
Concepts
• Loop
• Sprite
• Tilemap
• Collision
• Input
ROME 11-12 april 2014 – Valerio Riva
7
do { game } while (true);
• The hearth of the game
• update loop executes game logic
• Inputs, AI, collisions… your game is computed here!
• rendering loop draws graphic elements to screen
• Phaser game implementation
• Game is a set of states
• Each state has its own loops
• rendering loop is supplied by pixi.js
ROME 11-12 april 2014 – Valerio Riva
8
Phaser game state
Main functions:
• preload: used to load assets
• create: state initialization
• update: the real game loop
• render: called after rendering. Use it for debugging and
post-rendering purposes
• Other function:
• pause: called when the game is paused (on focus loss)
• shutdown: called when leaving a state
• …
ROME 11-12 april 2014 – Valerio Riva
9
Hello Phaser!
ROME 11-12 april 2014 – Valerio Riva
10
Deployment
Web
• Any hosting!
• Game portals
• http://gamepix.com
• http://kongregate.com
• http://armorgames.com
Mobile
• Cordova (Phonegap)
• Intel XDK
• Accelerated webview
• CocoonJS
• Accelerated webview
• API for
Ads, IAP, accelerometer,
etc.
ROME 11-12 april 2014 –
Valerio Riva
11
Sprite
“In computer graphics, a sprite is a two-
dimensional image or animation that is
integrated into a larger scene.”
• Has a set of coordinates
and sizes
• Can be animated with
sequential drawings
• Main actor of a 2D game
ROME 11-12 april 2014 – Valerio Riva
12
• Be created
• Scale
• Rotate
• Moves
• Animate
• Have physic body
for collisions
• and much more!
var s = game.add.sprite(x,y, "image");
s.scale.setTo(0.75,0.75);
s.angle=180 / s.rotation=3.141
s.x += 10; s.y -= 10;
s.animations.play("walk",fps);
game.physics.arcade.enable(s);
ROME 11-12 april 2014 – Valerio Riva
What sprites can do
ROME 11-12 april 2014 –
Valerio Riva
13
Group of sprites
• Use it as z-ordered layer
• Use it for fast pooling and object recycling too
• Can apply transformation to all sprites of the group
• Can call methods on all sprites of the group
var group = game.add.group();
var sprite = group.create(x, y, 'image');
group.x += 100;
group.callAll('kill');
var zombie = group.getFirstExists(false);
zombie.revive(); //cured!
ROME 11-12 april 2014 – Valerio Riva
14
Tilesprite
“A tilesprite is a sprite that has a repeating texture.”
var tilesprite =
game.add.tileSprite(0, 0, 32, 64, 'image');
• texture can be scrolled
tilesprite.tilePosition.setTo(10,20);
• texture can be scaled
tilesprite.tileScale.setTo(1.5,1.5);
ROME 11-12 april 2014 – Valerio Riva
15
Tilemap
ROME 11-12 april 2014 – Valerio Riva
16
Tilemap
A tilemap is a map composed by a fixed number of
same sized sprites (tiles)
• Each tile can have different behavior
• Used to create platform and map based games
• Can be orthogonal or isometric
• Easy to create with Tiled
(http://www.mapeditor.org/)
ROME 11-12 april 2014 – Valerio Riva
17
Tilemap
function preload() {
game.load.tilemap('codem', 'tilemap/codem.json', n
ull, Phaser.Tilemap.TILED_JSON);
game.load.image('block', 'sprites/block.gif');
}
function create() {
map = game.add.tilemap("codem");
map.addTilesetImage("block");
map.setCollisionByExclusion([]);
layer = map.createLayer("codemotion");
layer.resizeWorld();
}
ROME 11-12 april 2014 – Valerio Riva
18
Collision
“A collision is an instance of one moving object touching
another.”
• Both object must have a “body” (collider)
• Object can be a sprite or a tilemap or even a group!
• A body can be a rectangle, a circle or a polygon
• Bodies can have a lot of properties
(mass, gravity, velocity, material, …)
• Last two statements depends on what physics engine
you are using.
• More complex is the engine, more computation is
needed. Choose wisely!
ROME 11-12 april 2014 – Valerio Riva
19
Collision
function create() {
game.physics.startSystem(Phaser.Physics.ARCADE);
sprite = game.add.sprite(0, 0, 'image');
game.physics.enable(sprite, Phaser.Physics.ARCADE);
sprite.body.collideWorldBounds = true;
sprite.body.bounce.set(1);
}
function update() {
game.physics.arcade.collide(sprite, [tilemap, group],
function(sprite, other) { … });
}
ROME 11-12 april 2014 – Valerio Riva
20
Input
Phaser supports natively
• Keyboard
• Mouse
• Multi-touch
• Gamepads (up to four, each one with 10 axis and
16 buttons)
• Supports even Xbox 360 gamepad! (button
mapping depends on browser : )
ROME 11-12 april 2014 – Valerio Riva
21
Input: Keyboard
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
ufo.y -= 10;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
ufo.y += 10;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
ufo.x -= 10;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
ufo.x += 10;
}
}
ROME 11-12 april 2014 – Valerio Riva
22
Input: Mouse
if (game.input.mousePointer.isDown) {
if (game.input.mousePointer.x < game.width*0.5) {
clickOnLeft = true;
}
else if (game.input.mousePointer.x > game.width*0.5) {
clickOnRight = true;
}
if (game.input.mousePointer.y < game.height*0.5) {
clickOnTop = true;
}
}
• Swap mousePointer with activePointer to capture
any active pointer (works with mouse and touch
inputs)
ROME 11-12 april 2014 – Valerio Riva
23
Input: Multi-touch
• Supports 10 pointers (= fingers)!
• Two pointers are already available
• Add another pointer
game.input.addPointer();
• Read different pointers
game.input.pointer3; or game.input.pointer4;
ROME 11-12 april 2014 – Valerio Riva
24
Input: Gamepad
function create() {
game.input.gamepad.start();
pad1 = game.input.gamepad.pad1;
}
function update() {
if (game.input.gamepad.supported
&& game.input.gamepad.active
&& pad1.connected) {
//play with gamepad!
if (pad1.isDown(Phaser.Gamepad.XBOX360_DPAD_LEFT)) { … }
if (pad1.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)) { … }
if (pad1.justPressed(Phaser.Gamepad.XBOX360_A)) { … }
}
else {
//play with boring keyboard!
}
}
ROME 11-12 april 2014 – Valerio Riva
25
Dissecting the mummy
ROME 11-12 april 2014 – Valerio Riva
26
Want more?
• Take a look to another example that implements P2
physics engine (http://github.com/Lotti/phaserTut)
• Phaser examples (http://examples.phaser.io/)
• Phaser docs (http://docs.phaser.io/)
ROME 11-12 april 2014 – Valerio Riva
27
Resources & Links
• The mummy game
• P2 physics engine example
• Phaser’s forum
• http://docs.phaser.io
• http://examples.phaser.io
• http://html5gameengine.com
• http://brackets.io
• http://www.pixijs.com
• http://schteppe.github.io/p2.js
• http://www.mapeditor.org
• http://xdk-software.intel.com
• https://www.ludei.com/cocoonjs
• https://cordova.apache.org
• http://phonegap.com
ROME 11-12 april 2014 –
Valerio Riva
28
Thank you!
Any Questions?
ROME 11-12 april 2014 – Valerio Riva
29
valerio.riva@gmail.com
@ValerioRiva
http://it.linkedin.com/in/valerioriva/

More Related Content

What's hot (9)

Introduction to Phaser.js
Introduction to Phaser.jsIntroduction to Phaser.js
Introduction to Phaser.js
 
UE4.14で広がるVRの可能性
UE4.14で広がるVRの可能性UE4.14で広がるVRの可能性
UE4.14で広がるVRの可能性
 
Recast Detour.pptx
Recast Detour.pptxRecast Detour.pptx
Recast Detour.pptx
 
UE4を用いた人間から狼男への変身表現法の解説
UE4を用いた人間から狼男への変身表現法の解説UE4を用いた人間から狼男への変身表現法の解説
UE4を用いた人間から狼男への変身表現法の解説
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
 
アプリ起動時間高速化 ~推測するな、計測せよ~
アプリ起動時間高速化 ~推測するな、計測せよ~アプリ起動時間高速化 ~推測するな、計測せよ~
アプリ起動時間高速化 ~推測するな、計測せよ~
 
大規模タイトルにおけるエフェクトマテリアル運用 (SQEX大阪: 林武尊様) #UE4DD
大規模タイトルにおけるエフェクトマテリアル運用 (SQEX大阪: 林武尊様) #UE4DD大規模タイトルにおけるエフェクトマテリアル運用 (SQEX大阪: 林武尊様) #UE4DD
大規模タイトルにおけるエフェクトマテリアル運用 (SQEX大阪: 林武尊様) #UE4DD
 
Unity道場08「絵づくりの基礎」ライティング虎の巻
Unity道場08「絵づくりの基礎」ライティング虎の巻Unity道場08「絵づくりの基礎」ライティング虎の巻
Unity道場08「絵づくりの基礎」ライティング虎の巻
 
UE4で”MetaHumanを使わずに”耳なし芳一になる10の方法 | UE4 Character Art Dive Online
UE4で”MetaHumanを使わずに”耳なし芳一になる10の方法 | UE4 Character Art Dive OnlineUE4で”MetaHumanを使わずに”耳なし芳一になる10の方法 | UE4 Character Art Dive Online
UE4で”MetaHumanを使わずに”耳なし芳一になる10の方法 | UE4 Character Art Dive Online
 

Viewers also liked

Making HTML5 Games with Phaser
Making HTML5 Games with PhaserMaking HTML5 Games with Phaser
Making HTML5 Games with PhaserIndieOutpost
 
VlbgWebDev Mai 2015 - Game Design PT 1
VlbgWebDev Mai 2015 - Game Design PT 1VlbgWebDev Mai 2015 - Game Design PT 1
VlbgWebDev Mai 2015 - Game Design PT 1Johannes Moser
 
硅谷早期投资趋势
硅谷早期投资趋势硅谷早期投资趋势
硅谷早期投资趋势Rui Ma
 
Keep your game in the fun zone - Designing an AI Director
Keep your game in the fun zone - Designing an AI DirectorKeep your game in the fun zone - Designing an AI Director
Keep your game in the fun zone - Designing an AI DirectorIndieOutpost
 
Juice up your game feel!
Juice up your game feel!Juice up your game feel!
Juice up your game feel!IndieOutpost
 
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...Pablo Farías Navarro
 
La ecuación de Batman
La ecuación de BatmanLa ecuación de Batman
La ecuación de BatmanJesus Garcia
 
Flappy Bird Game Dev by Phaser Framework
Flappy Bird Game Dev by Phaser FrameworkFlappy Bird Game Dev by Phaser Framework
Flappy Bird Game Dev by Phaser FrameworkRyan Chung
 
Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Alvinsight
 
Making Native Browser Games in The Modern Age
Making Native Browser Games in The Modern AgeMaking Native Browser Games in The Modern Age
Making Native Browser Games in The Modern AgeCatt Small
 
Lasertron lt 12 vs zone nexus fec
Lasertron lt 12 vs zone nexus fecLasertron lt 12 vs zone nexus fec
Lasertron lt 12 vs zone nexus fecejeffers2010
 
HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015
HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015
HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015Pablo Farías Navarro
 
Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...
Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...
Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...Himanshu Sharan
 
我的敏捷测试宣言(Agile Testing Manifesto)
我的敏捷测试宣言(Agile Testing Manifesto)我的敏捷测试宣言(Agile Testing Manifesto)
我的敏捷测试宣言(Agile Testing Manifesto)Xudong Yu
 
跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...
跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...
跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...Rui Ma
 
敏捷开发全景视图(流程、方法和最佳实践)
敏捷开发全景视图(流程、方法和最佳实践)敏捷开发全景视图(流程、方法和最佳实践)
敏捷开发全景视图(流程、方法和最佳实践)Weijun Zhong
 

Viewers also liked (20)

Phaser presentation
Phaser presentationPhaser presentation
Phaser presentation
 
Making HTML5 Games with Phaser
Making HTML5 Games with PhaserMaking HTML5 Games with Phaser
Making HTML5 Games with Phaser
 
VlbgWebDev Mai 2015 - Game Design PT 1
VlbgWebDev Mai 2015 - Game Design PT 1VlbgWebDev Mai 2015 - Game Design PT 1
VlbgWebDev Mai 2015 - Game Design PT 1
 
硅谷早期投资趋势
硅谷早期投资趋势硅谷早期投资趋势
硅谷早期投资趋势
 
Keep your game in the fun zone - Designing an AI Director
Keep your game in the fun zone - Designing an AI DirectorKeep your game in the fun zone - Designing an AI Director
Keep your game in the fun zone - Designing an AI Director
 
Juice up your game feel!
Juice up your game feel!Juice up your game feel!
Juice up your game feel!
 
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
 
La ecuación de Batman
La ecuación de BatmanLa ecuación de Batman
La ecuación de Batman
 
Flappy Bird Game Dev by Phaser Framework
Flappy Bird Game Dev by Phaser FrameworkFlappy Bird Game Dev by Phaser Framework
Flappy Bird Game Dev by Phaser Framework
 
Html5 game development
Html5 game developmentHtml5 game development
Html5 game development
 
Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014
 
Making Native Browser Games in The Modern Age
Making Native Browser Games in The Modern AgeMaking Native Browser Games in The Modern Age
Making Native Browser Games in The Modern Age
 
Marketing 360 - 2011
Marketing 360 - 2011Marketing 360 - 2011
Marketing 360 - 2011
 
Lasertron lt 12 vs zone nexus fec
Lasertron lt 12 vs zone nexus fecLasertron lt 12 vs zone nexus fec
Lasertron lt 12 vs zone nexus fec
 
HTML5 Game Development frameworks overview
HTML5 Game Development frameworks overviewHTML5 Game Development frameworks overview
HTML5 Game Development frameworks overview
 
HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015
HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015
HTML5 Mobile Game Development - Brisbane Game Technology Meetup 2015
 
Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...
Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...
Multi-platform Compatibility of HTML5 by developing simple HTML5 based game(M...
 
我的敏捷测试宣言(Agile Testing Manifesto)
我的敏捷测试宣言(Agile Testing Manifesto)我的敏捷测试宣言(Agile Testing Manifesto)
我的敏捷测试宣言(Agile Testing Manifesto)
 
跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...
跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...
跨境10年 - The Next Decade of US China Crossborder Early Stage Tech Venture Inve...
 
敏捷开发全景视图(流程、方法和最佳实践)
敏捷开发全景视图(流程、方法和最佳实践)敏捷开发全景视图(流程、方法和最佳实践)
敏捷开发全景视图(流程、方法和最佳实践)
 

Similar to Introduction to HTML5 game development (with Phaser)

Scrivere Webapp per Firefox OS - Orru
Scrivere Webapp per Firefox OS - OrruScrivere Webapp per Firefox OS - Orru
Scrivere Webapp per Firefox OS - OrruCodemotion
 
Bigpoint: Game of Thrones: Bringing Westeros to Life
Bigpoint: Game of Thrones: Bringing Westeros to LifeBigpoint: Game of Thrones: Bringing Westeros to Life
Bigpoint: Game of Thrones: Bringing Westeros to LifeDevGAMM Conference
 
Build a serverless distributed Pong game with Azure
Build a serverless distributed Pong game with AzureBuild a serverless distributed Pong game with Azure
Build a serverless distributed Pong game with AzureMarco Parenzan
 
Node meetup feb_20_12
Node meetup feb_20_12Node meetup feb_20_12
Node meetup feb_20_12jafar104
 
VR digest. July 2017
VR digest. July 2017VR digest. July 2017
VR digest. July 2017ElifTech
 
Intro to HTML5 Game Programming
Intro to HTML5 Game ProgrammingIntro to HTML5 Game Programming
Intro to HTML5 Game ProgrammingJames Williams
 
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...Joseph Labrecque
 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)David Salz
 
Developing Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay FrameworkDeveloping Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay FrameworkCsaba Toth
 
Refactoring PHP/Symfony2 apps
Refactoring PHP/Symfony2 appsRefactoring PHP/Symfony2 apps
Refactoring PHP/Symfony2 appsRaul Fraile
 
Teacher Training Workshop - Game Development with Phaser
Teacher Training Workshop  - Game Development with PhaserTeacher Training Workshop  - Game Development with Phaser
Teacher Training Workshop - Game Development with PhaserPablo Farías Navarro
 
Delta Engine Multiplatform Development Presentation 2011-05
Delta Engine Multiplatform Development Presentation 2011-05Delta Engine Multiplatform Development Presentation 2011-05
Delta Engine Multiplatform Development Presentation 2011-05Benjamin Nitschke
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.ioSteven Cooper
 
Game Development with Windows Phone 7
Game Development with Windows Phone 7Game Development with Windows Phone 7
Game Development with Windows Phone 7Allan Mangune
 
VR digest. December 2017
VR digest. December 2017VR digest. December 2017
VR digest. December 2017ElifTech
 
Java 8 Launch Event - Past, Present and Future of Java and Java 8 key themes
Java 8 Launch Event - Past, Present and Future of Java and Java 8 key themesJava 8 Launch Event - Past, Present and Future of Java and Java 8 key themes
Java 8 Launch Event - Past, Present and Future of Java and Java 8 key themesLucas Jellema
 
Snake project report
Snake project reportSnake project report
Snake project reportManju Rajput
 

Similar to Introduction to HTML5 game development (with Phaser) (20)

Scrivere Webapp per Firefox OS - Orru
Scrivere Webapp per Firefox OS - OrruScrivere Webapp per Firefox OS - Orru
Scrivere Webapp per Firefox OS - Orru
 
Bigpoint: Game of Thrones: Bringing Westeros to Life
Bigpoint: Game of Thrones: Bringing Westeros to LifeBigpoint: Game of Thrones: Bringing Westeros to Life
Bigpoint: Game of Thrones: Bringing Westeros to Life
 
Ferguson VR Hackathon - May 6, 2017
Ferguson VR Hackathon - May 6, 2017Ferguson VR Hackathon - May 6, 2017
Ferguson VR Hackathon - May 6, 2017
 
Build a serverless distributed Pong game with Azure
Build a serverless distributed Pong game with AzureBuild a serverless distributed Pong game with Azure
Build a serverless distributed Pong game with Azure
 
Node meetup feb_20_12
Node meetup feb_20_12Node meetup feb_20_12
Node meetup feb_20_12
 
VR digest. July 2017
VR digest. July 2017VR digest. July 2017
VR digest. July 2017
 
Intro to HTML5 Game Programming
Intro to HTML5 Game ProgrammingIntro to HTML5 Game Programming
Intro to HTML5 Game Programming
 
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
What’s Going On with the Adobe® Flash® Platform and why it is still Relevant ...
 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
 
Developing Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay FrameworkDeveloping Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay Framework
 
XNA L01–Introduction
XNA L01–IntroductionXNA L01–Introduction
XNA L01–Introduction
 
Refactoring PHP/Symfony2 apps
Refactoring PHP/Symfony2 appsRefactoring PHP/Symfony2 apps
Refactoring PHP/Symfony2 apps
 
Teacher Training Workshop - Game Development with Phaser
Teacher Training Workshop  - Game Development with PhaserTeacher Training Workshop  - Game Development with Phaser
Teacher Training Workshop - Game Development with Phaser
 
Delta Engine Multiplatform Development Presentation 2011-05
Delta Engine Multiplatform Development Presentation 2011-05Delta Engine Multiplatform Development Presentation 2011-05
Delta Engine Multiplatform Development Presentation 2011-05
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
 
Game Development with Windows Phone 7
Game Development with Windows Phone 7Game Development with Windows Phone 7
Game Development with Windows Phone 7
 
Java8 launch at AMIS Services / First8
Java8 launch at AMIS Services / First8Java8 launch at AMIS Services / First8
Java8 launch at AMIS Services / First8
 
VR digest. December 2017
VR digest. December 2017VR digest. December 2017
VR digest. December 2017
 
Java 8 Launch Event - Past, Present and Future of Java and Java 8 key themes
Java 8 Launch Event - Past, Present and Future of Java and Java 8 key themesJava 8 Launch Event - Past, Present and Future of Java and Java 8 key themes
Java 8 Launch Event - Past, Present and Future of Java and Java 8 key themes
 
Snake project report
Snake project reportSnake project report
Snake project report
 

Recently uploaded

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 

Recently uploaded (20)

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

Introduction to HTML5 game development (with Phaser)

  • 1. Introduction to HTML5 game development (with Phaser) valerio.riva@gmail.com @ValerioRiva http://it.linkedin.com/in/valerioriva/ Valerio «Lotti» Riva
  • 2. Who am I? • Web developer @ past life • Game developer @ Interactive Project • MyGPTeam (http://www.mygpteam.com/) • MyGPTeam Turbo (http://www.mygpteam.com/turbo/) • OverVolt: crazy slot cars (coming soon!) ROME 11-12 april 2014 – Valerio Riva 2
  • 3. Intro • Core game development concepts • Phaser: Desktop and Mobile HTML5 game framework • Few useful tools • Deployment ROME 11-12 april 2014 – Valerio Riva 3
  • 4. HTML5 is the new Flash • No plugin needed! • Available on all mobile devices • Low performances on almost every mobile devices (especially on Android) • Flash game frameworks ported to HTML5 (Flixel -> Phaser!) ROME 11-12 april 2014 – Valerio Riva 4
  • 5. To develop an HTML5 game you need… • Any OS • Any editor • Any web server Or you can just use Brackets! http://brackets.io/ ROME 11-12 april 2014 – Valerio Riva 5
  • 6. Phaser (http://phaser.io/) • Easy to use 2D game framework • Focused on mobile • Use pixi.js for WebGL & Canvas rendering (http://www.pixijs.com/) • Supports WebAudio & HTML Audio • Various physics engine supported • “arcade”: simple AABB physics engine • p2.js: complete physics engine (http://schteppe.github.io/p2.js/) ROME 11-12 april 2014 – Valerio Riva 6
  • 7. Core Game Development Concepts • Loop • Sprite • Tilemap • Collision • Input ROME 11-12 april 2014 – Valerio Riva 7
  • 8. do { game } while (true); • The hearth of the game • update loop executes game logic • Inputs, AI, collisions… your game is computed here! • rendering loop draws graphic elements to screen • Phaser game implementation • Game is a set of states • Each state has its own loops • rendering loop is supplied by pixi.js ROME 11-12 april 2014 – Valerio Riva 8
  • 9. Phaser game state Main functions: • preload: used to load assets • create: state initialization • update: the real game loop • render: called after rendering. Use it for debugging and post-rendering purposes • Other function: • pause: called when the game is paused (on focus loss) • shutdown: called when leaving a state • … ROME 11-12 april 2014 – Valerio Riva 9
  • 10. Hello Phaser! ROME 11-12 april 2014 – Valerio Riva 10
  • 11. Deployment Web • Any hosting! • Game portals • http://gamepix.com • http://kongregate.com • http://armorgames.com Mobile • Cordova (Phonegap) • Intel XDK • Accelerated webview • CocoonJS • Accelerated webview • API for Ads, IAP, accelerometer, etc. ROME 11-12 april 2014 – Valerio Riva 11
  • 12. Sprite “In computer graphics, a sprite is a two- dimensional image or animation that is integrated into a larger scene.” • Has a set of coordinates and sizes • Can be animated with sequential drawings • Main actor of a 2D game ROME 11-12 april 2014 – Valerio Riva 12
  • 13. • Be created • Scale • Rotate • Moves • Animate • Have physic body for collisions • and much more! var s = game.add.sprite(x,y, "image"); s.scale.setTo(0.75,0.75); s.angle=180 / s.rotation=3.141 s.x += 10; s.y -= 10; s.animations.play("walk",fps); game.physics.arcade.enable(s); ROME 11-12 april 2014 – Valerio Riva What sprites can do ROME 11-12 april 2014 – Valerio Riva 13
  • 14. Group of sprites • Use it as z-ordered layer • Use it for fast pooling and object recycling too • Can apply transformation to all sprites of the group • Can call methods on all sprites of the group var group = game.add.group(); var sprite = group.create(x, y, 'image'); group.x += 100; group.callAll('kill'); var zombie = group.getFirstExists(false); zombie.revive(); //cured! ROME 11-12 april 2014 – Valerio Riva 14
  • 15. Tilesprite “A tilesprite is a sprite that has a repeating texture.” var tilesprite = game.add.tileSprite(0, 0, 32, 64, 'image'); • texture can be scrolled tilesprite.tilePosition.setTo(10,20); • texture can be scaled tilesprite.tileScale.setTo(1.5,1.5); ROME 11-12 april 2014 – Valerio Riva 15
  • 16. Tilemap ROME 11-12 april 2014 – Valerio Riva 16
  • 17. Tilemap A tilemap is a map composed by a fixed number of same sized sprites (tiles) • Each tile can have different behavior • Used to create platform and map based games • Can be orthogonal or isometric • Easy to create with Tiled (http://www.mapeditor.org/) ROME 11-12 april 2014 – Valerio Riva 17
  • 18. Tilemap function preload() { game.load.tilemap('codem', 'tilemap/codem.json', n ull, Phaser.Tilemap.TILED_JSON); game.load.image('block', 'sprites/block.gif'); } function create() { map = game.add.tilemap("codem"); map.addTilesetImage("block"); map.setCollisionByExclusion([]); layer = map.createLayer("codemotion"); layer.resizeWorld(); } ROME 11-12 april 2014 – Valerio Riva 18
  • 19. Collision “A collision is an instance of one moving object touching another.” • Both object must have a “body” (collider) • Object can be a sprite or a tilemap or even a group! • A body can be a rectangle, a circle or a polygon • Bodies can have a lot of properties (mass, gravity, velocity, material, …) • Last two statements depends on what physics engine you are using. • More complex is the engine, more computation is needed. Choose wisely! ROME 11-12 april 2014 – Valerio Riva 19
  • 20. Collision function create() { game.physics.startSystem(Phaser.Physics.ARCADE); sprite = game.add.sprite(0, 0, 'image'); game.physics.enable(sprite, Phaser.Physics.ARCADE); sprite.body.collideWorldBounds = true; sprite.body.bounce.set(1); } function update() { game.physics.arcade.collide(sprite, [tilemap, group], function(sprite, other) { … }); } ROME 11-12 april 2014 – Valerio Riva 20
  • 21. Input Phaser supports natively • Keyboard • Mouse • Multi-touch • Gamepads (up to four, each one with 10 axis and 16 buttons) • Supports even Xbox 360 gamepad! (button mapping depends on browser : ) ROME 11-12 april 2014 – Valerio Riva 21
  • 22. Input: Keyboard function update() { if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) { ufo.y -= 10; } else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { ufo.y += 10; } if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { ufo.x -= 10; } else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { ufo.x += 10; } } ROME 11-12 april 2014 – Valerio Riva 22
  • 23. Input: Mouse if (game.input.mousePointer.isDown) { if (game.input.mousePointer.x < game.width*0.5) { clickOnLeft = true; } else if (game.input.mousePointer.x > game.width*0.5) { clickOnRight = true; } if (game.input.mousePointer.y < game.height*0.5) { clickOnTop = true; } } • Swap mousePointer with activePointer to capture any active pointer (works with mouse and touch inputs) ROME 11-12 april 2014 – Valerio Riva 23
  • 24. Input: Multi-touch • Supports 10 pointers (= fingers)! • Two pointers are already available • Add another pointer game.input.addPointer(); • Read different pointers game.input.pointer3; or game.input.pointer4; ROME 11-12 april 2014 – Valerio Riva 24
  • 25. Input: Gamepad function create() { game.input.gamepad.start(); pad1 = game.input.gamepad.pad1; } function update() { if (game.input.gamepad.supported && game.input.gamepad.active && pad1.connected) { //play with gamepad! if (pad1.isDown(Phaser.Gamepad.XBOX360_DPAD_LEFT)) { … } if (pad1.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_X)) { … } if (pad1.justPressed(Phaser.Gamepad.XBOX360_A)) { … } } else { //play with boring keyboard! } } ROME 11-12 april 2014 – Valerio Riva 25
  • 26. Dissecting the mummy ROME 11-12 april 2014 – Valerio Riva 26
  • 27. Want more? • Take a look to another example that implements P2 physics engine (http://github.com/Lotti/phaserTut) • Phaser examples (http://examples.phaser.io/) • Phaser docs (http://docs.phaser.io/) ROME 11-12 april 2014 – Valerio Riva 27
  • 28. Resources & Links • The mummy game • P2 physics engine example • Phaser’s forum • http://docs.phaser.io • http://examples.phaser.io • http://html5gameengine.com • http://brackets.io • http://www.pixijs.com • http://schteppe.github.io/p2.js • http://www.mapeditor.org • http://xdk-software.intel.com • https://www.ludei.com/cocoonjs • https://cordova.apache.org • http://phonegap.com ROME 11-12 april 2014 – Valerio Riva 28
  • 29. Thank you! Any Questions? ROME 11-12 april 2014 – Valerio Riva 29 valerio.riva@gmail.com @ValerioRiva http://it.linkedin.com/in/valerioriva/