Files
thepool/source/main.cpp

48 lines
1.3 KiB
C++

#include "jgame.h"
#include "jdraw.h"
#include "jinput.h"
#include <SDL2/SDL.h>
#include "actor.h"
draw::surface *surf;
actor::actor_t *box;
void game::init()
{
draw::init("The Pool", 320, 240, 3);
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) && 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)
{
for (int x=0;x<8;++x)
{
draw::draw(148+x*12-y*12,80+x*6+y*6,24,11,0,13);
}
}
actor::draw(actor::getFirst());
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
draw::render();
return true;
}