Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major refactor of sprite.js, closing in on a final 0.1 API. New chain…
…able methods while still allowing use of fast variables in many cases. Bugfixes. Tons of new Sprite-tests, now over 110+ unittests. Quick Sprite API reference in README.
- Loading branch information
ippa
committed
Mar 23, 2011
1 parent
f9c6e12
commit 2fff8ce
Showing
6 changed files
with
678 additions
and
388 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
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,76 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../jaws.js"></script> | ||
<link type="text/css" rel="stylesheet" href="style.css" /> | ||
<title>Benchmark</title> | ||
<head> | ||
<body> | ||
|
||
<canvas width=500 height=300></canvas><br /> | ||
FPS: <span id="fps">0</span> | ||
|
||
<div id="info"> | ||
Sprites | ||
</div> | ||
|
||
<h3>jaws log</h3> | ||
<div id="jaws-log"></div> | ||
|
||
<script> | ||
var loop = 10000; | ||
var fps = document.getElementById("fps") | ||
var sprite, image, canvas, context | ||
|
||
function global_setup() { | ||
image = jaws.assets.get("plane.png") | ||
canvas = document.createElement("canvas") | ||
canvas.width = image.width | ||
canvas.height = image.height | ||
context = canvas.getContext("2d") | ||
context.drawImage(image, 0, 0) | ||
sprite = new jaws.Sprite({image: canvas, x:100, y:100, center: "center"}) | ||
} | ||
|
||
|
||
sprite.draw()function BenchSprite() { | ||
this.setup = function() { | ||
global_setup() | ||
} | ||
|
||
this.draw = function() { | ||
for(var i=0; i < loop; i++) { | ||
jaws.clear() | ||
sprite.draw() | ||
} | ||
fps.innerHTML = jaws.gameloop.fps | ||
} | ||
} | ||
|
||
/* --------------------------------------------------------- */ | ||
|
||
function BenchSprite2s() { | ||
var rotation = 0 | ||
this.setup = function() { | ||
global_setup() | ||
} | ||
|
||
this.draw = function() { | ||
for(var i=0; i < loop; i++) { | ||
jaws.clear() | ||
sprite.draw() | ||
} | ||
fps.innerHTML = jaws.gameloop.fps | ||
} | ||
} | ||
|
||
jaws.onload = function() { | ||
jaws.assets.add("plane.png") | ||
jaws.on_keydown("space", function() { jaws.switchGameState(BenchCanvas) }) | ||
jaws.on_keydown("esc", function() { jaws.gameloop.stop() }) | ||
jaws.start(BenchSprite, 200) // Try impossible framerate | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.