Created
July 21, 2012 04:18
-
-
Save NatashaTheRobot/3154555 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang='en'> | |
<head> | |
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> | |
<script type=text/javascript src="/game.js"></script> | |
<meta charset="UTF-8"> | |
<link rel="stylesheet" href="game.css"> | |
<!--[if lt IE 9]> | |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<script language=javascript> | |
$(function() { | |
var canvas = $(".game")[0]; | |
var context = canvas.getContext("2d"); | |
context.fillStyle = '#BADA55'; | |
context.fillRect (1,1, 50, 50); | |
var imageObj = new Image(); | |
imageObj.src = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/372541_3403944_806268154_q.jpg" | |
var x = 400 | |
var y = 400 | |
setInterval(function() { | |
context.drawImage(imageObj, x, y); | |
x += ((Math.floor(Math.random()*2)*2)-1)*50 | |
y += ((Math.floor(Math.random()*2)*2)-1)*50 | |
}, 100); | |
}); | |
</script> | |
</head> | |
<body> | |
<center><canvas class="game" width="800" height="800" style="border:1px solid"></canvas></center> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment