diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-21 02:14:30 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-21 02:14:30 +0200 |
commit | 3c6e4a47af54f59425d04b35ab93a2ebf04ba0bf (patch) | |
tree | c938ff5917c7c2d66945660e949795ae86377e16 | |
parent | 79b8fb11967aa1637e0a0bfaeafab2d77f83ca82 (diff) |
Added boundary tests to Player::update.
Also upgraded the awesome player texture with a hitbox!
-rw-r--r-- | player.cpp | 5 | ||||
-rw-r--r-- | textures/player.png | bin | 799 -> 1172 bytes |
2 files changed, 3 insertions, 2 deletions
@@ -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 Binary files differindex 2c21d21..33e9154 100644 --- a/textures/player.png +++ b/textures/player.png |