SlideShare a Scribd company logo
Html5 Game + Websocket + Arduino
Andrea D’Ippolito + Giuseppe Modarelli
Phaser.io 101
Javascript Game Development Engine
Phaser.io
var game = new Phaser.Game(1200, 600, Phaser.AUTO);
game.state.add('boot', BootState);
game.state.add('preload', PreloadState);
game.state.add('menu', MenuState);
game.state.add('play', PlayState);
game.state.add('finish', FinishState);
game.state.start('boot');
Phaser.io
{
preload: function() {
...
},
create: function() {
...
},
update: function() {
...
}
}
Phaser.io
{
preload: function() {
...
this.load.image('sky', 'assets/sky.png');
this.load.image('cloud1', 'assets/cloud1.png');
this.load.image('cloud2', 'assets/cloud2.png');
this.load.image('ground', 'assets/ground.png');
this.load.image('home', 'assets/home.png');
this.load.image('startButton', 'assets/start.png');
this.load.spritesheet('monk', 'assets/monk.png', 80, 103);
...
},
create: function() {
...
},
update: function() {
...
}
}
credits: Emanuela Oliva. emanuelaoliva.com
Phaser.io
{
preload: function() {
...
},
create: function() {
...
this.player = this.game.add.sprite(560, this.game.world.height - 150, 'monk');
this.game.physics.arcade.enable(this.player);
this.player.body.bounce.y = 0.35;
this.player.body.gravity.y = -15;
this.player.body.collideWorldBounds = true;
this.player.animations.add('left', [3, 4], 10, true);
this.player.animations.add('right', [0, 1], 10, true);
this.cursors = this.game.input.keyboard.createCursorKeys();
this.game.camera.follow(this.player);
...
},
update: function() {
...
}
}
Phaser.io
{
preload: function() {
...
},
create: function() {
...
},
update: function() {
...
if (this.cursors.left.isDown) {
this.player.animations.play('left');
this.player.body.velocity.x = -75;
} else if (this.cursors.right.isDown) {
this.player.animations.play('right');
this.player.body.velocity.y = 75;
} else {
this.player.animations.stop();
this.player.frame = 2;
}
...
}
}
Socket.io 101
Websocket connection for real time pub/sub messaging
Socket.io
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
io.on('connection', function(socket) {
socket.on('controls', function(msg) {
socket.broadcast.emit(msg);
});
socket.on('finish', function(msg) {
socket.broadcast.emit('you won');
});
socket.on('controller', function(msg) {
socket.broadcast.emit('controller connected', msg);
});
});
http.listen(3000, function() {
console.log('Listening on port %d', http.address().port);
});
Socket.io
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
</head>
<body>
<button id="left">Turn Left</button><button id="right">Turn Right</button>
<script>
var socket = io();
socket.emit( 'controller', 'HTML5 Gamepad' );
$(function(){
$('#left').click(function() {
socket.emit( 'controls', 'turn left');
});
$('#right').click(function() {
socket.emit( 'controls', 'turn right');
});
});
socket.on( 'you won', function(mgs) {
window.location.href = 'http://www.wearemonk.com' ;
});
</script>
</body>
</html>
Phaser.io + Socket.io
{
preload: function() {
...
},
create: function() {
...
this.socket = io();
var self = this;
this.socket.on('turn left', function(msg) {
self.turnLeft();
});
this.socket.on('turn right', function(msg) {
self.turnRight();
});
...
},
update: function() {
...
}
}
Arduino 101
Sketch Arduino per accendere un led con un bottone
Arduino
Arduino
const int buttonPin = 3; // the number of the pushbutton pin
const int ledPin = 4; // the number of the LED pin
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
pinMode(ledPin, OUTPUT); // initialize the LED pin as an output:
pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input:
}
void loop(){
buttonState = digitalRead(buttonPin); //read the state of the pushbutton
value
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH); // turn LED on:
}
else {
digitalWrite(ledPin, LOW); // turn LED off:
}
}
Noduino 101
Come controllare Arduino con Javascript (grazie a node e websocket)
Accendere un led con bottone
Noduino
var requirejs = require('requirejs');
requirejs.config({nodeRequire: require});
requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial',
'../public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) {
var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
var led_4;
board.withLED({pin: 4}, function(err, LED) {
if (err) { return console.log(err); }
led_4 = LED;
led_4.on('on',function(){
setTimeout(function () {
led_4.setOff();
}, 250);
});
});
board.withButton({pin: 3}, function(err, Button) {
if (err) { return console.log(err); }
Button.on('push', function() {
console.log('Button pushed');
led_4.setOn();
});
});
});
});
Noduino
var requirejs = require('requirejs');
var socket = require('socket.io-client')('http://localhost:3000');
requirejs.config({nodeRequire: require});
requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '..
/public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) {
var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
var led_4;
board.withLED({pin: 4}, function(err, LED) {
if (err) { return console.log(err); }
led_4 = LED;
led_4.on('on',function(){
setTimeout(function () {
led_4.setOff();
}, 250);
});
});
board.withButton({pin: 3}, function(err, Button) {
if (err) { return console.log(err); }
Button.on('push', function() {
console.log('Button pushed');
led_4.setOn();
socket.emit('controls','turn left');
});
});
});
});
Noduino
var requirejs = require('requirejs');
var socket = require('socket.io-client')('http://localhost:3000');
requirejs.config({nodeRequire: require});
requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '..
/public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) {
var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
var led_4;
board.withLED({pin: 4}, function(err, LED) {
[...]
});
board.withButton({pin: 3}, function(err, Button) {
if (err) { return console.log(err); }
Button.on('push', function() {
console.log('Button pushed');
led_4.setOn();
socket.emit('controls','turn left');
});
});
socket.on('you won', function(msg){
console.log("YOU WON");
setInterval(function () {
led_7.blink(250);
led_4.blink(250);
}, 500);
});
});
});
Noduino
var requirejs = require('requirejs');
var socket = require('socket.io-client')('http://localhost:3000');
requirejs.config({nodeRequire: require});
requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '..
/public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) {
var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
var board_serial = board.c.boards[0].serial.path;
socket.emit('controller','Arduino: '+board_serial);
var led_4;
board.withLED({pin: 4}, function(err, LED) {
[...]
});
board.withButton({pin: 3}, function(err, Button) {
if (err) { return console.log(err); }
Button.on('push', function() {
console.log('Button pushed');
led_4.setOn();
socket.emit('controls','turn left');
});
});
socket.on('you won', function(msg){
[...]
});
});
});
recap @ wcap
● 404 Game: http://bit.ly/rescuemonk
● Noduino Gamepad: http://bit.ly/noduino-gamepad
● Phaser.io: http://phaser.io
● Socket.io: http://socket.io/
● Arduino: www.arduino.cc
○ Button: http://arduino.cc/en/tutorial/button
● Noduino: http://semu.github.io/noduino/
● Andrea: @adedip / andreadippolito.it
● Giuseppe: @gmodarelli / gmodarelli.com
www.monksoftware.it
info@monksoftware.it
Twitter: @monksoftwareit
Facebook: MONKSoftwareIT
Roma
Via Tirone 11, 00146
+39 06 99291819
Kraków
ul. Rakowicka 11, 30-033
+48 888 565 545

