From 27c1130b06decb1728be5d6159bc7cfec605509a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nils=20Forss=C3=A9n?= Date: Thu, 9 Nov 2023 17:03:41 +0100 Subject: [PATCH] small changes --- src/Moving_object.h | 2 ++ src/Object.h | 12 +++++------- src/Player.cc | 2 +- src/Player.h | 3 +-- src/_main.cc | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Moving_object.h b/src/Moving_object.h index e20995e..959a195 100644 --- a/src/Moving_object.h +++ b/src/Moving_object.h @@ -6,6 +6,8 @@ class Moving_object : public Object { public: + Moving_object() = default; + ~Moving_object() = default; protected: private: }; diff --git a/src/Object.h b/src/Object.h index 2fe6023..80f1400 100644 --- a/src/Object.h +++ b/src/Object.h @@ -7,21 +7,19 @@ class Object { public: - Object() : x_pos(0), y_pos(0), sprite(), texture() {}; - + Object() : x_pos{0}, y_pos{0}, sprite{}, texture{} {}; + virtual ~Object() = default; + virtual bool collides(Object& other) = 0; virtual void collision(Object& other) = 0; virtual void update() = 0; virtual void render(sf::RenderWindow& window) = 0; - - virtual ~Object() = default; - + +protected: double x_pos; double y_pos; sf::Sprite sprite; sf::Texture texture; - -protected: private: }; diff --git a/src/Player.cc b/src/Player.cc index bee611c..ee8a77c 100644 --- a/src/Player.cc +++ b/src/Player.cc @@ -1,6 +1,6 @@ #include "Player.h" -Player::Player() : Object(), collected(0) +Player::Player() : collected{0} { texture.loadFromFile("assets/4V_figur.png"); sprite.setTexture(texture); diff --git a/src/Player.h b/src/Player.h index b4d8c20..05bb5ca 100644 --- a/src/Player.h +++ b/src/Player.h @@ -2,11 +2,10 @@ #include #include "Moving_object.h" -#include "Object.h" #include "constants.h" -class Player : public Object +class Player : public Moving_object { public: Player(); diff --git a/src/_main.cc b/src/_main.cc index 4c81ede..c248dd5 100644 --- a/src/_main.cc +++ b/src/_main.cc @@ -4,9 +4,9 @@ * All spelkod bör köras från denna fil och denna fil enbart. */ -#include // includes most things in SFML -#include "constants.h" +#include +#include "constants.h" #include "Player.h" int main () -- 2.30.2