- Treballant en les colisions
This commit is contained in:
@@ -26,7 +26,20 @@ 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_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); }
|
||||
|
||||
Reference in New Issue
Block a user