Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new example0.html which tries to get something working with as little…
… code as possible
- Loading branch information
ippa
committed
Sep 4, 2011
1 parent
2c4170d
commit b25cea9
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../jaws.js"></script> | ||
<link type="text/css" rel="stylesheet" href="style.css" /> | ||
<title>Jaws Example #12 - As minimalistic as JawsJS can get</title> | ||
</head> | ||
<body> | ||
<div id="info"> | ||
As minimalistic a Jaws-game can get, have jaws.start() autocreate a canvas. | ||
Also skip wrapping setup, update & draw in a function or object. | ||
This makes Jaws look for them in the global window-object. | ||
</div> | ||
|
||
<script> | ||
function setup() { | ||
player = new jaws.Sprite({image: "plane.png", x: jaws.width/2, y:jaws.height/2, anchor: "center"}) | ||
jaws.preventDefaultKeys(["up", "down", "left", "right"]) | ||
} | ||
|
||
function update() { | ||
if(jaws.pressed("left")) { player.x -= 2 } | ||
if(jaws.pressed("right")) { player.x += 2 } | ||
if(jaws.pressed("up")) { player.y -= 2 } | ||
if(jaws.pressed("down")) { player.y += 2 } | ||
} | ||
|
||
function draw() { | ||
jaws.clear() | ||
player.draw() | ||
} | ||
|
||
// Looks for <canvas> or <div id="canvas"> to draw on. Creates <canvas> if niether is found. | ||
// Then load predined-assets, call setup(), then loop update() and draw() in 60 FPS. | ||
jaws.start() | ||
</script> | ||
|
||
</body> | ||
</html> | ||
|