summaryrefslogtreecommitdiff
path: root/src/entity.cpp
blob: 55339758b78c416acf80d58ab54039bb14fea2a2 (plain)
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
#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;
}