Skip to content
Snippets Groups Projects
Commit e98bafb5 authored by KosmX's avatar KosmX
Browse files

some more code

moar code
parent b1452456
No related branches found
No related tags found
No related merge requests found
...@@ -149,6 +149,8 @@ ...@@ -149,6 +149,8 @@
<ClCompile Include="ResourceManager.cpp" /> <ClCompile Include="ResourceManager.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="olc.h" />
<ClInclude Include="ITexture.h" />
<ClInclude Include="Entity.h" /> <ClInclude Include="Entity.h" />
<ClInclude Include="interfaces.h" /> <ClInclude Include="interfaces.h" />
<ClInclude Include="LazySprite.h" /> <ClInclude Include="LazySprite.h" />
......
...@@ -59,5 +59,11 @@ ...@@ -59,5 +59,11 @@
<ClInclude Include="olcPixelGameEngine.h"> <ClInclude Include="olcPixelGameEngine.h">
<Filter>olc::PGE</Filter> <Filter>olc::PGE</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ITexture.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="olc.h">
<Filter>olc::PGE</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
include "AbstractTexture.h"
#include "Entity.h" #include "Entity.h"
namespace entities {
Entity::Entity(render::ITexture& texture, const olc::vf2d& pos)
:pos(pos), texture(texture)
{
}
Entity::~Entity()
{
delete &texture;
}
}
olc::TransformedView& operator+=(olc::TransformedView& scene, entities::Entity& entity) {
entity.render(scene);
return scene;
}
\ No newline at end of file
#pragma once #pragma once
#include "olc.h"
#include "ITexture.h"
namespace entities {
class Entity class Entity
{ {
private: protected:
olc::vf2d pos; //I can store these safely directly
render::ITexture& texture;
public:
Entity(render::ITexture& texture, const olc::vf2d& pos);
virtual olc::vf2d getPos() const;
virtual void tick(float deltaT);
//this shouldn't change it's state
virtual void render(olc::TransformedView& scene) const;
virtual ~Entity();
//TODO getAs*** stuff, all virtual
}; };
}
/**
* I literally add entities to the scene :D
*/
olc::TransformedView& operator+=(olc::TransformedView&, entities::Entity&);
\ No newline at end of file
#pragma once
#include "Entity.h"
#include "olcPGEX_TransformedView.h"
namespace render
{
class ITexture
{
public:
//Giving the entity will reduce the variables needed, and will make it's use more dynamic
virtual void render(olc::TransformedView& scene, Entity& entity) = 0;
virtual ~ITexture() = default;
};
}
...@@ -12,10 +12,15 @@ namespace render { ...@@ -12,10 +12,15 @@ namespace render {
} }
LazySprite::LazySprite(int u, int v, int sizeU, int sizeV) LazySprite::LazySprite(int u, int v, int sizeU, int sizeV)
: uv(u, v), size(sizeU, sizeV) : LazySprite(olc::vi2d(u, v), olc::vi2d(sizeU, sizeV))
{}
LazySprite::LazySprite(olc::vi2d pos, olc::vi2d size)
: uv(pos), size(size)
{ {
sprite = nullptr; sprite = nullptr;
} }
void LazySprite::render(olc::TransformedView& scene, olc::vf2d pos, olc::vf2d scale) void LazySprite::render(olc::TransformedView& scene, olc::vf2d pos, olc::vf2d scale)
{ {
scene.DrawPartialDecal(pos, this->getDecay(), uv, size, scale); scene.DrawPartialDecal(pos, this->getDecay(), uv, size, scale);
......
...@@ -25,7 +25,9 @@ namespace render { ...@@ -25,7 +25,9 @@ namespace render {
* u, v the texture coordinates on the image, * u, v the texture coordinates on the image,
* sizeU, V are the size of that sprite * sizeU, V are the size of that sprite
*/ */
LazySprite(int u, int v, int sizeU, int sizeV); LazySprite(int u, int v, int sizeU = 16, int sizeV = 16);
LazySprite(olc::vi2d pos, olc::vi2d size = olc::vi2d(16, 16));
/** /**
* Render the sprite in world-space * Render the sprite in world-space
......
olc.h 0 → 100644
#pragma once
#include "olcPGEX_TransformedView.h"
#include "olcPixelGameEngine.h"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment