Cedric just did an awesome presentation about Particles
so
I will NOT talk about Particles (or not so much)
There is Zillion of stores
- Intel - AppUp
- Google - Chrome Store
- Apple - WebApp Store
- Samsung - Bada HTML5 Store
- Orange - Le webstore (really :p)
- ...
But most HTML5 games (including mine) SUCKS
How to become an HTML5 GAME DEVELOPER?
(in 10 minutes)
- Check user INPUT
- ANIMATE your game
- RENDER your game
- GOTO 1
function run()
{
input();
animate();
render();
requestAnimFrame(run);
}
requestAnimFrame = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
window.setTimeout(callback, 1000/60);
};
})();
Game are Synchronous
Javascript is Asynchronous
<body
onkeydown='keyIsDown(event)'
onkeyup='keyIsUp(event)'>
var keyBoard =
{
left : 0,
right :0,
fire : 0
}
function keyIsDown(event)
{
if(event.keyCode == 65)
{
keyBoard.left = 1;
}
if(event.keyCode == 68)
{
keyBoard.right = 1;
}
if(event.keyCode == 32)
{
keyBoard.fire = 1;
}
}
function input()
{
if (keyBoard.left)
{
if (SHIP.X > 15)
{
SHIP.X -= 10;
}
}
(...)
}
- Animate Sprites
- Animate Particles
- Animate ???
Browser support up to 2000 Canvas 2d sprites.
Demo
{
X : 10,
Y : 10,
XB : 1,
YB : 1,
KEY : 3,
}
function animateBob(bob)
{
bob.KEY--;
if (bob.KEY == 0)
{
bob.KEY = 5;
bob.XB = (bob.XB + 1) % 3;
}
if (keyBoard.left)
{
bob.X++;
bob.YB = 1;
}
(...)
}
function renderBob(bob)
{
ctx.drawImage(
bobImage,
bob.XB * 48,
bob.YB * 64,
48,
64,
bob.X,
bob.Y,
48,
64
);
}
Browser support up to
5000
Draw operation by frame.
Demo
Use globalAlpha to draw less particles.
ctx.globalAlpha = 0.5;
If you need to draw a crazy amount of particles (~20k) use :
var imageData = ctx.getImageData();
And then get imageData data properties
var data = imageData.data;
You then get a RGBA image buffer.
It's easy, REALLY
Demo
Come to HTML5 Game Jam
(http://j.mp/HTML5GameJam2012)
10-12 February, Free 48 hours hackathon
We also seek sponsors / help for organisation