Code: Select all
import "ecere"
#define TILESIZE 72
BitmapResource tilesetGfx { ":Tileset.png" };
class TileObject
{
BitmapResource res;
void Render(Surface surface)
{
Bitmap bmp = res ? res.bitmap : null;
if(bmp)
{
surface.Blit(bmp, x, y, (frameStep * TILESIZE) + srcX, srcY, TILESIZE, TILESIZE);
}
if(Animate)
if(++frameStep >= numFrames) frameStep = 0;
}
public:
int x, y;
int srcX, srcY;
bool Animate;
int numFrames;
int tileType;
bool visited;
int dir[4];
int frameStep;
Uint32 curTime, lastTime;
}
class FloorObject : TileObject { res = tilesetGfx; srcX = 72; srcY = 0; }
class BushObject : TileObject { res = tilesetGfx; srcX = 0; srcY = 0; }
class ExitObject : TileObject { res = tilesetGfx; srcX = 144; srcY = 0; Animate = true; numFrames = 4; }
class GameWindow : Window
{
background = black;
clientSize = { 1024, 768 };
autoCreate = false;
BushObject bush {100, 100};
bool OnCreate()
{
return true;
}
bool OnLoadGraphics()
{
AddResource(tilesetGfx);
return true;
}
void OnUnloadGraphics()
{
RemoveResource(tilesetGfx);
}
void OnDestroy()
{
}
void OnRedraw(Surface surface)
{
bush.Render(surface);
}
bool OnKeyHit(Key key, unichar ch)
{
return true;
}
}