summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-05-21 02:14:30 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-05-21 02:14:30 +0200
commit3c6e4a47af54f59425d04b35ab93a2ebf04ba0bf (patch)
treec938ff5917c7c2d66945660e949795ae86377e16
parent79b8fb11967aa1637e0a0bfaeafab2d77f83ca82 (diff)
Added boundary tests to Player::update.
Also upgraded the awesome player texture with a hitbox!
-rw-r--r--player.cpp5
-rw-r--r--textures/player.pngbin799 -> 1172 bytes
2 files changed, 3 insertions, 2 deletions
diff --git a/player.cpp b/player.cpp
index 0a7118a..2ab07de 100644
--- a/player.cpp
+++ b/player.cpp
@@ -8,6 +8,7 @@
#include "player.h"
#include "texturesdl.h"
+#include "config.h"
Player::Player() {
x = 0.5;
@@ -43,6 +44,6 @@ void Player::update() {
y_speed /= sqrtf(2);
}
- x += x_speed;
- y += y_speed;
+ x = fmaxf(fminf(x + x_speed, 1.0 - 16.0 / Config::viewport_w), 16.0 / Config::viewport_w);
+ y = fmaxf(fminf(y + y_speed, Config::viewport_aspect - 16.0 / Config::viewport_h), 16.0 / Config::viewport_h);
}
diff --git a/textures/player.png b/textures/player.png
index 2c21d21..33e9154 100644
--- a/textures/player.png
+++ b/textures/player.png
Binary files differ