commit 82eb573ef8564720e20c608823b2d67b4b7dc40a Author: Bartłomiej Pluta Date: Wed May 18 00:01:11 2016 +0200 Inicjalizacja projektu. diff --git a/inc/def.hh b/inc/def.hh new file mode 100644 index 0000000..5815f48 --- /dev/null +++ b/inc/def.hh @@ -0,0 +1,14 @@ +#ifndef DEF_HH +#define DEF_HH + +#include + +/* Plik zawiera definicje stałych globalnych oraz przedefiniowanie istniejących typów. */ + +// Długość boku pojedynczego kafelka(który jest kwadratem) +const int TILE_SIZE = 64; + +// Przedefiniowanie sf::Vector2f na RealVector +typedef sf::Vector2f RealVector; + +#endif diff --git a/inc/misc.hh b/inc/misc.hh new file mode 100644 index 0000000..c0c7e2a --- /dev/null +++ b/inc/misc.hh @@ -0,0 +1,38 @@ +#ifndef MISC_HH +#define MISC_HH + +#include + +#include "def.hh" + +/* Struktura reprezentująca wektor w układzie odniesienia planszy do gier (a nie według rzeczywistych współrzędnych - pikseli). */ +struct Vector +{ + unsigned int x; + unsigned int y; + + // Konstruktor tworzący parę (_x, _y) + Vector(unsigned int _x, unsigned int _y) : x(_x), y(_y) {} + + // Konstruktor tworzący parę (x, y) na podstawie rzeczywistych współrzędnych + Vector(const RealVector& real_position) : x(real_position.x/TILE_SIZE), y(real_position.y/TILE_SIZE) {} + + // Pobierz rzeczywistą pozycję górnego, lewego narożnika kafelka o współrzędnych (x, y) + RealVector getRealVector() const { return RealVector(x*TILE_SIZE, y*TILE_SIZE); } + + // Pobierz rzeczywistą pozycję środka kafelka o współrzędnych (x, y) + RealVector getCenterRealVector() const { return RealVector(x*TILE_SIZE + 0.5*TILE_SIZE, y*TILE_SIZE + 0.5*TILE_SIZE); } + + // Operator dodawania wektorów + Vector operator+(const Vector& v) { return Vector(x+v.x, y+v.y); } + + // Operator odejmowania wektorów + Vector operator-(const Vector& v) { return Vector(x-v.x, y-v.y); } + + // Mnożenie wektora przez liczbę + Vector operator*(int a) { return Vector(a*v.x, a*v.y); } + Vector operator*(float a) { return Vector(a*v.x, a*v.y); } + +}; + +#endif diff --git a/inc/object.hh b/inc/object.hh new file mode 100644 index 0000000..3fdd55b --- /dev/null +++ b/inc/object.hh @@ -0,0 +1,36 @@ +#ifndef OBJECT_HH +#define OBJECT_HH + +/* Klasa object będąca interfejsem po którym dziedziczą pionki. + * Klasa ta deklaruje podstawowe elementy obiektów znajdujących się + * na planszy, takie jak wyświetlanie, przesuwanie czy odczytywanie pozycji. + * Nie definiuje ona jeszcze żadnych kształtów czy kolorów, jest więc zatem klasą + * w zasadzie czysto abstrakcyjną. */ + +#include + +#include "def.hh" +#include "misc.hh" + +class Object +{ +private: + + // Pozycja obiektu + Vector position; +public: + + // Pobierz pozycję obiektu + Vector getPosition() const { return position; } + + // Ustaw pozycję obiektu + void setPosition(const Vector& _position) { position = _position } + + // Przesuń obiekt o wektor + void move(const Vector& vector) {} + + // Rysuj obiekt + void draw(sf::RenderWindow window) = 0; +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..2c49a87 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,10 @@ +#include +#include + +#include "../inc/def.hh" +#include "../inc/misc.hh" + +int main() +{ + return 0; +}