added rest of basics in TSE_Core

This commit is contained in:
2026-01-17 21:06:02 +01:00
parent d09953f476
commit 117c1e6adb
27 changed files with 2908 additions and 9 deletions

View File

@@ -0,0 +1,35 @@
#include "TileSet.hpp"
#include "Debug.hpp"
#define PADDING 0.0f
TSE::TileSet::TileSet(Texture *tex, int x, int y)
{
SetTexture(tex);
SetCount(x,y);
}
void TSE::TileSet::SetCount(int x, int y)
{
resx = x;
resy = y;
}
void TSE::TileSet::SetTexture(Texture *tex)
{
this->tex = tex;
}
void TSE::TileSet::GetSpriteAt(int x, int y, Sprite &s)
{
if(x < 0 || x >= resx || y < 0 || y >= resy)
{
TSE_ERROR("The sprite you are trying to access is out of range");
return;
}
Vector2 startpos = Vector2(((tex->size().x / resx) * (x + PADDING)) / tex->size().x, ((tex->size().y / resy) * (y + PADDING)) / tex->size().y);
Vector2 endpos = Vector2(((tex->size().x / resx) * ((x + 1) - PADDING)) / tex->size().x, ((tex->size().y / resy) * ((y + 1) - PADDING)) / tex->size().y);
s = Sprite(tex, Rect(startpos, endpos));
}