- Afegit nom als actors
- [BUG] Els actors es movien magicament (push no definit) - Clear de actors - Comencem amb l'editor
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
*.exe
|
||||
*.dll
|
||||
vscode/*
|
||||
.vscode/*
|
||||
thepool
|
||||
|
||||
@@ -19,14 +19,16 @@ namespace actor
|
||||
return first;
|
||||
}
|
||||
|
||||
actor_t *create(vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o)
|
||||
actor_t *create(const char *name, vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o)
|
||||
{
|
||||
actor_t *act = (actor_t*)malloc(sizeof(actor_t));
|
||||
strcpy(act->name, name);
|
||||
act->pos = p;
|
||||
act->size = s;
|
||||
act->bmp_rect = r;
|
||||
act->bmp_offset = o;
|
||||
act->anim_cycle = 0;
|
||||
act->anim_cycle = act->orient = 0;
|
||||
act->push = act->mov_push = PUSH_NONE;
|
||||
act->below = act->above = nullptr;
|
||||
act->prev = act->next = nullptr;
|
||||
return act;
|
||||
@@ -582,4 +584,16 @@ namespace actor
|
||||
(obj1->pos.z < obj2->pos.z + obj2->size.z) &&
|
||||
(obj1->pos.z + obj1->size.z > obj2->pos.z );
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
actor_t *act = first;
|
||||
while (act)
|
||||
{
|
||||
actor_t *tmp = act->next;
|
||||
free(act);
|
||||
act = tmp;
|
||||
}
|
||||
first = dirty = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ namespace actor
|
||||
{
|
||||
struct actor_t
|
||||
{
|
||||
char name[8];
|
||||
SDL_Rect bmp_rect;
|
||||
SDL_Point bmp_offset;
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace actor
|
||||
|
||||
actor_t *getFirst();
|
||||
|
||||
actor_t *create(vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o);
|
||||
actor_t *create(const char *name, vec3_t p, vec3_t s, SDL_Rect r, SDL_Point o);
|
||||
|
||||
void setDirty(actor_t *act, const bool force=false);
|
||||
|
||||
@@ -75,4 +76,6 @@ namespace actor
|
||||
actor_t *get_collision(actor_t *act);
|
||||
|
||||
const bool check_collision(actor_t *obj1, actor_t *obj2);
|
||||
|
||||
void clear();
|
||||
}
|
||||
@@ -7,6 +7,31 @@
|
||||
|
||||
draw::surface *surf;
|
||||
actor::actor_t *box;
|
||||
int ii = 0;
|
||||
|
||||
void restart()
|
||||
{
|
||||
actor::clear();
|
||||
room::load(ii,3);
|
||||
|
||||
box = actor::create("ASCENSOR",{16,32,0}, {8,8,4}, {64,0,32,24}, {0,24});
|
||||
box->flags = FLAG_MOVING;
|
||||
box->movement = MOV_Z;
|
||||
box->mov_push = PUSH_ZP;
|
||||
actor::setDirty(box, true);
|
||||
|
||||
box = actor::create("BOX", {32,32,16}, {8,8,8}, {32,0,32,32}, {0,32});
|
||||
box->flags = FLAG_PUSHABLE | FLAG_GRAVITY;
|
||||
box->movement = MOV_CW;
|
||||
box->mov_push = PUSH_XN;
|
||||
actor::setDirty(box, true);
|
||||
|
||||
box = actor::create("HERO", {16,32,8}, {8,8,12}, {0,32,20,32}, {-6,38});
|
||||
box->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
|
||||
actor::setDirty(box, true);
|
||||
|
||||
actor::reorder();
|
||||
}
|
||||
|
||||
void game::init()
|
||||
{
|
||||
@@ -16,25 +41,7 @@ void game::init()
|
||||
draw::loadPalette("test.gif");
|
||||
game::setUpdateTicks(64);
|
||||
|
||||
room::load(3,3);
|
||||
|
||||
box = actor::create({16,32,0}, {8,8,4}, {64,0,32,24}, {0,24});
|
||||
box->flags = FLAG_MOVING;
|
||||
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 | FLAG_GRAVITY;
|
||||
box->movement = MOV_CW;
|
||||
box->mov_push = PUSH_XN;
|
||||
actor::setDirty(box, true);
|
||||
|
||||
box = actor::create({16,32,8}, {8,8,12}, {0,32,20,32}, {-6,38});
|
||||
box->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
|
||||
actor::setDirty(box, true);
|
||||
|
||||
actor::reorder();
|
||||
restart();
|
||||
}
|
||||
|
||||
int sx=1, sy=0;
|
||||
@@ -42,6 +49,11 @@ int sx=1, sy=0;
|
||||
|
||||
bool game::loop()
|
||||
{
|
||||
if ( input::keyDown(SDL_SCANCODE_Q) )
|
||||
{
|
||||
ii++;if(ii>3)ii=0;
|
||||
restart();
|
||||
}
|
||||
actor::update(actor::getFirst());
|
||||
actor::reorder();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace room
|
||||
static vec3_t min = {0,0,0};
|
||||
static vec3_t max = {56,56,56};
|
||||
|
||||
static uint8_t doors = 15; //OOR_XP /*| DOOR_YP*/ ;
|
||||
static uint8_t doors = DOOR_XP /*| DOOR_YP*/ ;
|
||||
static uint8_t door_height[4];
|
||||
|
||||
void load(int x, int y)
|
||||
@@ -27,20 +27,20 @@ namespace room
|
||||
|
||||
if (doors & DOOR_YP)
|
||||
{
|
||||
actor::actor_t *act = actor::create({24,(tmax.y+1)*8,0}, {8,8,(door_height[2])*4}, {0,1,32,15}, {0,15+door_height[2]*8});
|
||||
actor::actor_t *act = actor::create("DOOR_YP1", {24,(tmax.y+1)*8,0}, {8,8,(door_height[2])*4}, {0,1,32,15}, {0,15+door_height[2]*8});
|
||||
act->flags = FLAG_NONE;
|
||||
actor::setDirty(act, true);
|
||||
act = actor::create({32,(tmax.y+1)*8,0}, {8,8,(door_height[2])*4}, {0,1,32,15}, {0,15+door_height[2]*8});
|
||||
act = actor::create("DOOR_YP2", {32,(tmax.y+1)*8,0}, {8,8,(door_height[2])*4}, {0,1,32,15}, {0,15+door_height[2]*8});
|
||||
act->flags = FLAG_NONE;
|
||||
actor::setDirty(act, true);
|
||||
}
|
||||
|
||||
if (doors & DOOR_XP)
|
||||
{
|
||||
actor::actor_t *act = actor::create({(tmax.x+1)*8,24,0}, {8,8,(door_height[0])*4}, {0,1,32,15}, {0,15+door_height[0]*8});
|
||||
actor::actor_t *act = actor::create("DOOR_XP1", {(tmax.x+1)*8,24,0}, {8,8,(door_height[0])*4}, {0,1,32,15}, {0,15+door_height[0]*8});
|
||||
act->flags = FLAG_NONE;
|
||||
actor::setDirty(act, true);
|
||||
act = actor::create({(tmax.x+1)*8,32,0}, {8,8,(door_height[0])*4}, {0,1,32,15}, {0,15+door_height[0]*8});
|
||||
act = actor::create("DOOR_XP2", {(tmax.x+1)*8,32,0}, {8,8,(door_height[0])*4}, {0,1,32,15}, {0,15+door_height[0]*8});
|
||||
act->flags = FLAG_NONE;
|
||||
actor::setDirty(act, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user