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
|
#pragma once
#include<vector>
#include "Collision.h"
class CObject
{
CObject(float w, float h, float x, float y)
: width(w), height(h), startx(x), starty(y), collision(startx, starty, w, h)
{
object = sf::Shape::Rectangle(0, 0, w, h, sf::Color(100, 100, 100));
object.SetPosition(startx, starty);
objects.push_back(this);
}
CObject(float w, float h, float x, float y, unsigned short r, unsigned short g, unsigned short b)
: width(w), height(h), startx(x), starty(y), collision(startx, starty, w, h)
{
object = sf::Shape::Rectangle(0, 0, w, h, sf::Color(r, g, b));
object.SetPosition(startx, starty);
objects.push_back(this);
}
static std::vector<CObject*> objects;
protected:
float width;
float height;
float startx;
float starty;
colRegion collision;
sf::Shape object;
};
std::vector<CObject*> CObject::objects;
|