More Related Content

What's hot

The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212
Mahmoud Samir Fayed
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
Eric Basile
 
Gabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirGabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of Elixir
Codemotion
 
Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0
Leszek Godlewski
 
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31
Mahmoud Samir Fayed
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1boedax
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31
Mahmoud Samir Fayed
 
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Chris Adamson
 
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202
Mahmoud Samir Fayed
 
Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇
Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇
Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇
Johnny Sung
 
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Pujana Paliyawan
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
Thierry Wasylczenko
 
Flow of events during Media Player creation in Android
Flow of events during Media Player creation in AndroidFlow of events during Media Player creation in Android
Flow of events during Media Player creation in Android
Somenath Mukhopadhyay
 
DAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of thingsDAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of things
Jan Jongboom
 
67WS Seminar Event
67WS Seminar Event67WS Seminar Event
67WS Seminar Event
Shigeru Kobayashi
 
First meet with Android Auto
First meet with Android AutoFirst meet with Android Auto
First meet with Android Auto
Johnny Sung
 
The Ring programming language version 1.9 book - Part 80 of 210
The Ring programming language version 1.9 book - Part 80 of 210The Ring programming language version 1.9 book - Part 80 of 210
The Ring programming language version 1.9 book - Part 80 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 87 of 185
The Ring programming language version 1.5.4 book - Part 87 of 185The Ring programming language version 1.5.4 book - Part 87 of 185
The Ring programming language version 1.5.4 book - Part 87 of 185
Mahmoud Samir Fayed
 

