Skip to content
Browse files

better way to detect collission sprite

  • Loading branch information...
1 parent 8acfb62 commit 9be89cfd54ff5b31a6d808379e7bb462c9c31f6c @digitaltom committed Dec 28, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −2 js/game.js
  2. +0 −1 js/level_methods.js
View
4 js/game.js
@@ -341,8 +341,8 @@ function updateElements() {
}
sprite_bottom = getLevelSpriteXY(item.x + size.tile.target.w / 2, item.y + size.tile.target.h)
// turn around on collide or above edge
- if (['z', 'x', 'a', 's', '#', 'H'].indexOf(sprite_collide) >= 0 ||
- ['z', 'x', '#', '?', 'ß'].indexOf(sprite_bottom) < 0 || item.x <= 0) {
+ if ((blocks[sprite_collide] && blocks[sprite_collide].collide) ||
+ (!blocks[sprite_bottom] || !blocks[sprite_bottom].collide) || item.x <= 0) {
item.speed_x *= -1
}
item.x += item.speed_x
View
1 js/level_methods.js
@@ -16,7 +16,6 @@ function getLevelSprite(pos, line) {
return current_level.level[line].charAt(pos);
}
-
var blocks = {};
blocks['#'] = {sx: 5, sy: 0, collide: true};
blocks['x'] = {sx: 0, sy: 0, collide: true};

0 comments on commit 9be89cf

Please sign in to comment.
Something went wrong with that request. Please try again.