55 lines
1013 B
C
55 lines
1013 B
C
#pragma once
|
|
#include <SFML/Graphics.hpp>
|
|
#include <SFML/Graphics/Rect.hpp>
|
|
#include <SFML/System/Vector2.hpp>
|
|
|
|
struct Entity {
|
|
sf::Vector2f position;
|
|
float speed;
|
|
sf::Vector2f direction;
|
|
sf::Vector2f velocity;
|
|
|
|
virtual void update(sf::Time delta) = 0;
|
|
void set_position(sf::Vector2f new_pos);
|
|
void set_size(sf::Vector2f new_size);
|
|
};
|
|
|
|
|
|
struct Player {
|
|
const float START_SPEED = 200;
|
|
const float START_HEALTH = 100;
|
|
|
|
sf::Vector2f position;
|
|
sf::Sprite sprite;
|
|
sf::Texture texture;
|
|
sf::Vector2f resolution;
|
|
sf::IntRect arena;
|
|
int tile_size;
|
|
|
|
bool up_pressed;
|
|
bool down_pressed;
|
|
bool left_pressed;
|
|
bool right_pressed;
|
|
|
|
int health;
|
|
int max_health;
|
|
sf::Time last_hit;
|
|
float speed;
|
|
|
|
Player();
|
|
|
|
void spawn(sf::IntRect arena, sf::Vector2f resolution, int tile_size);
|
|
|
|
void reset();
|
|
|
|
bool hit(sf::Time time_hit);
|
|
|
|
void update(float delta, sf::Vector2i mouse_position);
|
|
|
|
void upgrade_speed();
|
|
|
|
void upgrade_health();
|
|
|
|
void increase_health_level(int amount);
|
|
};
|