What's hot (20)

The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
 
Gabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirGabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of Elixir
 
Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0
 
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31
 
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
Core Audio in iOS 6 (CocoaConf Chicago, March 2013)
 
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202
 
Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇
Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇
Everything About Bluetooth (淺談藍牙 4.0) - Peripheral 篇
 
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
 
Introduction to JavaFX 2
Introduction to JavaFX 2Introduction to JavaFX 2
Introduction to JavaFX 2
 
Ubiquitous Language
Ubiquitous LanguageUbiquitous Language
Ubiquitous Language
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Flow of events during Media Player creation in Android
Flow of events during Media Player creation in AndroidFlow of events during Media Player creation in Android
Flow of events during Media Player creation in Android
 
DAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of thingsDAHO.AM 2015 - Abusing phones to make the internet of things
DAHO.AM 2015 - Abusing phones to make the internet of things
 
67WS Seminar Event
67WS Seminar Event67WS Seminar Event
67WS Seminar Event
 
First meet with Android Auto
First meet with Android AutoFirst meet with Android Auto
First meet with Android Auto
 
The Ring programming language version 1.9 book - Part 80 of 210
The Ring programming language version 1.9 book - Part 80 of 210The Ring programming language version 1.9 book - Part 80 of 210
The Ring programming language version 1.9 book - Part 80 of 210
 
The Ring programming language version 1.5.4 book - Part 87 of 185
The Ring programming language version 1.5.4 book - Part 87 of 185The Ring programming language version 1.5.4 book - Part 87 of 185
The Ring programming language version 1.5.4 book - Part 87 of 185
 

Viewers also liked

HTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesignerHTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesigner
Matteo Magni
 
SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...
SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...
SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...
Roberto Ellero
 
Introduzione a Twitter Bootstrap
Introduzione a Twitter BootstrapIntroduzione a Twitter Bootstrap
Introduzione a Twitter Bootstrap
Giulio Bonanome
 
Html5 - Un anno dopo
Html5 - Un anno dopoHtml5 - Un anno dopo
Html5 - Un anno dopo
Cristiano Rastelli
 
HTML5 e Css3 - 4 | WebMaster & WebDesigner
HTML5 e Css3 - 4 | WebMaster & WebDesignerHTML5 e Css3 - 4 | WebMaster & WebDesigner
HTML5 e Css3 - 4 | WebMaster & WebDesigner
Matteo Magni
 
HTML5 Security
HTML5 SecurityHTML5 Security
HTML5 Security
Simone Onofri
 
HTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesignerHTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesigner
Matteo Magni
 
Laboratorio di Web Design Base - 2014/15 - HTML/5
Laboratorio di Web Design Base - 2014/15 - HTML/5Laboratorio di Web Design Base - 2014/15 - HTML/5
Laboratorio di Web Design Base - 2014/15 - HTML/5
Giovanni Buffa
 
Introduzione a jQuery
Introduzione a jQueryIntroduzione a jQuery
Introduzione a jQuerySandro Marcon
 
Html e Css - 3 | WebMaster & WebDesigner
Html e Css - 3 | WebMaster & WebDesignerHtml e Css - 3 | WebMaster & WebDesigner
Html e Css - 3 | WebMaster & WebDesigner
Matteo Magni
 
Html5 e css3 nuovi strumenti per un nuovo web
Html5 e css3 nuovi strumenti per un nuovo webHtml5 e css3 nuovi strumenti per un nuovo web
Html5 e css3 nuovi strumenti per un nuovo web
Massimo Bonanni
 
HTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesignerHTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesigner
Matteo Magni
 
follow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQueryfollow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQueryQIRIS
 
HTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare OggiHTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare Oggi
SkillsAndMore
 
Ancora anatomia, le pagine HTML(5)
Ancora anatomia, le pagine HTML(5)Ancora anatomia, le pagine HTML(5)
Ancora anatomia, le pagine HTML(5)
nois3lab
 
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore RomeoHTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
marcocasario
 

Viewers also liked (20)

HTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesignerHTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesigner
 
SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...
SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...
SMAU 2009 - Scenari futuri del Video-on-the-Web in HTML 5 - Roberto Ellero, ...
 
Introduzione a Twitter Bootstrap
Introduzione a Twitter BootstrapIntroduzione a Twitter Bootstrap
Introduzione a Twitter Bootstrap
 
