-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.h
More file actions
32 lines (28 loc) · 967 Bytes
/
player.h
File metadata and controls
32 lines (28 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <SFML/Graphics.hpp>
#include <iostream>
class Player : private sf::Sprite
{
private:
int speedx_; // Only horizontal speed/movement
int fixedy_; // Fixed y-coordinate of player/spaceship
sf::Keyboard::Key left_key_;
sf::Keyboard::Key right_key_;
public:
// Constructor
Player(sf::Texture &player_texture, sf::Vector2i windowSize);
// Setter for speed
void setSpeed(int speedx);
// Setters for left and right key
void setLeftkey(sf::Keyboard::Key key);
void setRightkey(sf::Keyboard::Key key);
// Draw on window
void drawPlayer(sf::RenderWindow &window);
// Move Player
void movePlayer(sf::Time elapsed, sf::Keyboard::Key key, sf::Vector2i windowSize, bool side_teleport);
// Getter for position
sf::Vector2f getPlayerPosition();
private:
// Move Player to exact bounds when outside Window
void exact_bounds(sf::FloatRect player_bounds, sf::Vector2i windowSize);
};