- Comencem a treballar en les habitacions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "actor.h"
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include "room.h"
|
||||
|
||||
namespace actor
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace actor
|
||||
act->size = s;
|
||||
act->bmp_rect = r;
|
||||
act->bmp_offset = o;
|
||||
act->anim_cycle = 0;
|
||||
act->below = act->above = nullptr;
|
||||
act->prev = act->next = nullptr;
|
||||
return act;
|
||||
@@ -100,32 +102,23 @@ namespace actor
|
||||
|
||||
if (act1->pos.x >= act2->pos.x+act2->size.x) { return true; }
|
||||
else if (act2->pos.x >= act1->pos.x+act1->size.x) { return false; }
|
||||
|
||||
if (act1->pos.y >= act2->pos.y+act2->size.y) { return true; }
|
||||
else if (act1->pos.y >= act2->pos.y+act2->size.y) { return true; }
|
||||
else if (act2->pos.y >= act1->pos.y+act1->size.y) { return false; }
|
||||
|
||||
if (act1->pos.z >= act2->pos.z+act2->size.z) { return true; }
|
||||
else if (act1->pos.z >= act2->pos.z+act2->size.z) { return true; }
|
||||
else if (act2->pos.z >= act1->pos.z+act1->size.z) { return false; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
void reorder()
|
||||
{
|
||||
anim_frame=(anim_frame+1)%4;
|
||||
//dirty=first;
|
||||
//first=nullptr;
|
||||
while (dirty)
|
||||
{
|
||||
//const int z_index = dirty->pos.x + dirty->pos.y + dirty->pos.z;
|
||||
if (first)
|
||||
{
|
||||
actor_t *current = first;
|
||||
while (true)
|
||||
{
|
||||
//const int z_index2 = current->pos.x + current->pos.y + current->pos.z;
|
||||
//if ((dirty->pos.z < current->pos.z+current->size.z) && (current->pos.x+current->size.x+current->pos.y > dirty->pos.x+dirty->size.x+dirty->pos.y))
|
||||
|
||||
//if (current->pos.x+current->pos.y>dirty->pos.y+dirty->pos.x || current->pos.z+current->size.z>dirty->pos.z)
|
||||
//if (current->pos.x>dirty->pos.x+dirty->size.x || current->pos.y>dirty->pos.y+dirty->size.y || current->pos.z>dirty->pos.z+dirty->size.z)
|
||||
if (isInFront(current, dirty))
|
||||
{
|
||||
dirty->prev = current->prev;
|
||||
@@ -164,11 +157,14 @@ namespace actor
|
||||
|
||||
void updateUserInput(actor_t *act)
|
||||
{
|
||||
vec3_t min = room::getMin();
|
||||
vec3_t max = room::getMax();
|
||||
|
||||
bool moving = false;
|
||||
if (input::keyDown(SDL_SCANCODE_LEFT) && act->pos.x>0) { act->push |= PUSH_XN; act->orient=PUSH_XN; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_RIGHT) && act->pos.x<56) { act->push |= PUSH_XP; act->orient=PUSH_XP; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_UP) && act->pos.y>0) { act->push |= PUSH_YN; act->orient=PUSH_YN; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_DOWN) && act->pos.y<56) { act->push |= PUSH_YP; act->orient=PUSH_YP; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_LEFT) && act->pos.x>min.x) { act->push |= PUSH_XN; act->orient=PUSH_XN; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_RIGHT) && act->pos.x<max.x) { act->push |= PUSH_XP; act->orient=PUSH_XP; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_UP) && act->pos.y>min.y) { act->push |= PUSH_YN; act->orient=PUSH_YN; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_DOWN) && act->pos.y<max.y) { act->push |= PUSH_YP; act->orient=PUSH_YP; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_SPACE) && act->react_mask==0 && (act->pos.z==0 || act->below)) {
|
||||
act->react_mask=1;
|
||||
act->react_push=0;
|
||||
@@ -179,7 +175,7 @@ namespace actor
|
||||
}
|
||||
}
|
||||
if (input::keyDown(SDL_SCANCODE_Z) && act->pos.z>0) { act->push |= PUSH_ZN; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_A) && act->pos.z<56) { act->push |= PUSH_ZP; moving = true; }
|
||||
if (input::keyDown(SDL_SCANCODE_A) && act->pos.z<max.z) { act->push |= PUSH_ZP; moving = true; }
|
||||
|
||||
if (act->react_mask)
|
||||
{
|
||||
@@ -259,8 +255,11 @@ namespace actor
|
||||
|
||||
void updatePushable(actor_t *act)
|
||||
{
|
||||
vec3_t min = room::getMin();
|
||||
vec3_t max = room::getMax();
|
||||
|
||||
if (act->push & PUSH_ZP) {
|
||||
if (act->pos.z>=56)
|
||||
if (act->pos.z>=max.z)
|
||||
{
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -281,7 +280,7 @@ namespace actor
|
||||
if (act->push & PUSH_XN) {
|
||||
act->pos.x--;
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (act->pos.x<0 || other)
|
||||
if (act->pos.x<min.x || other)
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_XN;
|
||||
act->pos.x++;
|
||||
@@ -306,7 +305,7 @@ namespace actor
|
||||
if (act->push & PUSH_XP) {
|
||||
act->pos.x++;
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (act->pos.x>56 || other)
|
||||
if (act->pos.x>max.x || other)
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_XP;
|
||||
act->pos.x--;
|
||||
@@ -331,7 +330,7 @@ namespace actor
|
||||
if (act->push & PUSH_YN) {
|
||||
act->pos.y--;
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (act->pos.y<0 || other)
|
||||
if (act->pos.y<min.y || other)
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YN;
|
||||
act->pos.y++;
|
||||
@@ -356,7 +355,7 @@ namespace actor
|
||||
if (act->push & PUSH_YP) {
|
||||
act->pos.y++;
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (act->pos.y>56 ||other)
|
||||
if (act->pos.y>max.y ||other)
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YP;
|
||||
act->pos.y--;
|
||||
@@ -477,6 +476,7 @@ namespace actor
|
||||
//print(x+5,y,act->pos.x);
|
||||
//print(x+5,y+6,act->pos.y);
|
||||
//print(x+5,y+12,order);
|
||||
print(x+5,y,act->flags);
|
||||
|
||||
if (draw_all && act->next) draw(act->next);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user