Skip to content

Commit

Permalink
Merge branch 'develop' for release 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-hayward committed Jun 18, 2020
2 parents 86defa3 + f552131 commit 4bbc16a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ olc::AnimatedSprite sprite;
bool OnUserCreate()
{
// configure the sprite:
olc::Renderable spritesheet = new olc::Renderable();
spritesheet.Load("spritesheet.png");
sprite.mode = olc::AnimatedSprite::SPRITE_MODE::SINGLE; // set sprite to use a single spritesheet
sprite.spriteSheet = new olc::Renderable("spritesheet.png"); // define image to use for the spritesheet
sprite.spriteSheet = spritesheet; // define image to use for the spritesheet
sprite.SetSpriteSize({50, 50}); // define size of each sprite with an olc::vi2d
sprite.SetSpriteScale(2.0f); // define scale of sprite; 1.0f is original size. Must be above 0 and defaults to 1.0f

Expand Down
31 changes: 5 additions & 26 deletions olcPGEX_AnimatedSprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@

namespace olc
{
class Renderable
{
public:
Renderable() = default;
Renderable(std::string spriteLocation);
~Renderable();

public:
olc::Sprite* sprite = nullptr;
olc::Decal* decal = nullptr;
};

class AnimatedSprite : public olc::PGEX
{
public:
Expand Down Expand Up @@ -149,16 +137,6 @@ namespace olc

namespace olc
{
Renderable::Renderable(std::string spriteLocation) {
sprite = new Sprite(spriteLocation);
decal = new Decal(sprite);
}

Renderable::~Renderable() {
delete decal;
delete sprite;
}

olc::Sprite* AnimatedSprite::GetMultiFrame(float fElapsedTime)
{
frameTimer += fElapsedTime;
Expand Down Expand Up @@ -208,7 +186,7 @@ namespace olc
}
}

return multiRenderables[state][currentFrame]->decal;
return multiRenderables[state][currentFrame]->Decal();
}

olc::vi2d AnimatedSprite::GetSingleFrame(float fElapsedTime)
Expand Down Expand Up @@ -282,7 +260,8 @@ namespace olc
if (type == SPRITE_TYPE::SPRITE) {
multiFrames[stateName].push_back(new olc::Sprite(path));
} else {
multiRenderables[stateName].push_back(new Renderable(path));
multiRenderables[stateName].push_back(new Renderable());
multiRenderables[stateName].back()->Load(path);
}
}

Expand Down Expand Up @@ -335,9 +314,9 @@ namespace olc
}
else {
if (type == SPRITE_TYPE::SPRITE) {
pge->DrawPartialSprite(position, spriteSheet->sprite, GetSingleFrame(fElapsedTime), spriteSize, spriteScale, flip);
pge->DrawPartialSprite(position, spriteSheet->Sprite(), GetSingleFrame(fElapsedTime), spriteSize, spriteScale, flip);
} else {
pge->DrawPartialDecal(GetDecalPosition(position, flip), spriteSheet->decal, GetSingleFrame(fElapsedTime), spriteSize, GetDecalScale(flip), tint);
pge->DrawPartialDecal(GetDecalPosition(position, flip), spriteSheet->Decal(), GetSingleFrame(fElapsedTime), spriteSize, GetDecalScale(flip), tint);
}
}
}
Expand Down

0 comments on commit 4bbc16a

Please sign in to comment.