From 3c6e4a47af54f59425d04b35ab93a2ebf04ba0bf Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 21 May 2010 02:14:30 +0200 Subject: Added boundary tests to Player::update. Also upgraded the awesome player texture with a hitbox! --- player.cpp | 5 +++-- textures/player.png | Bin 799 -> 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 Binary files a/textures/player.png and b/textures/player.png differ -- cgit v1.2.3