- Treballant en les plantilles de actors
- Comença la reescritura del sistema de push
This commit is contained in:
118
source/actor.cpp
118
source/actor.cpp
@@ -2,6 +2,7 @@
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include "room.h"
|
||||
#include <vector>
|
||||
|
||||
namespace actor
|
||||
{
|
||||
@@ -246,6 +247,7 @@ namespace actor
|
||||
}
|
||||
if ( input::keyDown(SDL_SCANCODE_SPACE) && act->pos.y<=max.y && act->pos.y>=min.y && act->pos.x<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below))
|
||||
{
|
||||
// [RZC 14/05/2024] hack usant react_mask i react_push del heroi. Llegir més avall.
|
||||
act->react_mask=1;
|
||||
act->react_push=0;
|
||||
act->flags &= uint8_t(~FLAG_GRAVITY);
|
||||
@@ -258,6 +260,10 @@ 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<max.z) { act->push |= PUSH_ZP; moving = true; }
|
||||
|
||||
// [RZC 14/05/2024] Açò es un hack. estic usant react_mask i react_push del hero com a guarda
|
||||
// i contador per al bot. Supose que perque se suposa que el heroi no te raons
|
||||
// per a ser REACTIU. Però si arriba a vindre la guardia civil m'en pega més
|
||||
// que a un xixo.
|
||||
if (act->react_mask)
|
||||
{
|
||||
if (act->pos.x>max.x || act->pos.x<min.x || act->pos.y>max.y || act->pos.y<min.y) act->react_push=8;
|
||||
@@ -767,4 +773,116 @@ namespace actor
|
||||
|
||||
}
|
||||
|
||||
namespace templates
|
||||
{
|
||||
char tmp[255];
|
||||
|
||||
std::vector<actor_t> templates;
|
||||
|
||||
const char *numToOrient(uint8_t value)
|
||||
{
|
||||
tmp[0]=0;
|
||||
if (value==0) return "NONE";
|
||||
if (value&1) strcat(tmp, "XP ");
|
||||
if (value&2) strcat(tmp, "XN ");
|
||||
if (value&4) strcat(tmp, "YP ");
|
||||
if (value&8) strcat(tmp, "YN ");
|
||||
if (value&16) strcat(tmp, "ZP ");
|
||||
if (value&32) strcat(tmp, "ZN ");
|
||||
return tmp;
|
||||
}
|
||||
|
||||
const char *numToFlags(uint16_t value)
|
||||
{
|
||||
tmp[0]=0;
|
||||
if (value==0) return "NONE";
|
||||
if (value&1) strcat(tmp, "HERO ");
|
||||
if (value&2) strcat(tmp, "PUSHABLE ");
|
||||
if (value&4) strcat(tmp, "REACTIVE ");
|
||||
if (value&8) strcat(tmp, "MOVING ");
|
||||
if (value&16) strcat(tmp, "ANIMATED ");
|
||||
if (value&32) strcat(tmp, "ORIENTABLE ");
|
||||
if (value&64) strcat(tmp, "DEADLY ");
|
||||
if (value&128) strcat(tmp, "GRAVITY ");
|
||||
return tmp;
|
||||
}
|
||||
|
||||
const char *numToMov(uint8_t value)
|
||||
{
|
||||
if (value==0) return "NONE";
|
||||
if (value==1) return "X";
|
||||
if (value==2) return "Y";
|
||||
if (value==3) return "Z";
|
||||
if (value==4) return "CW";
|
||||
if (value==5) return "CCW";
|
||||
if (value==6) return "RAND";
|
||||
if (value==7) return "HUNT";
|
||||
}
|
||||
|
||||
void load()
|
||||
{
|
||||
templates.clear();
|
||||
FILE *f = fopen("data/templates.txt", "r");
|
||||
if (!f) return;
|
||||
int size = 0;
|
||||
fscanf(f, "TEMPLATES %i\n", &size);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void save()
|
||||
{
|
||||
FILE *f = fopen("data/templates.txt", "w");
|
||||
fprintf(f, "TEMPLATES %i\n", templates.size());
|
||||
|
||||
for (int i=0; i<templates.size(); ++i)
|
||||
{
|
||||
actor_t t = templates[i];
|
||||
fprintf(f, "name = %s\n", t.name);
|
||||
fprintf(f, "bmp = %s\n", t.bmp);
|
||||
fprintf(f, "bmp_rect = %i %i %i %i\n", t.bmp_rect.x, t.bmp_rect.y, t.bmp_rect.w, t.bmp_rect.h);
|
||||
fprintf(f, "bmp_offset = %i %i\n", t.bmp_offset.x, t.bmp_offset.y);
|
||||
fprintf(f, "pos = %i %i %i\n", t.pos.x, t.pos.y, t.pos.z);
|
||||
fprintf(f, "size = %i %i %i\n", t.size.x, t.size.y, t.size.z);
|
||||
fprintf(f, "orient = %s\n", numToOrient(t.orient));
|
||||
fprintf(f, "anim_cycle = %s\n", t.anim_cycle==0 ? "WALK" : "SEQ");
|
||||
fprintf(f, "anim_wait = %i\n", t.anim_wait);
|
||||
fprintf(f, "flags = %s\n", numToFlags(t.flags));
|
||||
fprintf(f, "react_mask = %s\n", numToOrient(t.react_mask));
|
||||
fprintf(f, "react_push = %s\n", numToOrient(t.react_push));
|
||||
fprintf(f, "movement = %s\n\n", numToMov(t.movement));
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
const int size()
|
||||
{
|
||||
return templates.size();
|
||||
}
|
||||
|
||||
actor_t *get(const int index)
|
||||
{
|
||||
return &templates[index];
|
||||
}
|
||||
|
||||
void add(actor_t *actor){
|
||||
actor_t new_template;
|
||||
strcpy(new_template.name, actor->name);
|
||||
strcpy(new_template.bmp, actor->bmp);
|
||||
new_template.bmp_rect = actor->bmp_rect;
|
||||
new_template.bmp_offset = actor->bmp_offset;
|
||||
new_template.pos = actor->pos;
|
||||
new_template.size = actor->size;
|
||||
new_template.orient = actor->orient;
|
||||
new_template.anim_cycle = actor->anim_cycle;
|
||||
new_template.anim_wait = actor->anim_wait;
|
||||
new_template.flags = actor->flags;
|
||||
new_template.react_mask = actor->react_mask;
|
||||
new_template.react_push = actor->react_push;
|
||||
new_template.movement = actor->movement;
|
||||
templates.push_back(new_template);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
#define PUSH_YN 8
|
||||
#define PUSH_ZP 16
|
||||
#define PUSH_ZN 32
|
||||
#define PUSH_KILL 64
|
||||
|
||||
// Tipus de moviment de l'actor
|
||||
#define MOV_NONE 0 // Ningun
|
||||
@@ -105,4 +106,13 @@ namespace actor
|
||||
void remove(actor_t *act);
|
||||
|
||||
void clear();
|
||||
|
||||
namespace templates
|
||||
{
|
||||
void load();
|
||||
void save();
|
||||
const int size();
|
||||
actor_t *get(const int index);
|
||||
void add(actor_t *actor);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user