Html5 - Un anno dopo
Html5 - Un anno dopoHtml5 - Un anno dopo
Html5 - Un anno dopo
 
HTML5 e Css3 - 4 | WebMaster & WebDesigner
HTML5 e Css3 - 4 | WebMaster & WebDesignerHTML5 e Css3 - 4 | WebMaster & WebDesigner
HTML5 e Css3 - 4 | WebMaster & WebDesigner
 
Responsive design
Responsive designResponsive design
Responsive design
 
Domino e HTML5, #dd13
Domino e HTML5, #dd13Domino e HTML5, #dd13
Domino e HTML5, #dd13
 
HTML5 Security
HTML5 SecurityHTML5 Security
HTML5 Security
 
HTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesignerHTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesigner
 
Laboratorio di Web Design Base - 2014/15 - HTML/5
Laboratorio di Web Design Base - 2014/15 - HTML/5Laboratorio di Web Design Base - 2014/15 - HTML/5
Laboratorio di Web Design Base - 2014/15 - HTML/5
 
Introduzione a jQuery
Introduzione a jQueryIntroduzione a jQuery
Introduzione a jQuery
 
Html5
Html5Html5
Html5
 
Html e Css - 3 | WebMaster & WebDesigner
Html e Css - 3 | WebMaster & WebDesignerHtml e Css - 3 | WebMaster & WebDesigner
Html e Css - 3 | WebMaster & WebDesigner
 
Html5 e css3 nuovi strumenti per un nuovo web
Html5 e css3 nuovi strumenti per un nuovo webHtml5 e css3 nuovi strumenti per un nuovo web
Html5 e css3 nuovi strumenti per un nuovo web
 
HTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesignerHTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesigner
 
follow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQueryfollow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQuery
 
HTML 5 e browser legacy
HTML 5 e browser legacyHTML 5 e browser legacy
HTML 5 e browser legacy
 
HTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare OggiHTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare Oggi
 
Ancora anatomia, le pagine HTML(5)
Ancora anatomia, le pagine HTML(5)Ancora anatomia, le pagine HTML(5)
Ancora anatomia, le pagine HTML(5)
 
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore RomeoHTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
 

Similar to Html5 game, websocket e arduino

Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
udit652068
 
Need help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdfNeed help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdf
hainesburchett26321
 
[가상편] 하드웨어에 생명을 주는 아두이노
[가상편] 하드웨어에 생명을 주는 아두이노[가상편] 하드웨어에 생명을 주는 아두이노
[가상편] 하드웨어에 생명을 주는 아두이노
Chiwon Song
 
robotics presentation for a club you run
robotics presentation for a club you runrobotics presentation for a club you run
robotics presentation for a club you run
SunilAcharya37
 
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
DroidConTLV
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
Fernando Daciuk
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
Sarwan Singh
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi and
Kellyn Pot'Vin-Gorman
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
archanaemporium
 
Lab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docxLab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docx
DIPESH30
 
This is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdfThis is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdf
anjandavid
 
Praktek ARDUINO
Praktek ARDUINOPraktek ARDUINO
Praktek ARDUINO
Dedi Supardi
 
Arduino Boot Camp Pitch Slides
Arduino Boot Camp Pitch SlidesArduino Boot Camp Pitch Slides
Arduino Boot Camp Pitch Slides
Mithi Sevilla
 
Fabric robots
Fabric robotsFabric robots
Fabric robots
Endian Neo
 
Gatcha for developers
Gatcha for developersGatcha for developers
Gatcha for developers
Pieter De Schepper
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
Steven Foote
 
S Console, Multi-Screen and Group Play
S Console, Multi-Screen and Group PlayS Console, Multi-Screen and Group Play
S Console, Multi-Screen and Group Play
Kyuho Kim
 

Similar to Html5 game, websocket e arduino (20)

Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
Need help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdfNeed help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdf
 
[가상편] 하드웨어에 생명을 주는 아두이노
[가상편] 하드웨어에 생명을 주는 아두이노[가상편] 하드웨어에 생명을 주는 아두이노
[가상편] 하드웨어에 생명을 주는 아두이노
 
Arduino Workshop 2011.05.31
Arduino Workshop 2011.05.31Arduino Workshop 2011.05.31
Arduino Workshop 2011.05.31
 
