From 29168e06ffcea8b8f55a9ed2e8acb3529e776456 Mon Sep 17 00:00:00 2001 From: tom Date: Thu, 30 Apr 2015 22:53:59 -0500 Subject: added creature and resource classes --- src/creature.cpp | 8 ++++++++ src/creature.h | 12 ++++++++++++ src/entity.cpp | 7 ------- src/entity.h | 1 - src/main.cpp | 6 ++++-- src/main.h | 2 ++ src/resource.cpp | 8 ++++++++ src/resource.h | 12 ++++++++++++ 8 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 src/creature.cpp create mode 100644 src/creature.h create mode 100644 src/resource.cpp create mode 100644 src/resource.h (limited to 'src') diff --git a/src/creature.cpp b/src/creature.cpp new file mode 100644 index 0000000..c96785e --- /dev/null +++ b/src/creature.cpp @@ -0,0 +1,8 @@ +#include "creature.h" + +Creature::Creature(Window m, std::string s) +{ + texture = loadTexture(s, m); + renderer = m.getRenderer(); + x=y=500; +} diff --git a/src/creature.h b/src/creature.h new file mode 100644 index 0000000..5f5bb8d --- /dev/null +++ b/src/creature.h @@ -0,0 +1,12 @@ +#ifndef creature_h +#define creature_h + +#include "entity.h" + +class Creature: public Entity +{ + public: + Creature(Window m, std::string s); +}; + +#endif diff --git a/src/entity.cpp b/src/entity.cpp index 5533975..03accd9 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -1,12 +1,5 @@ #include "entity.h" -Entity::Entity(Window m, std::string s) -{ - texture = loadTexture(s, m); - renderer = m.getRenderer(); - x=y=200; -} - void Entity::Place() { SDL_Rect rect = {x, y, width/8, height/8}; diff --git a/src/entity.h b/src/entity.h index 1d1f876..1d16a2c 100644 --- a/src/entity.h +++ b/src/entity.h @@ -6,7 +6,6 @@ class Entity { public: - Entity(Window m, std::string s); void Place(); SDL_Texture* loadTexture(std::string path, Window main); diff --git a/src/main.cpp b/src/main.cpp index 5ab78b3..88a34dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,8 @@ int main() { Window main; - Entity ship(main, "images/basic.png"); + Creature testcreature(main, "images/Cbasic.png"); + Resource testresource(main, "images/Rbasic.png"); Event e; while(e.gRun()) @@ -16,7 +17,8 @@ int main() // eventHandle(e.gEvent()); } main.Clear(); - ship.Place(); + testcreature.Place(); + testresource.Place(); main.Render(); } diff --git a/src/main.h b/src/main.h index 9a1a64d..d026886 100644 --- a/src/main.h +++ b/src/main.h @@ -4,5 +4,7 @@ #include "window.h" #include "entity.h" #include "event.h" +#include "creature.h" +#include "resource.h" #endif diff --git a/src/resource.cpp b/src/resource.cpp new file mode 100644 index 0000000..06c7a04 --- /dev/null +++ b/src/resource.cpp @@ -0,0 +1,8 @@ +#include "resource.h" + +Resource::Resource(Window m, std::string s) +{ + texture = loadTexture(s, m); + renderer = m.getRenderer(); + x=y=300; +} diff --git a/src/resource.h b/src/resource.h new file mode 100644 index 0000000..463f355 --- /dev/null +++ b/src/resource.h @@ -0,0 +1,12 @@ +#ifndef resource_h +#define resource_h + +#include "entity.h" + +class Resource: public Entity +{ + public: + Resource(Window m, std::string s); +}; + +#endif -- cgit v1.2.3