Permalink
Browse files

Better bouncing image

  • Loading branch information...
1 parent f7b87fa commit f699bc5eca0a992becfcc0bf7fb1ca9c5cc96302 @kevmoo kevmoo committed Mar 13, 2011
Showing with 10 additions and 8 deletions.
  1. +5 −4 coffee/Application.coffee
  2. BIN images/pixellab_cropped.png
  3. +5 −4 js/Application.js
@@ -28,17 +28,18 @@ class Application
s = this._shape
if s.x < 0
this._dx = Application.delta
- else if s.x > (this.canvas.width - Application.imageSize)
+ else if s.x > (this.canvas.width - Application.imgWidth)
this._dx = -Application.delta
if s.y < 0
this._dy = Application.delta
- else if s.y > (this.canvas.height - Application.imageSize)
+ else if s.y > (this.canvas.height - Application.imgHeight)
this._dy = -Application.delta
s.x += this._dx
s.y += this._dy
this._stage.update();
box2d.Util.requestAnimFrame(goog.bind(this.tick, this));
-Application.imageSrc = '../images/pixellab.png'
-Application.imageSize = 192
+Application.imageSrc = '../images/pixellab_cropped.png'
+Application.imgWidth = 119
+Application.imgHeight = 95
Application.delta = 5
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -26,12 +26,12 @@ Application = (function() {
s = this._shape;
if (s.x < 0) {
this._dx = Application.delta;
- } else if (s.x > (this.canvas.width - Application.imageSize)) {
+ } else if (s.x > (this.canvas.width - Application.imgWidth)) {
this._dx = -Application.delta;
}
if (s.y < 0) {
this._dy = Application.delta;
- } else if (s.y > (this.canvas.height - Application.imageSize)) {
+ } else if (s.y > (this.canvas.height - Application.imgHeight)) {
this._dy = -Application.delta;
}
s.x += this._dx;
@@ -41,6 +41,7 @@ Application = (function() {
};
return Application;
})();
-Application.imageSrc = '../images/pixellab.png';
-Application.imageSize = 192;
+Application.imageSrc = '../images/pixellab_cropped.png';
+Application.imgWidth = 119;
+Application.imgHeight = 95;
Application.delta = 5;

0 comments on commit f699bc5

Please sign in to comment.