robotics presentation for a club you run
robotics presentation for a club you runrobotics presentation for a club you run
robotics presentation for a club you run
 
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi and
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
 
Lab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docxLab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docx
 
Arduino
ArduinoArduino
Arduino
 
This is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdfThis is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdf
 
Praktek ARDUINO
Praktek ARDUINOPraktek ARDUINO
Praktek ARDUINO
 
Arduino Boot Camp Pitch Slides
Arduino Boot Camp Pitch SlidesArduino Boot Camp Pitch Slides
Arduino Boot Camp Pitch Slides
 
R tist
R tistR tist
R tist
 
Fabric robots
Fabric robotsFabric robots
Fabric robots
 
Gatcha for developers
Gatcha for developersGatcha for developers
Gatcha for developers
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
 
S Console, Multi-Screen and Group Play
S Console, Multi-Screen and Group PlayS Console, Multi-Screen and Group Play
S Console, Multi-Screen and Group Play
 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 

Html5 game, websocket e arduino

  • 1. Html5 Game + Websocket + Arduino Andrea D’Ippolito + Giuseppe Modarelli
  • 2.
  • 3. Phaser.io 101 Javascript Game Development Engine
  • 4. Phaser.io var game = new Phaser.Game(1200, 600, Phaser.AUTO); game.state.add('boot', BootState); game.state.add('preload', PreloadState); game.state.add('menu', MenuState); game.state.add('play', PlayState); game.state.add('finish', FinishState); game.state.start('boot');
  • 5. Phaser.io { preload: function() { ... }, create: function() { ... }, update: function() { ... } }
  • 6. Phaser.io { preload: function() { ... this.load.image('sky', 'assets/sky.png'); this.load.image('cloud1', 'assets/cloud1.png'); this.load.image('cloud2', 'assets/cloud2.png'); this.load.image('ground', 'assets/ground.png'); this.load.image('home', 'assets/home.png'); this.load.image('startButton', 'assets/start.png'); this.load.spritesheet('monk', 'assets/monk.png', 80, 103); ... }, create: function() { ... }, update: function() { ... } }
  • 7. credits: Emanuela Oliva. emanuelaoliva.com
  • 8. Phaser.io { preload: function() { ... }, create: function() { ... this.player = this.game.add.sprite(560, this.game.world.height - 150, 'monk'); this.game.physics.arcade.enable(this.player); this.player.body.bounce.y = 0.35; this.player.body.gravity.y = -15; this.player.body.collideWorldBounds = true; this.player.animations.add('left', [3, 4], 10, true); this.player.animations.add('right', [0, 1], 10, true); this.cursors = this.game.input.keyboard.createCursorKeys(); this.game.camera.follow(this.player); ... }, update: function() { ... } }
  • 9. Phaser.io { preload: function() { ... }, create: function() { ... }, update: function() { ... if (this.cursors.left.isDown) { this.player.animations.play('left'); this.player.body.velocity.x = -75; } else if (this.cursors.right.isDown) { this.player.animations.play('right'); this.player.body.velocity.y = 75; } else { this.player.animations.stop(); this.player.frame = 2; } ... } }
  • 10. Socket.io 101 Websocket connection for real time pub/sub messaging
  • 11. Socket.io var express = require('express'); var app = express(); var http = require('http').Server(app); var io = require('socket.io')(http); io.on('connection', function(socket) { socket.on('controls', function(msg) { socket.broadcast.emit(msg); }); socket.on('finish', function(msg) { socket.broadcast.emit('you won'); }); socket.on('controller', function(msg) { socket.broadcast.emit('controller connected', msg); }); }); http.listen(3000, function() { console.log('Listening on port %d', http.address().port); });
  • 12. Socket.io <!doctype html> <html lang="en"> <head> <script type="text/javascript" src="/socket.io/socket.io.js"></script> </head> <body> <button id="left">Turn Left</button><button id="right">Turn Right</button> <script> var socket = io(); socket.emit( 'controller', 'HTML5 Gamepad' ); $(function(){ $('#left').click(function() { socket.emit( 'controls', 'turn left'); }); $('#right').click(function() { socket.emit( 'controls', 'turn right'); }); }); socket.on( 'you won', function(mgs) { window.location.href = 'http://www.wearemonk.com' ; }); </script> </body> </html>
  • 13. Phaser.io + Socket.io { preload: function() { ... }, create: function() { ... this.socket = io(); var self = this; this.socket.on('turn left', function(msg) { self.turnLeft(); }); this.socket.on('turn right', function(msg) { self.turnRight(); }); ... }, update: function() { ... } }
  • 14. Arduino 101 Sketch Arduino per accendere un led con un bottone
  • 16. Arduino const int buttonPin = 3; // the number of the pushbutton pin const int ledPin = 4; // the number of the LED pin int buttonState = 0; // variable for reading the pushbutton status void setup() { pinMode(ledPin, OUTPUT); // initialize the LED pin as an output: pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input: } void loop(){ buttonState = digitalRead(buttonPin); //read the state of the pushbutton value // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); // turn LED on: } else { digitalWrite(ledPin, LOW); // turn LED off: } }
  • 17. Noduino 101 Come controllare Arduino con Javascript (grazie a node e websocket) Accendere un led con bottone
  • 18. Noduino var requirejs = require('requirejs'); requirejs.config({nodeRequire: require}); requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '../public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) { var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger); Noduino.connect(function(err, board) { if (err) { return console.log(err); } var led_4; board.withLED({pin: 4}, function(err, LED) { if (err) { return console.log(err); } led_4 = LED; led_4.on('on',function(){ setTimeout(function () { led_4.setOff(); }, 250); }); }); board.withButton({pin: 3}, function(err, Button) { if (err) { return console.log(err); } Button.on('push', function() { console.log('Button pushed'); led_4.setOn(); }); }); }); });
  • 19. Noduino var requirejs = require('requirejs'); var socket = require('socket.io-client')('http://localhost:3000'); requirejs.config({nodeRequire: require}); requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '.. /public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) { var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger); Noduino.connect(function(err, board) { if (err) { return console.log(err); } var led_4; board.withLED({pin: 4}, function(err, LED) { if (err) { return console.log(err); } led_4 = LED; led_4.on('on',function(){ setTimeout(function () { led_4.setOff(); }, 250); }); }); board.withButton({pin: 3}, function(err, Button) { if (err) { return console.log(err); } Button.on('push', function() { console.log('Button pushed'); led_4.setOn(); socket.emit('controls','turn left'); }); }); }); });
  • 20. Noduino var requirejs = require('requirejs'); var socket = require('socket.io-client')('http://localhost:3000'); requirejs.config({nodeRequire: require}); requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '.. /public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) { var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger); Noduino.connect(function(err, board) { if (err) { return console.log(err); } var led_4; board.withLED({pin: 4}, function(err, LED) { [...] }); board.withButton({pin: 3}, function(err, Button) { if (err) { return console.log(err); } Button.on('push', function() { console.log('Button pushed'); led_4.setOn(); socket.emit('controls','turn left'); }); }); socket.on('you won', function(msg){ console.log("YOU WON"); setInterval(function () { led_7.blink(250); led_4.blink(250); }, 500); }); }); });
  • 21. Noduino var requirejs = require('requirejs'); var socket = require('socket.io-client')('http://localhost:3000'); requirejs.config({nodeRequire: require}); requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '.. /public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) { var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger); Noduino.connect(function(err, board) { if (err) { return console.log(err); } var board_serial = board.c.boards[0].serial.path; socket.emit('controller','Arduino: '+board_serial); var led_4; board.withLED({pin: 4}, function(err, LED) { [...] }); board.withButton({pin: 3}, function(err, Button) { if (err) { return console.log(err); } Button.on('push', function() { console.log('Button pushed'); led_4.setOn(); socket.emit('controls','turn left'); }); }); socket.on('you won', function(msg){ [...] }); }); });
  • 22. recap @ wcap ● 404 Game: http://bit.ly/rescuemonk ● Noduino Gamepad: http://bit.ly/noduino-gamepad ● Phaser.io: http://phaser.io ● Socket.io: http://socket.io/ ● Arduino: www.arduino.cc ○ Button: http://arduino.cc/en/tutorial/button ● Noduino: http://semu.github.io/noduino/ ● Andrea: @adedip / andreadippolito.it ● Giuseppe: @gmodarelli / gmodarelli.com
  • 23. www.monksoftware.it info@monksoftware.it Twitter: @monksoftwareit Facebook: MONKSoftwareIT Roma Via Tirone 11, 00146 +39 06 99291819 Kraków ul. Rakowicka 11, 30-033 +48 888 565 545