diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-21 19:24:51 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-21 19:24:51 +0200 |
commit | 267bebfc227c94f543a39e2aa75fb101bc06932e (patch) | |
tree | 40ad8057634ba80aa19c61f57884982fd59f6b56 /player.cpp | |
parent | 88b1e9e505dad78fd2c3ff927495d322b11491ca (diff) |
Moved engine-sources to seperate subdirectory.
Diffstat (limited to 'player.cpp')
-rw-r--r-- | player.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/player.cpp b/player.cpp deleted file mode 100644 index 4a159ca..0000000 --- a/player.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef __APPLE__ -#include <GL/gl.h> -#else -#include <OpenGL/gl.h> -#endif -#include <cmath> -#include <SDL/SDL.h> - -#include "player.h" -#include "texturesdl.h" -#include "config.h" - -Player::Player() { - x = 0.5; - y = 0.1; - move_factor = 0.005; - focus_factor = 0.5; - texture = new TextureSDL("textures/player.png"); -} - -void Player::draw() { - glPointSize(32.0); - - glColor4f(1, 1, 1, 1); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture->tex()); - - glBegin(GL_POINTS); - glVertex2f(x, y); - glEnd(); - - glDisable(GL_TEXTURE_2D); -} - -void Player::update() { - Uint8 *keystate = SDL_GetKeyState(NULL); - float factor = move_factor * (SDL_GetModState() & KMOD_SHIFT ? focus_factor : 1); - - float x_speed = factor * keystate[SDLK_RIGHT] - factor * keystate[SDLK_LEFT]; - float y_speed = factor * keystate[SDLK_UP] - factor * keystate[SDLK_DOWN]; - - if(x_speed && y_speed) { - x_speed /= sqrtf(2); - y_speed /= sqrtf(2); - } - - x = fmaxf(fminf(x + x_speed, 1.0 - 0.018), 0.018); - y = fmaxf(fminf(y + y_speed, Config::viewport_aspect - 0.018), 0.018); -} |