summaryrefslogtreecommitdiff
path: root/src/entity.cpp
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-04-30 22:20:53 -0500
committertom <tom@ground-control>2015-04-30 22:20:53 -0500
commite1d75dfdf0727776adf0b3d44995ccf0e03487b3 (patch)
treef26074b8e9c598df33c66b1c57aad1e4dcd51f03 /src/entity.cpp
first commit
Diffstat (limited to 'src/entity.cpp')
-rw-r--r--src/entity.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
new file mode 100644
index 0000000..5533975
--- /dev/null
+++ b/src/entity.cpp
@@ -0,0 +1,25 @@
+#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};
+ SDL_RenderCopyEx(renderer,texture,NULL,&rect,degrees,NULL,SDL_FLIP_NONE);
+}
+
+SDL_Texture* Entity::loadTexture(std::string path, Window main)
+{
+ SDL_Surface* surface = IMG_Load(path.c_str());
+ SDL_SetColorKey(surface, SDL_TRUE, SDL_MapRGB(surface->format, 255, 255, 255));
+ height = surface->h;
+ width = surface->w;
+ SDL_Texture* texture = SDL_CreateTextureFromSurface(main.getRenderer(),surface);
+ SDL_FreeSurface(surface);
+ return texture;
+}