- Treballant en la ordenació de actors

This commit is contained in:
2023-03-01 18:57:45 +01:00
parent f54e5ebef5
commit 195fb39210
9 changed files with 194 additions and 7 deletions

View File

@@ -2,8 +2,10 @@
#include "jdraw.h"
#include "jinput.h"
#include <SDL2/SDL.h>
#include "actor.h"
draw::surface *surf;
actor::actor_t *box;
void game::init()
{
@@ -11,14 +13,25 @@ void game::init()
surf = draw::loadSurface("test.gif");
draw::setSource(surf);
draw::loadPalette("test.gif");
game::setUpdateTicks(64);
box = actor::create({0,0,0}, {6,6,6}, {24,0,24,24}, {0,24});
actor::setDirty(box);
box = actor::create({6,0,0}, {6,6,6}, {24,0,24,24}, {0,24});
actor::setDirty(box);
actor::reorder();
}
int sx=1, sy=0;
bool game::loop()
{
if (input::keyDown(SDL_SCANCODE_LEFT)) sx++;
if (input::keyDown(SDL_SCANCODE_LEFT) && box->pos.x>0) { box->pos.x--; actor::setDirty(box); }
if (input::keyDown(SDL_SCANCODE_RIGHT) && box->pos.x<42) { box->pos.x++; actor::setDirty(box); }
if (input::keyDown(SDL_SCANCODE_UP) && box->pos.y>0) { box->pos.y--; actor::setDirty(box); }
if (input::keyDown(SDL_SCANCODE_DOWN) && box->pos.y<42) { box->pos.y++; actor::setDirty(box); }
actor::reorder();
draw::cls(8);
for (int y=0;y<8;++y)
{
@@ -27,7 +40,8 @@ bool game::loop()
draw::draw(148+x*12-y*12,80+x*6+y*6,24,11,0,13);
}
}
draw::draw(148+sx*2-sy*2, 68+sx+sy,24,24,24,0);
actor::draw(actor::getFirst());
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
draw::render();
return true;