feat(laser): created laser object

Created laser object without any collision detection
This commit is contained in:
2024-01-09 12:26:42 +01:00
parent 0fed252afd
commit 9b0a7a78bb
10 changed files with 103 additions and 27 deletions
+20 -12
View File
@@ -1,19 +1,27 @@
#include "Inputs.h"
void Inputs::HandleInputs(Event& event) {
if (event.type == Event::Closed)
{
_window.close();
return;
void Inputs::HandleInputs() {
// Player movements
if (Keyboard::isKeyPressed(Keyboard::Left) || Keyboard::isKeyPressed(Keyboard::Q)) {
_player.move(-1);
}
// Player movements
if (event.type == Event::KeyPressed) {
if (event.key.code == Keyboard::Left || event.key.code == Keyboard::Q) {
_player.Move(-1);
}
if (event.key.code == Keyboard::Right || event.key.code == Keyboard::D) {
_player.Move(1);
if (Keyboard::isKeyPressed(Keyboard::Right) || Keyboard::isKeyPressed(Keyboard::D)) {
_player.move(1);
}
if (Keyboard::isKeyPressed(Keyboard::Space)) {
if (_clock.getElapsedTime().asMilliseconds() > 500) {
const Vector2f playerPos = _player.PlayerShape.getPosition();
const float playerRadius = _player.PlayerShape.getRadius();
Laser laser;
laser.setInitialPosition(Vector2f(playerPos.x + playerRadius, playerPos.y - playerRadius));
_lasers.push_back(laser.getLaser());
_clock.restart();
}
}
}