Add misc and sfml modules with initial implementations, including new classes, assets, and CMake integration.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by David Hackbarth on 27.02.26.
|
||||
//
|
||||
|
||||
#include "Ball.h"
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Created by David Hackbarth on 27.02.26.
|
||||
//
|
||||
|
||||
#ifndef CMAKESFMLPROJECT_BALL_H
|
||||
#define CMAKESFMLPROJECT_BALL_H
|
||||
|
||||
|
||||
class Ball {
|
||||
};
|
||||
|
||||
|
||||
#endif //CMAKESFMLPROJECT_BALL_H
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Created by David Hackbarth on 27.02.26.
|
||||
//
|
||||
|
||||
#include "Paddle.h"
|
||||
|
||||
Paddle::Paddle(sf::Keyboard::Key upKey, sf::Keyboard::Key downKey) : _shape(sf::Vector2f(20, 100)), _upKey(upKey),
|
||||
_downKey(downKey) {
|
||||
_shape.setFillColor(sf::Color::White);
|
||||
}
|
||||
|
||||
void Paddle::Update(float dt) {
|
||||
if (sf::Keyboard::isKeyPressed(_upKey)) {
|
||||
_shape.move(sf::Vector2f(0, -100 * dt));
|
||||
}
|
||||
if (sf::Keyboard::isKeyPressed(_downKey)) {
|
||||
_shape.move(sf::Vector2f(0, 100 * dt));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by David Hackbarth on 27.02.26.
|
||||
//
|
||||
|
||||
#ifndef CMAKESFMLPROJECT_PADDLE_H
|
||||
#define CMAKESFMLPROJECT_PADDLE_H
|
||||
#include "SFML/Graphics/RectangleShape.hpp"
|
||||
#include "SFML/Window/Keyboard.hpp"
|
||||
|
||||
class Paddle {
|
||||
public:
|
||||
Paddle(sf::Keyboard::Key upKey, sf::Keyboard::Key downKey);
|
||||
|
||||
sf::RectangleShape& getShape() { return _shape; }
|
||||
|
||||
void Update(float dt);
|
||||
|
||||
private:
|
||||
sf::RectangleShape _shape;
|
||||
sf::Keyboard::Key _upKey;
|
||||
sf::Keyboard::Key _downKey;
|
||||
};
|
||||
|
||||
|
||||
#endif //CMAKESFMLPROJECT_PADDLE_H
|
||||
Reference in New Issue
Block a user