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 --- Makefile | 2 +- README.md | 2 +- images/Cbasic.png | Bin 0 -> 3081 bytes images/Rbasic.png | Bin 0 -> 1310 bytes images/basic.png | Bin 3081 -> 0 bytes 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 ++++++++++++ 13 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 images/Cbasic.png create mode 100644 images/Rbasic.png delete mode 100644 images/basic.png create mode 100644 src/creature.cpp create mode 100644 src/creature.h create mode 100644 src/resource.cpp create mode 100644 src/resource.h diff --git a/Makefile b/Makefile index 9f346de..369b090 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -OBJS = src/main.cpp src/window.cpp src/entity.cpp src/event.cpp +OBJS = src/main.cpp src/window.cpp src/entity.cpp src/event.cpp src/creature.cpp src/resource.cpp CC = g++ diff --git a/README.md b/README.md index 383e625..cfffeb3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Nature's Course - Tom Barrett +Nature's Course For librarys ~ sudo apt-get install libsdl* diff --git a/images/Cbasic.png b/images/Cbasic.png new file mode 100644 index 0000000..6d1f592 Binary files /dev/null and b/images/Cbasic.png differ diff --git a/images/Rbasic.png b/images/Rbasic.png new file mode 100644 index 0000000..9f668cf Binary files /dev/null and b/images/Rbasic.png differ diff --git a/images/basic.png b/images/basic.png deleted file mode 100644 index 6d1f592..0000000 Binary files a/images/basic.png and /dev/null differ 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