Skip to content

Instantly share code, notes, and snippets.

Created July 21, 2012 04:18
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
<!DOCTYPE html>
<html lang='en'>
<script src=''></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=""></script>
<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 = ""
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);
<center><canvas class="game" width="800" height="800" style="border:1px solid"></canvas></center>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment