Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: digitaltom/jump-run
base: c3b605472a
...
head fork: digitaltom/jump-run
compare: 9ce1ca1f91
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 26, 2012
@digitaltom Revert "use requestAnimFrame"
This reverts commit 89610cc.
cfbeac0
Commits on Dec 27, 2012
@digitaltom add geeko animation 9ce1ca1
View
35 js/game.js
@@ -26,7 +26,7 @@ var collisionMap;
// fps measurement
var filterStrength = 20;
-var frameTime = 0, lastLoop = new Date, thisLoop, current_fps = 0;
+var frameTime = 0, lastLoop = new Date, thisLoop;
// speed, gravity parameters
@@ -575,7 +575,7 @@ function drawControls() {
}
ctx.fillText("Scroll: " + Math.round(scroll_x) + "px - tile#: " + Math.round(scroll_x / size.tile.target.w), size.tile.target.w, size.tile.target.h + 40);
ctx.fillText("Objects: " + (collisionMap.length + items.length), size.tile.target.w, size.tile.target.h + 60);
- ctx.fillText("Fps: " + current_fps, size.tile.target.w, size.tile.target.h + 80)
+ ctx.fillText("Fps: " + (1000 / frameTime).toFixed(1), size.tile.target.w, size.tile.target.h + 80)
}
ctx.font = 'bold 14px sans-serif'
ctx.fillText("Score: " + score, size.tile.target.w, size.tile.target.h);
@@ -659,7 +659,6 @@ function gameLoop() {
ticks++;
var thisFrameTime = (thisLoop = new Date) - lastLoop;
frameTime += (thisFrameTime - frameTime) / filterStrength;
- current_fps = (1000 / frameTime).toFixed(1);
lastLoop = thisLoop;
drawLevel();
@@ -668,35 +667,12 @@ function gameLoop() {
drawActors();
drawElements();
drawControls();
-
- gameInterval = requestAnimFrame(gameLoop);
}
-requestAnimFrame = (function () {
- return window.requestAnimationFrame ||
- window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function (/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
- window.setTimeout(callback, 1000 / speed.fps);
- };
-})();
-
-window.cancelRequestAnimFrame = (function () {
- return window.cancelAnimationFrame ||
- window.webkitCancelRequestAnimationFrame ||
- window.mozCancelRequestAnimationFrame ||
- window.oCancelRequestAnimationFrame ||
- window.msCancelRequestAnimationFrame ||
- clearTimeout
-})();
-
-
function initGame() {
- cancelRequestAnimFrame(gameInterval)
+ window.clearInterval(gameInterval);
var canvas = document.getElementById("game");
ctx = canvas.getContext("2d");
@@ -734,11 +710,12 @@ function startGame() {
registerControls()
initializeLevel()
initializeTheme()
- cancelRequestAnimFrame(gameInterval)
- gameLoop();
+ window.clearInterval(gameInterval);
+ gameInterval = setInterval(gameLoop, 1000 / speed.fps);
}
function restartGame() {
+ window.clearInterval(gameInterval)
initGame()
startGame()
}
View
BIN  themes/super_mario/images/player_sprites.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/suse/images/player_sprites.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/suse/images/resources/geeko.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/suse/images/resources/geeko_32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/suse/images/resources/geeko_kawaii_thumb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  themes/suse/images/resources/player_sprites.xcf
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.