Files
thepool/source/main.cpp

76 lines
2.1 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({16,16,0}, {8,8,8}, {32,0,32,32}, {0,32});
box->flags = FLAG_MOVING;// | FLAG_PUSHABLE;
box->movement = MOV_Z;
box->mov_push = PUSH_ZP;
actor::setDirty(box, true);
box = actor::create({32,32,16}, {8,8,8}, {32,0,32,32}, {0,32});
box->flags = FLAG_PUSHABLE;
box->movement = MOV_CW;
box->mov_push = PUSH_XN;
actor::setDirty(box, true);
box = actor::create({16,16,16}, {8,8,8}, {32,0,32,32}, {0,32});
box->flags = FLAG_HERO | FLAG_PUSHABLE;
actor::setDirty(box, true);
actor::reorder();
}
int sx=1, sy=0;
bool game::loop()
{
/*if (input::keyDown(SDL_SCANCODE_LEFT) && box->pos.x>0) {
box->pos.x--;
actor::actor_t *other = actor::get_collision(box);
if (other)
{
other->push |= 1;
box->pos.x++;
}
else
{
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); }
if (input::keyDown(SDL_SCANCODE_Z) && box->pos.z>0) { box->pos.z--; actor::setDirty(box); }
if (input::keyDown(SDL_SCANCODE_A) && box->pos.z<42) { box->pos.z++; actor::setDirty(box); }*/
actor::update(actor::getFirst());
actor::reorder();
draw::cls(8);
for (int y=0;y<8;++y)
{
for (int x=0;x<8;++x)
{
draw::draw(148+x*16-y*16,76+x*8+y*8,32,15,0,1);
}
}
actor::draw(actor::getFirst());
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
draw::render();
return true;
}