From c51571e53c780ff72af75fc20ce72d414f7f7c26 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Tue, 14 May 2024 14:09:23 +0200 Subject: [PATCH] =?UTF-8?q?-=20Treballant=20en=20les=20plantilles=20de=20a?= =?UTF-8?q?ctors=20-=20Comen=C3=A7a=20la=20reescritura=20del=20sistema=20d?= =?UTF-8?q?e=20push?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/actor.cpp | 118 +++++++++++++++++++++++++++++++++++++++++++++++ source/actor.h | 10 ++++ 2 files changed, 128 insertions(+) diff --git a/source/actor.cpp b/source/actor.cpp index 6bef561..4daa011 100644 --- a/source/actor.cpp +++ b/source/actor.cpp @@ -2,6 +2,7 @@ #include "jdraw.h" #include "jinput.h" #include "room.h" +#include 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.zpush |= 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.xpos.y>max.y || act->pos.yreact_push=8; @@ -767,4 +773,116 @@ namespace actor } + namespace templates + { + char tmp[255]; + + std::vector 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; iname); + 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); + } + } + } \ No newline at end of file diff --git a/source/actor.h b/source/actor.h index a993da1..61f3014 100644 --- a/source/actor.h +++ b/source/actor.h @@ -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); + } } \ No newline at end of file