From a8de6cb5593e3d6347393eb4c144c9cc22a470d8 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 19 May 2018 15:15:20 +0100 Subject: Moving resources and generalising examples --- examples/shooter/player.cpp | 72 --------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 examples/shooter/player.cpp (limited to 'examples/shooter/player.cpp') diff --git a/examples/shooter/player.cpp b/examples/shooter/player.cpp deleted file mode 100644 index dab743a9..00000000 --- a/examples/shooter/player.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "player.h" - -Player::Player(const glm::vec4 &bound, const yage::Texture &texture) - : bound_(bound), texture_(texture), direction_(Direction::DOWN), - action_(Action::IDLE), speed_(4) -{ -} - -void Player::setTexture(const yage::Texture &texture) { - texture_ = texture; -} - -void Player::draw(yage::SpriteBatch &sp) -{ - static int time = 0; - static int iteration = 0; - float width = 1.f / static_cast(texture_.x); - float height = 1.f / static_cast(texture_.y); - - switch (action_) { - case Action::IDLE: - sp.draw(bound_, - {width, static_cast(direction_) * height, width, height}, - texture_.id, yage::Colour(255, 255, 255, 255), 1); - break; - case Action::MOVING: - if(time % 15 == 0) { - iteration = (iteration + 1) % 2; - } - sp.draw(bound_, - {iteration * 2 * width, static_cast(direction_) * height, width, height}, - texture_.id, yage::Colour(255, 255, 255, 255), 1); - time = (time + 1) % 59; - break; - } -} - -void Player::move(Direction direction) -{ - direction_ = direction; - action_ = Action::MOVING; - - switch (direction_) { - case Direction::LEFT: - bound_.x -= speed_; - break; - case Direction::DOWN: - bound_.y -= speed_; - break; - case Direction::RIGHT: - bound_.x += speed_; - break; - case Direction::UP: - bound_.y += speed_; - break; - } -} - -void Player::idle() -{ - action_ = Action::IDLE; -} - -void Player::look(Direction direction) -{ - direction_ = direction; -} - -glm::vec4 Player::position() const -{ - return bound_; -} -- cgit