Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Phaser HTML5 Game Framework @ Otomat Hackaton
Search
Eralp Karaduman
November 19, 2016
Programming
0
160
Phaser HTML5 Game Framework @ Otomat Hackaton
Slides from the lightning talk I gave, at awesome
http://otomat.org
hackaton.
Eralp Karaduman
November 19, 2016
Tweet
Share
Other Decks in Programming
See All in Programming
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.4k
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
220
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1k
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
CSC307 Lecture 09
javiergs
PRO
1
840
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
120
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
200
CSC307 Lecture 02
javiergs
PRO
1
780
Patterns of Patterns
denyspoltorak
0
1.4k
Featured
See All Featured
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
100
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
430
Docker and Python
trallard
47
3.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
54
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
220
Become a Pro
speakerdeck
PRO
31
5.8k
A designer walks into a library…
pauljervisheath
210
24k
Tell your own story through comics
letsgokoyo
1
810
The Limits of Empathy - UXLibs8
cassininazir
1
220
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
66
Transcript
PHASER HTML5 GAME FRAMEWORK
ERALP KARADUMAN SUPER DAMAGE GAMES
None
None
None
None
None
None
GLOBAL GAME JAM LUDUM DARE ITCH.IO
None
GAME FRAMEWORK?
RENDERING SCALING PARTICLES
TILEMAPS TIMERS TWEENS
ANIMATION SPRITES INPUT TEXT
PHYSICS AUDIO CANVAS / WEBGL
None
INDEX.HTML <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>try-phaser</title> <link
rel="stylesheet" href="/main.css" media="all"> </head> <body> <div id="content"></div> <script src="/bin/phaser.min.js"></script> <script src="/bin/bundle.js"></script> </body> </html>
MAIN.JS new Phaser.Game(800, 600, Phaser.AUTO, 'content', null);
MAIN.JS var bootState = require("./bootState"); var game = new Phaser.Game(800,
600, Phaser.AUTO, 'content', null); game.state.add('boot', bootState); game.state.start('boot');
MAIN.JS var bootState = require("./bootState"); var loadState = require("./loadState"); var
introState = require("./introState"); var gameState = require("./gameState"); var game = new Phaser.Game(800, 600, Phaser.AUTO, 'content', null); game.state.add('boot', bootState); game.state.add('load', loadState); game.state.add('intro', introState); game.state.add('game', gameState); game.state.start('boot');
BOOTSTATE.JS module.exports = { preload: function() { // load assets
} create: function() { // setup game // initiate player // initiate enemy game.state.start('load'); } update: function() { // handle input & move sprites & check collisions } }
INTROSTATE.JS module.exports = { create: function() { var logo =
this.add.sprite( this.world.centerX, this.world.centerY, 'logo' ); logo.anchor.setTo(0.5, 0.8); var button = this.add.button(this.world.centerX, 500, 'btn', function() { game.state.start('game'); }, this, 1, 0, 0); button.anchor.setTo(0.5, 0.5); } }
None
LOADSTATE.JS module.exports = { preload: function() { this.load.image('logo', 'phaser.png'); this.load.image('man-blue',
'man-blue.png'); this.load.image('man-red', 'man-red.png'); this.load.image('logo', 'phaser.png'); this.load.spritesheet('btn', 'btn-spritesheet.png', 288, 84); }, create: function() { this.state.start('intro'); } }
this.load.spritesheet( 'btn', 'btn-spritesheet.png', 288, 84 );
GAMESTATE.JS var Person = require('./person'); var input = {}; var
player = null function create() { var game = window.game; player = new Person(game, this.world.centerX, this.world.centerY); input.upKey = game.input.keyboard.addKey(Phaser.Keyboard.UP); input.downKey = game.input.keyboard.addKey(Phaser.Keyboard.DOWN); input.leftKey = game.input.keyboard.addKey(Phaser.Keyboard.LEFT); input.rightKey = game.input.keyboard.addKey(Phaser.Keyboard.RIGHT); } function update() { input.up = input.upKey.isDown; input.down = input.downKey.isDown; input.left = input.leftKey.isDown; input.right = input.rightKey.isDown; player.move(input); } module.exports = { create: create, update, update }
GAMESTATE.JS (CREATE) var input = {}; var player = null
function create() { var game = window.game; player = new Person(game, this.world.centerX, this.world.centerY); input.upKey = game.input.keyboard.addKey(Phaser.Keyboard.UP); input.downKey = game.input.keyboard.addKey(Phaser.Keyboard.DOWN); input.leftKey = game.input.keyboard.addKey(Phaser.Keyboard.LEFT); input.rightKey = game.input.keyboard.addKey(Phaser.Keyboard.RIGHT); }
GAMESTATE.JS (UPDATE) function update() { input.up = input.upKey.isDown; input.down =
input.downKey.isDown; input.left = input.leftKey.isDown; input.right = input.rightKey.isDown; player.move(input); }
PERSON.JS var Person = function(game, x, y) { this.moveSpeed =
5; Phaser.Sprite.call(this, game, x, y, 'man-blue'); this.anchor.setTo(0.5, 0.5); game.add.existing(this); } Person.prototype = Object.create(Phaser.Sprite.prototype); Person.prototype.constructor = Person; Person.prototype.update = function() { } Person.prototype.move = function(input) { // ... } module.exports = Person
PERSON.JS (MOVE) Person.prototype.move = function(input) { var pos = {y:
0, x: 0}; if (input.up) { pos.y = -1; } else if (input.down) { pos.y = 1; } if (input.left) { pos.x = -1; } else if (input.right) { pos.x = 1; } this.x += (pos.x * this.moveSpeed); this.y += (pos.y * this.moveSpeed); }
phaser.org ludumdare.com/compo/ itch.io/jams globalgamejam.org @superdamage superdamage.com eralpkaraduman.com @eralpkaraduman