-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.hpp
More file actions
38 lines (32 loc) · 1.16 KB
/
Config.hpp
File metadata and controls
38 lines (32 loc) · 1.16 KB
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
33
34
35
36
37
38
#pragma once
#include "Particle.hpp"
inline const int SCREEN_WIDTH = 896;
inline const int SCREEN_HEIGHT = 896;
struct InputState {
bool mouseHeld = false;
sf::Vector2f mousePos;
bool downPressed = false;
bool upPressed = false;
bool leftPressed = false;
bool rightPressed = false;
void update(sf::RenderWindow &window) {
mouseHeld = sf::Mouse::isButtonPressed(sf::Mouse::Left);
mousePos = static_cast<sf::Vector2f>(sf::Mouse::getPosition(window));
downPressed = sf::Keyboard::isKeyPressed(sf::Keyboard::Down);
leftPressed = sf::Keyboard::isKeyPressed(sf::Keyboard::Left);
rightPressed = sf::Keyboard::isKeyPressed(sf::Keyboard::Right);
upPressed = sf::Keyboard::isKeyPressed(sf::Keyboard::Up);
updateGravityIfNeeded();
}
void updateGravityIfNeeded() {
if (leftPressed) {
Particle::GRAVITY = {-100.f, 0.f};
} else if (downPressed) {
Particle::GRAVITY = {0.f, 100.f};
} else if (rightPressed) {
Particle::GRAVITY = {100.f, 0.f};
} else if (upPressed) {
Particle::GRAVITY = {0.f, -100.f};
}
}
};