<script src='
http://www.gamemakersgarage.com/html5/jquery.min.js'></script>
<script src='
http://www.gamemakersgarage.com/html5/HTML5-Commands.js'></script>
<div style='text-align:center;'>
<div style='width:100%;height:100%'>
<canvas id='gameCanvas' width='500px' height='500px' style='cursor:default;outline: none;border:1px solid;border-color:#949494;position:relative;margin:auto;top:10px;background:transparent;'></canvas>
</div>
</div><script type='text/javascript'>
var g1Count = 1;
var g1Forward = true;
var g2Count = 1;
var g2Forward = true;
var g3Count = 1;
var g3Forward = true;
function Game_Open() {
LoadImage("t1");
LoadImage("t2");
LoadImage("t3");
CreateTimer("Guy 1", "Guy1Dance()", 0.05);
CreateTimer("Guy 2", "Guy2Dance()", 0.1);
CreateTimer("Guy 3", "Guy3Dance()", 0.2);
CreateTimer("Draw Timer", "Draw()", 1/60);
SetFillColor("Pink");
PlaySound("Music","MyBackgroundMusic",true);
}
function Key_Down() {
}
function Key_Up() {
}
function Mouse_Down() {
}
function Mouse_Up() {
}
function Mouse_Move() {
}
function Game_Close() {
}
function Guy1Dance() {
if ( g1Forward ) {
g1Count += 1;
}
if ( !g1Forward ) {
g1Count -= 1;
}
if ( g1Count > 3 ) {
g1Count = 3;
g1Forward = false;
}
if ( g1Count < 1 ) {
g1Count = 1;
g1Forward = true;
}
}
function Guy2Dance() {
if ( g2Forward ) {
g2Count += 1;
}
if ( !g2Forward ) {
g2Count -= 1;
}
if ( g2Count > 3 ) {
g2Count = 3;
g2Forward = false;
}
if ( g2Count < 1 ) {
g2Count = 1;
g2Forward = true;
}
}
function Guy3Dance() {
if ( g3Forward ) {
g3Count += 1;
}
if ( !g3Forward ) {
g3Count -= 1;
}
if ( g3Count > 3 ) {
g3Count = 3;
g3Forward = false;
}
if ( g3Count < 1 ) {
g3Count = 1;
g3Forward = true;
}
}
function Draw() {
ClearScreen();
if ( Random(0,100) == 5 ) {
SetFillColor("rgba("+Random(0,250)+","+Random(0,250)+","+Random(0,250)+","+250+")");
}
FillRect(0,0,500,500);
DrawImage("t"+g1Count,150,200,0);
DrawImage("t"+g2Count,250,400,0);
DrawImage("t"+g3Count,350,200,0);
}
var canvas;
var imageArray = new Array();
imageArray["t1"]= "
http://gamemakersgarage.com/html5/Demo%20Images/timerDemo1.png";
imageArray["t2"]= "
http://gamemakersgarage.com/html5/Demo%20Images/timerDemo2.png";
imageArray["t3"]= "
http://gamemakersgarage.com/html5/Demo%20Images/timerDemo3.png";
var soundArray = new Array()
soundArray["Music"]= "
http://www.gamemakersgarage.com/html5/Demo Sounds/DanceDemo.mp3";
var context;
var mousePressed= false;
var lastKeyPressed = null;
var keyPressedArray = new Array();
for (i = 0; i < 300; i++) {keyPressedArray.push(false);}var mouseX = 0;
var mouseY = 0;
$('#gameCanvas').ready(function() {canvas = document.getElementById('gameCanvas');context = canvas.getContext('2d');prepareCommands();Game_Open();});
$('#gameCanvas').keydown(function(e){ lastKeyPressed = e.keyCode; keyPressedArray[lastKeyPressed] = true; Key_Down(); return false; });
$('#gameCanvas').keyup(function(e){ lastKeyPressed = e.keyCode; keyPressedArray[lastKeyPressed] = false; Key_Up(); return false; });
$('#gameCanvas').mousedown(function(e){ mouseX = getMousePos(canvas,e).x; mouseY = getMousePos(canvas,e).y; mousePressed = true; $(this).focus(); Mouse_Down(); return false; });
$(window).bind('mouseup',function(e){ mouseX = getMousePos(canvas,e).x; mouseY = getMousePos(canvas,e).y; mousePressed = false; Mouse_Up(); return false; });
$('#gameCanvas').mousemove(function(e){ mouseX = getMousePos(canvas,e).x; mouseY = getMousePos(canvas,e).y; Mouse_Move(); return false; });
$('#gameCanvas').attr('tabindex', '0');
jQuery('#gameCanvas').bind('beforeunload', function(){ Game_Close(); $(window).unbind('mouseup');})</script>