class Moving_object : public Object
{
public:
+ Moving_object() = default;
+ ~Moving_object() = default;
protected:
private:
};
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:
};
#include "Player.h"
-Player::Player() : Object(), collected(0)
+Player::Player() : collected{0}
{
texture.loadFromFile("assets/4V_figur.png");
sprite.setTexture(texture);
#include <SFML/Graphics.hpp>
#include "Moving_object.h"
-#include "Object.h"
#include "constants.h"
-class Player : public Object
+class Player : public Moving_object
{
public:
Player();
* All spelkod bör köras från denna fil och denna fil enbart.
*/
-#include <SFML/Graphics.hpp> // includes most things in SFML
-#include "constants.h"
+#include <SFML/Graphics.hpp>
+#include "constants.h"
#include "Player.h"
int main ()