Skip to content

Commit

Permalink
use default values for addSprite() arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
rktrlng committed Dec 10, 2020
1 parent 559df45 commit a4147b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 45 deletions.
56 changes: 22 additions & 34 deletions rt2d/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,40 +100,7 @@ void Entity::addSprite(Sprite* spr)
*_sprite = *spr;
}

void Entity::addDynamicSprite(PixelBuffer* pixels)
{
deleteSprite();
_sprite = new Sprite();
_sprite->setupSpriteByPixelBuffer(pixels);
}

void Entity::addSprite(const std::string& filename)
{
this->addSprite(filename, 0.5f, 0.5f);
}

void Entity::addCircleSprite(const std::string& filename, int radius, int segments)
{
deleteSprite();
_sprite = new Sprite();
_sprite->setupCircleSprite(filename, radius, segments);
}

void Entity::addSegmentSprite(const std::string& filename, int radius, int segments, int which)
{
deleteSprite();
_sprite = new Sprite();
_sprite->setupSegmentSprite(filename, radius, segments, which);
}

void Entity::addSprite(const std::string& filename, float pivotx, float pivoty)
{
deleteSprite();
_sprite = new Sprite();
_sprite->setupSprite(filename, pivotx, pivoty, 1.0f, 1.0f, DEFAULTFILTER, DEFAULTWRAP); // trilinear filter, mirror repeat
}

void Entity::addSprite(const std::string& filename, float pivotx, float pivoty, int filter, int wrap)
void Entity::addSprite(const std::string& filename, float pivotx /* 0.5f */, float pivoty /* 0.5f */, int filter /*DEFAULTFILTER*/, int wrap /*DEFAULTWRAP*/)
{
deleteSprite();
_sprite = new Sprite();
Expand Down Expand Up @@ -168,6 +135,27 @@ void Entity::addGrid(const std::string& filename, int u, int v, int cols, int ro
std::cout << "grid added: " << _spritebatch.size() << " sprites." << std::endl;
}

void Entity::addCircleSprite(const std::string& filename, int radius, int segments)
{
deleteSprite();
_sprite = new Sprite();
_sprite->setupCircleSprite(filename, radius, segments);
}

void Entity::addSegmentSprite(const std::string& filename, int radius, int segments, int which)
{
deleteSprite();
_sprite = new Sprite();
_sprite->setupSegmentSprite(filename, radius, segments, which);
}

void Entity::addDynamicSprite(PixelBuffer* pixels)
{
deleteSprite();
_sprite = new Sprite();
_sprite->setupSpriteByPixelBuffer(pixels);
}

// ############################################################
// Debug Draw
// ############################################################
Expand Down
12 changes: 1 addition & 11 deletions rt2d/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,14 @@ class Entity
/// @param spr A pointer to a Sprite.
/// @return void
void addSprite(Sprite* spr);
/// @brief add a Sprite to this Entity by filename.
/// @param filename The filename of the image you want to add as a Sprite.
/// @return void
void addSprite(const std::string& filename);
/// @brief add a Sprite to this Entity.
/// @param filename The filename of the image you want to add as a Sprite.
/// @param pivotx The x component of the pivotpoint.
/// @param pivoty The y component of the pivotpoint.
/// @return void
void addSprite(const std::string& filename, float pivotx, float pivoty);
/// @brief add a Sprite to this Entity.
/// @param filename The filename of the image you want to add as a Sprite.
/// @param pivotx The x component of the pivotpoint.
/// @param pivoty The y component of the pivotpoint.
/// @param filter The filter.
/// @param wrap The wrapping.
/// @return void
void addSprite(const std::string& filename, float pivotx, float pivoty, int filter, int wrap);
void addSprite(const std::string& filename, float pivotx = 0.5f, float pivoty = 0.5f, int filter = DEFAULTFILTER, int wrap = DEFAULTWRAP);
/// @brief add a SpriteSheet to this Entity.
/// @param filename The filename of the image you want to add as a SpriteSheet.
/// @param u number of horizontal textures
Expand Down

0 comments on commit a4147b0

Please sign in to comment.