forked from jaildesigner-jailgames/jaildoctors_dilemma
Rehaciendo las clases Sprite y sus hijas
This commit is contained in:
63
source/item.cpp
Normal file
63
source/item.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "item.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
// Constructor
|
||||
Item::Item(SDL_Rect _rect, std::string _tileset, SDL_Renderer *_renderer, Asset *_asset)
|
||||
{
|
||||
// Obten punteros a objetos
|
||||
asset = _asset;
|
||||
renderer = _renderer;
|
||||
|
||||
// Crea objetos
|
||||
texture = new LTexture();
|
||||
sprite = new Sprite(_rect, texture, renderer);
|
||||
|
||||
// Carga la textura
|
||||
loadTextureFromFile(texture, asset->get(_tileset), renderer);
|
||||
|
||||
// Inicia variables
|
||||
sprite->setSpriteClip(0,0,8,8);
|
||||
|
||||
// Inicializa los colores
|
||||
color_t c = stringToColor("blue");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("red");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("purple");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("green");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("cyan");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("yellow");
|
||||
color.push_back(c);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Item::~Item()
|
||||
{
|
||||
texture->unload();
|
||||
delete texture;
|
||||
texture = nullptr;
|
||||
|
||||
delete sprite;
|
||||
sprite = nullptr;
|
||||
}
|
||||
|
||||
// Pinta el enemigo en pantalla
|
||||
void Item::draw()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void Item::update()
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user