Games & Multiplayer
- for classic and mobile devices -
https://github.com/serbanghita/Responsive-Websites-presentation
Full list: html5index.org
* any editor with JavaScript code validation (eg. JSlint).
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d');
// Start drawing.
ctx.beginPath();
ctx.rect(188, 50, 200, 100);
ctx.fillStyle = 'yellow';
ctx.fill();
ctx.lineWidth = 7;
ctx.strokeStyle = 'black';
ctx.stroke();
var GameEngine = {
//...
loop: function(){
this.now = Date.now();
this.timeDiff = (this.now - this.then) / 1000; // 0.016
for(i in entities){
entities[i].draw();
}
window.requestAnimationFrame(function(){
GameEngine.loop();
});
}
// ...
};
window.localStorage
// Set
localStorage.setItem('name', 'Serban Ghita');
localStorage.setItem('position', JSON.stringify({x: 10, y: 10}));
// Get
localStorage.getItem('name');
JSON.parse(window.localStorage.getItem('position'));
// Delete
localStorage.removeItem('name');
var conn = new WebSocket("ws://server.com/chat");
conn.onmessage = function(msg) {
msgObj = JSON.parse(msg); // decode JSON into object
}
conn.onclose = function() { }
conn.send('Ce mai faci?');
Thank you!