- Organització dels templates en categories
- Al afegir un actor com a template, "neteja" el nom de numerets - El numeros del final de nom ara tenen el format "-XX"
This commit is contained in:
@@ -1,280 +1,323 @@
|
||||
|
||||
actor{
|
||||
name: BOX
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 32 0 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 32 32 0
|
||||
size: 8 8 8
|
||||
flags: PUSHABLE
|
||||
movement: CW
|
||||
category{
|
||||
name: default
|
||||
|
||||
actor{
|
||||
name: BOX
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 32 0 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 32 32 0
|
||||
size: 8 8 8
|
||||
flags: PUSHABLE
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: BARREL
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 96 64 18 32
|
||||
bmp-offset: -7 37
|
||||
pos: 25 9 0
|
||||
size: 6 6 12
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 1
|
||||
flags: PUSHABLE ANIMATED GRAVITY
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: NEVERA1
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 0 96 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 32 32 0
|
||||
size: 8 8 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: NEVERA2
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 32 96 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 32 32 8
|
||||
size: 8 8 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: LIFT
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 32 32 32 24
|
||||
bmp-offset: 0 24
|
||||
pos: 56 0 0
|
||||
size: 8 8 4
|
||||
orient: ZP
|
||||
flags: MOVING
|
||||
movement: Z
|
||||
}
|
||||
|
||||
actor{
|
||||
name: BOOSTER
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 114 78 15 18
|
||||
bmp-offset: -8 22
|
||||
pos: 0 0 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: ANIMATED SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: S-SHOES
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 162 0 28 22
|
||||
bmp-offset: -3 24
|
||||
pos: 48 8 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-TIMER
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 96 0 24 32
|
||||
bmp-offset: -4 34
|
||||
pos: 8 40 8
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-FILTER
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 24 0 24 32
|
||||
bmp-offset: -4 34
|
||||
pos: 8 24 8
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-ELBOW
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 22 32 22 32
|
||||
bmp-offset: -2 35
|
||||
pos: 8 16 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-PIPE
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 16 64 16 32
|
||||
bmp-offset: -8 36
|
||||
pos: 8 24 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-SALT
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 86 32 20 32
|
||||
bmp-offset: -7 35
|
||||
pos: 8 32 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-PUMP
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 70 64 22 32
|
||||
bmp-offset: -5 35
|
||||
pos: 8 32 11
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: SOFA
|
||||
bmp: altres.gif
|
||||
bmp-rect: 0 0 48 40
|
||||
bmp-offset: 0 32
|
||||
pos: 0 0 0
|
||||
size: 16 8 6
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: LLIT
|
||||
bmp: altres.gif
|
||||
bmp-rect: 48 0 57 47
|
||||
bmp-offset: 11 32
|
||||
pos: 8 8 0
|
||||
size: 16 16 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: KALLAX-A
|
||||
bmp: altres.gif
|
||||
bmp-rect: 0 48 24 27
|
||||
bmp-offset: 0 31
|
||||
pos: 0 0 0
|
||||
size: 8 4 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: FINESTRA
|
||||
bmp: altres.gif
|
||||
bmp-rect: 0 75 20 33
|
||||
bmp-offset: 0 39
|
||||
pos: 15 23 4
|
||||
size: 1 1 9
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: EXPLOSION
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 0 160 18 22
|
||||
bmp-offset: -7 24
|
||||
pos: 32 32 0
|
||||
size: 8 8 4
|
||||
anim-cycle: SEQ
|
||||
flags: ANIMATED
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: GAT-NEGRE
|
||||
bmp: gat.gif
|
||||
bmp-rect: 0 0 24 28
|
||||
bmp-offset: -4 32
|
||||
pos: 8 8 0
|
||||
size: 8 8 8
|
||||
orient: XP
|
||||
anim-wait: 2
|
||||
flags: MOVING ANIMATED ORIENTABLE
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: CUADRO
|
||||
bmp: altres.gif
|
||||
bmp-rect: 66 75 18 32
|
||||
bmp-offset: 0 39
|
||||
pos: 14 23 6
|
||||
size: 1 1 9
|
||||
orient: YP
|
||||
flags: ORIENTABLE
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: MESITA
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 0 64 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 0 16 0
|
||||
size: 8 8 4
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: LAMPARA
|
||||
bmp: altres.gif
|
||||
bmp-rect: 128 0 20 41
|
||||
bmp-offset: -6 45
|
||||
pos: 1 41 0
|
||||
size: 6 6 16
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: ROOMBA
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 160 0 32 32
|
||||
bmp-offset: 0 34
|
||||
pos: 32 32 0
|
||||
size: 8 8 2
|
||||
orient: XN
|
||||
flags: REACTIVE MOVING DEADLY
|
||||
react-mask: XP XN YP YN ZP ZN
|
||||
movement: CCW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: WC
|
||||
bmp: altres.gif
|
||||
bmp-rect: 105 0 21 33
|
||||
bmp-offset: -4 36
|
||||
pos: 8 8 0
|
||||
size: 8 8 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: MANCUERNA
|
||||
bmp: altres.gif
|
||||
bmp-rect: 106 33 17 14
|
||||
bmp-offset: -6 20
|
||||
pos: 24 25 0
|
||||
size: 6 4 2
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: CADIRA
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 64 96 20 32
|
||||
bmp-offset: -8 40
|
||||
pos: 8 51 0
|
||||
size: 5 4 8
|
||||
orient: YP
|
||||
movement: CW
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
actor{
|
||||
name: BARREL
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 96 64 18 32
|
||||
bmp-offset: -7 37
|
||||
pos: 25 9 0
|
||||
size: 6 6 12
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 1
|
||||
flags: PUSHABLE ANIMATED GRAVITY
|
||||
movement: CW
|
||||
}
|
||||
category{
|
||||
name: coses
|
||||
|
||||
actor{
|
||||
name: NEVERA1
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 0 96 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 32 32 0
|
||||
size: 8 8 8
|
||||
movement: CW
|
||||
}
|
||||
actor{
|
||||
name: PILA
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 160 96 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 24 8 0
|
||||
size: 8 8 8
|
||||
orient: YP
|
||||
flags: ORIENTABLE
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: NEVERA2
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 32 96 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 32 32 8
|
||||
size: 8 8 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: LIFT
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 32 32 32 24
|
||||
bmp-offset: 0 24
|
||||
pos: 56 0 0
|
||||
size: 8 8 4
|
||||
orient: ZP
|
||||
flags: MOVING
|
||||
movement: Z
|
||||
}
|
||||
|
||||
actor{
|
||||
name: BOOSTER
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 114 78 15 18
|
||||
bmp-offset: -8 22
|
||||
pos: 0 0 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: ANIMATED SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: S-SHOES
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 162 0 28 22
|
||||
bmp-offset: -3 24
|
||||
pos: 48 8 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-TIMER
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 96 0 24 32
|
||||
bmp-offset: -4 34
|
||||
pos: 8 40 8
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-FILTER
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 24 0 24 32
|
||||
bmp-offset: -4 34
|
||||
pos: 8 24 8
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-ELBOW
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 22 32 22 32
|
||||
bmp-offset: -2 35
|
||||
pos: 8 16 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-PIPE
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 16 64 16 32
|
||||
bmp-offset: -8 36
|
||||
pos: 8 24 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-SALT
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 86 32 20 32
|
||||
bmp-offset: -7 35
|
||||
pos: 8 32 0
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: P-PUMP
|
||||
bmp: objectes.gif
|
||||
bmp-rect: 70 64 22 32
|
||||
bmp-offset: -5 35
|
||||
pos: 8 32 11
|
||||
size: 4 4 4
|
||||
anim-cycle: SEQ
|
||||
anim-wait: 2
|
||||
flags: SPECIAL
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: SOFA
|
||||
bmp: altres.gif
|
||||
bmp-rect: 0 0 48 40
|
||||
bmp-offset: 0 32
|
||||
pos: 0 0 0
|
||||
size: 16 8 6
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: LLIT
|
||||
bmp: altres.gif
|
||||
bmp-rect: 48 0 57 47
|
||||
bmp-offset: 11 32
|
||||
pos: 8 8 0
|
||||
size: 16 16 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: KALLAX-A
|
||||
bmp: altres.gif
|
||||
bmp-rect: 0 48 24 27
|
||||
bmp-offset: 0 31
|
||||
pos: 0 0 0
|
||||
size: 8 4 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: FINESTRA
|
||||
bmp: altres.gif
|
||||
bmp-rect: 0 75 20 33
|
||||
bmp-offset: 0 39
|
||||
pos: 15 23 4
|
||||
size: 1 1 9
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: EXPLOSION
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 0 160 18 22
|
||||
bmp-offset: -7 24
|
||||
pos: 32 32 0
|
||||
size: 8 8 4
|
||||
anim-cycle: SEQ
|
||||
flags: ANIMATED
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: GAT-NEGRE
|
||||
bmp: gat.gif
|
||||
bmp-rect: 0 0 24 28
|
||||
bmp-offset: -4 32
|
||||
pos: 8 8 0
|
||||
size: 8 8 8
|
||||
orient: XP
|
||||
anim-wait: 2
|
||||
flags: MOVING ANIMATED ORIENTABLE
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: CUADRO
|
||||
bmp: altres.gif
|
||||
bmp-rect: 66 75 18 32
|
||||
bmp-offset: 0 39
|
||||
pos: 14 23 6
|
||||
size: 1 1 9
|
||||
orient: YP
|
||||
flags: ORIENTABLE
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: MESITA
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 0 64 32 32
|
||||
bmp-offset: 0 32
|
||||
pos: 0 16 0
|
||||
size: 8 8 4
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: LAMPARA
|
||||
bmp: altres.gif
|
||||
bmp-rect: 128 0 20 41
|
||||
bmp-offset: -6 45
|
||||
pos: 1 41 0
|
||||
size: 6 6 16
|
||||
movement: CW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: ROOMBA
|
||||
bmp: caixes.gif
|
||||
bmp-rect: 160 0 32 32
|
||||
bmp-offset: 0 34
|
||||
pos: 32 32 0
|
||||
size: 8 8 2
|
||||
orient: XN
|
||||
flags: REACTIVE MOVING DEADLY
|
||||
react-mask: XP XN YP YN ZP ZN
|
||||
movement: CCW
|
||||
}
|
||||
|
||||
actor{
|
||||
name: WC
|
||||
bmp: altres.gif
|
||||
bmp-rect: 105 0 21 33
|
||||
bmp-offset: -4 36
|
||||
pos: 8 8 0
|
||||
size: 8 8 8
|
||||
movement: CW
|
||||
}
|
||||
|
||||
127
source/actor.cpp
127
source/actor.cpp
@@ -88,6 +88,7 @@ namespace actor
|
||||
act->anim_frame=0;
|
||||
act->react_mask = act->react_push = 0;
|
||||
act->flags = FLAG_NONE;
|
||||
act->template_category = 0;
|
||||
return act;
|
||||
}
|
||||
|
||||
@@ -204,6 +205,16 @@ namespace actor
|
||||
|
||||
char tmp[255];
|
||||
|
||||
void cleanName(actor_t *act)
|
||||
{
|
||||
int size = strlen(act->name);
|
||||
if (act->name[size-3] == '-' && act->name[size-1] >= 48 && act->name[size-1] <= 57 && act->name[size-2] >= 48 && act->name[size-2] <= 57 )
|
||||
{
|
||||
act->name[size-3] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Li donem al actor un nom únic
|
||||
void setUniqueName(actor_t *act)
|
||||
{
|
||||
@@ -217,11 +228,12 @@ namespace actor
|
||||
// ... però tenim el mateix nom...
|
||||
if (strcmp(act->name, other->name)==0)
|
||||
{
|
||||
// Si el nom actual no acaba en dos digits, li afegim "01" al final
|
||||
// Si el nom actual no acaba en guió + dos digits, li afegim "-01" al final
|
||||
int size = strlen(act->name);
|
||||
if (act->name[size-1] < 48 || act->name[size-1] > 57 || act->name[size-2] < 48 || act->name[size-2] > 57 )
|
||||
if (act->name[size-3] != '-' || act->name[size-1] < 48 || act->name[size-1] > 57 || act->name[size-2] < 48 || act->name[size-2] > 57 )
|
||||
{
|
||||
strcat(act->name, "01");
|
||||
strcat(other->name, "-00");
|
||||
strcat(act->name, "-01");
|
||||
} else {
|
||||
// Si ja acaba en dos digits, agafem el numero, li sumem 1, i li'l tornem a ficar
|
||||
int num = (act->name[size-1]-48) + (act->name[size-2]-48)*10;
|
||||
@@ -332,23 +344,25 @@ namespace actor
|
||||
return alpha;
|
||||
}
|
||||
|
||||
void saveToFile(FILE *f, actor_t *act)
|
||||
void saveToFile(FILE *f, actor_t *act, bool tab)
|
||||
{
|
||||
fprintf(f, "\nactor{\n");
|
||||
fprintf(f, " name: %s\n", act->name);
|
||||
fprintf(f, " bmp: %s\n", act->bmp);
|
||||
fprintf(f, " bmp-rect: %i %i %i %i\n", act->bmp_rect.x, act->bmp_rect.y, act->bmp_rect.w, act->bmp_rect.h);
|
||||
fprintf(f, " bmp-offset: %i %i\n", act->bmp_offset.x, act->bmp_offset.y);
|
||||
fprintf(f, " pos: %i %i %i\n", act->pos.x, act->pos.y, act->pos.z);
|
||||
fprintf(f, " size: %i %i %i\n", act->size.x, act->size.y, act->size.z);
|
||||
if (act->orient!=0) fprintf(f, " orient: %s\n", numToOrient(act->orient));
|
||||
if (act->anim_cycle!=0) fprintf(f, " anim-cycle: %s\n", act->anim_cycle==0 ? "WALK" : act->anim_cycle==1 ? "SEQ" : "MIN");
|
||||
if (act->anim_wait!=0) fprintf(f, " anim-wait: %i\n", act->anim_wait);
|
||||
if (act->flags!=0) fprintf(f, " flags: %s\n", numToFlags(act->flags));
|
||||
if (act->react_mask!=0) fprintf(f, " react-mask: %s\n", numToOrient(act->react_mask));
|
||||
if (act->react_push!=0) fprintf(f, " react-push: %s\n", numToOrient(act->react_push));
|
||||
if (act->movement!=0) fprintf(f, " movement: %s\n", numToMov(act->movement));
|
||||
fprintf(f, "}\n");
|
||||
char ws[5] = "";
|
||||
if (tab) strcpy(ws, " ");
|
||||
fprintf(f, "\n%sactor{\n", ws);
|
||||
fprintf(f, " %sname: %s\n", ws, act->name);
|
||||
fprintf(f, " %sbmp: %s\n", ws, act->bmp);
|
||||
fprintf(f, " %sbmp-rect: %i %i %i %i\n", ws, act->bmp_rect.x, act->bmp_rect.y, act->bmp_rect.w, act->bmp_rect.h);
|
||||
fprintf(f, " %sbmp-offset: %i %i\n", ws, act->bmp_offset.x, act->bmp_offset.y);
|
||||
fprintf(f, " %spos: %i %i %i\n", ws, act->pos.x, act->pos.y, act->pos.z);
|
||||
fprintf(f, " %ssize: %i %i %i\n", ws, act->size.x, act->size.y, act->size.z);
|
||||
if (act->orient!=0) fprintf(f, " %sorient: %s\n", ws, numToOrient(act->orient));
|
||||
if (act->anim_cycle!=0) fprintf(f, " %sanim-cycle: %s\n", ws, act->anim_cycle==0 ? "WALK" : act->anim_cycle==1 ? "SEQ" : "MIN");
|
||||
if (act->anim_wait!=0) fprintf(f, " %sanim-wait: %i\n", ws, act->anim_wait);
|
||||
if (act->flags!=0) fprintf(f, " %sflags: %s\n", ws, numToFlags(act->flags));
|
||||
if (act->react_mask!=0) fprintf(f, " %sreact-mask: %s\n", ws, numToOrient(act->react_mask));
|
||||
if (act->react_push!=0) fprintf(f, " %sreact-push: %s\n", ws, numToOrient(act->react_push));
|
||||
if (act->movement!=0) fprintf(f, " %smovement: %s\n", ws, numToMov(act->movement));
|
||||
fprintf(f, "%s}\n", ws);
|
||||
}
|
||||
|
||||
const bool check_2d_collision(actor_t *obj1, actor_t *obj2)
|
||||
@@ -1306,14 +1320,18 @@ namespace actor
|
||||
namespace templates
|
||||
{
|
||||
std::vector<actor_t> templates;
|
||||
std::vector<std::string> categories;
|
||||
|
||||
void load()
|
||||
{
|
||||
//newCategory("default");
|
||||
categories.clear();
|
||||
templates.clear();
|
||||
char filename[] = "templates.txt";
|
||||
int filesize=0;
|
||||
char *buffer = file::getFileBuffer(filename, filesize, true);
|
||||
char *original_buffer = buffer;
|
||||
int current_category = 0;
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
@@ -1321,12 +1339,25 @@ namespace actor
|
||||
{
|
||||
const char* key = file::readString(&buffer);
|
||||
|
||||
if (util::strcomp(key, "actor{"))
|
||||
if (util::strcomp(key, "category{"))
|
||||
{
|
||||
const char* key = file::readString(&buffer);
|
||||
if (util::strcomp(key, "name:")) {
|
||||
const char *val = file::readString(&buffer);
|
||||
current_category = newCategory(val);
|
||||
}
|
||||
}
|
||||
else if (util::strcomp(key, "actor{"))
|
||||
{
|
||||
actor_t *t = createFromFile(&buffer);
|
||||
t->template_category = current_category;
|
||||
templates.push_back(*t);
|
||||
free(t);
|
||||
}
|
||||
else if (util::strcomp(key, "}")) {
|
||||
current_category = 0;
|
||||
}
|
||||
|
||||
}
|
||||
free(original_buffer);
|
||||
}
|
||||
@@ -1336,18 +1367,56 @@ namespace actor
|
||||
{
|
||||
FILE *f = fopen("data/templates.txt", "w");
|
||||
|
||||
for (int i=0; i<templates.size(); ++i)
|
||||
for (auto cat_name : categories)
|
||||
{
|
||||
|
||||
fprintf(f, "\ncategory{\n");
|
||||
fprintf(f, " name: %s\n", cat_name.c_str());
|
||||
|
||||
auto actors = getByCategory(cat_name.c_str());
|
||||
for (auto t : actors )
|
||||
{
|
||||
saveToFile(f, &t, true);
|
||||
}
|
||||
|
||||
fprintf(f, "\n}\n");
|
||||
}
|
||||
|
||||
/*for (int i=0; i<templates.size(); ++i)
|
||||
{
|
||||
actor_t t = templates[i];
|
||||
saveToFile(f, &t);
|
||||
}
|
||||
}*/
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
const int size()
|
||||
/*const int size()
|
||||
{
|
||||
return templates.size();
|
||||
}*/
|
||||
|
||||
std::vector<actor::actor_t> getByCategory(const char* category)
|
||||
{
|
||||
std::string catname = category;
|
||||
std::vector<actor_t> actors;
|
||||
for (auto act : templates)
|
||||
{
|
||||
if (act.template_category>=categories.size()) act.template_category = 0;
|
||||
if (categories[act.template_category]==catname) actors.push_back(act);
|
||||
}
|
||||
return actors;
|
||||
}
|
||||
|
||||
std::vector<std::string> getCategories()
|
||||
{
|
||||
return categories;
|
||||
}
|
||||
|
||||
const int newCategory(const char *name)
|
||||
{
|
||||
categories.push_back(name);
|
||||
return categories.size()-1;
|
||||
}
|
||||
|
||||
actor_t *get(const int index)
|
||||
@@ -1381,16 +1450,22 @@ namespace actor
|
||||
|
||||
void add(actor_t *act)
|
||||
{
|
||||
// Fem una copia del actor
|
||||
actor_t new_template;
|
||||
copy(&new_template, act);
|
||||
// Li fiquem la categoria per defecte
|
||||
new_template.template_category = 0;
|
||||
// Netejem el nom de numerets
|
||||
cleanName(&new_template);
|
||||
|
||||
// Si ja hi ha una plantilla amb eixe nom...
|
||||
if (actor::templates::getByName(act->name))
|
||||
{
|
||||
// ... la actualitzem amb les dades del actor seleccionat
|
||||
actor_t *existing_template = actor::templates::getByName(act->name);
|
||||
copy(existing_template, act);
|
||||
copy(existing_template, &new_template);
|
||||
} else {
|
||||
// ... i sinó, afegim el actor seleccionat a la llista de plantilles
|
||||
actor_t new_template;
|
||||
copy(&new_template, act);
|
||||
templates.push_back(new_template);
|
||||
}
|
||||
save();
|
||||
|
||||
160
source/actor.h
160
source/actor.h
@@ -2,26 +2,26 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include "misc.h"
|
||||
#include "jdraw.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// Flags que defineixen les capacitats de l'actor
|
||||
#define FLAG_NONE 0
|
||||
#define FLAG_HERO 1 // Es el heroi
|
||||
#define FLAG_PUSHABLE 2 // Es pot espentar
|
||||
#define FLAG_REACTIVE 4 // Quan se li espenta, torna una espenta específica
|
||||
#define FLAG_MOVING 8 // Es mou
|
||||
#define FLAG_ANIMATED 16 // Te animació de frames
|
||||
#define FLAG_ORIENTABLE 32 // S'orienta cap on va
|
||||
#define FLAG_DEADLY 64 // Fa pupa
|
||||
#define FLAG_GRAVITY 128 // Li afecta la gravetat
|
||||
#define FLAG_PICKABLE 256 // Es pot agafar
|
||||
#define FLAG_SPECIAL 512 // Especial (habilitats, poders temporals i parts de l'excavadora)
|
||||
#define FLAG_NOEDITOR 1024 // No es seleccionable a l'editor (son les portes)
|
||||
#define FLAG_INERTIA 2048 // Al rebre una espenta, continua fins tropesar en algo
|
||||
#define FLAG_NONE 0
|
||||
#define FLAG_HERO 1 // Es el heroi
|
||||
#define FLAG_PUSHABLE 2 // Es pot espentar
|
||||
#define FLAG_REACTIVE 4 // Quan se li espenta, torna una espenta específica
|
||||
#define FLAG_MOVING 8 // Es mou
|
||||
#define FLAG_ANIMATED 16 // Te animació de frames
|
||||
#define FLAG_ORIENTABLE 32 // S'orienta cap on va
|
||||
#define FLAG_DEADLY 64 // Fa pupa
|
||||
#define FLAG_GRAVITY 128 // Li afecta la gravetat
|
||||
#define FLAG_PICKABLE 256 // Es pot agafar
|
||||
#define FLAG_SPECIAL 512 // Especial (habilitats, poders temporals i parts de l'excavadora)
|
||||
#define FLAG_NOEDITOR 1024 // No es seleccionable a l'editor (son les portes)
|
||||
#define FLAG_INERTIA 2048 // Al rebre una espenta, continua fins tropesar en algo
|
||||
|
||||
#define FLAG_SENSIBLE 6 // PUSHABLE or REACTIVE
|
||||
#define FLAG_IGNORE 1025 // HERO or NOEDITOR
|
||||
#define FLAG_SENSIBLE 6 // PUSHABLE or REACTIVE
|
||||
#define FLAG_IGNORE 1025 // HERO or NOEDITOR
|
||||
|
||||
// Direcció de espenta
|
||||
#define PUSH_NONE 0
|
||||
@@ -34,78 +34,79 @@
|
||||
#define PUSH_KILL 64
|
||||
|
||||
// Tipus de moviment de l'actor
|
||||
#define MOV_NONE 0 // Ningun
|
||||
#define MOV_X 1 // Es mou només en l'eix X i quan topeta en algo, torna per on venia
|
||||
#define MOV_Y 2 // Es mou només en l'eix Y i quan topeta en algo, torna per on venia
|
||||
#define MOV_Z 3 // Es mou només en l'eix Z i quan topeta en algo, torna per on venia
|
||||
#define MOV_CW 4 // Es mou en sentit de les agulles del rellotge
|
||||
#define MOV_CCW 5 // Es mou en sentit contrari a les agulles del rellotge
|
||||
#define MOV_RAND 6 // Es mou en direcció aleatòria
|
||||
#define MOV_RANDV 7 // Es mou en direcció aleatòria, diagonals incloses
|
||||
#define MOV_HUNT 8 // Persegueix al heroi
|
||||
#define MOV_NONE 0 // Ningun
|
||||
#define MOV_X 1 // Es mou només en l'eix X i quan topeta en algo, torna per on venia
|
||||
#define MOV_Y 2 // Es mou només en l'eix Y i quan topeta en algo, torna per on venia
|
||||
#define MOV_Z 3 // Es mou només en l'eix Z i quan topeta en algo, torna per on venia
|
||||
#define MOV_CW 4 // Es mou en sentit de les agulles del rellotge
|
||||
#define MOV_CCW 5 // Es mou en sentit contrari a les agulles del rellotge
|
||||
#define MOV_RAND 6 // Es mou en direcció aleatòria
|
||||
#define MOV_RANDV 7 // Es mou en direcció aleatòria, diagonals incloses
|
||||
#define MOV_HUNT 8 // Persegueix al heroi
|
||||
|
||||
// Boosters
|
||||
#define BOOST_NONE 0
|
||||
#define BOOST_RUN 1
|
||||
#define BOOST_GOD 2
|
||||
#define BOOST_JUMP 4
|
||||
#define BOOST_LIVE 8
|
||||
#define BOOST_NONE 0
|
||||
#define BOOST_RUN 1
|
||||
#define BOOST_GOD 2
|
||||
#define BOOST_JUMP 4
|
||||
#define BOOST_LIVE 8
|
||||
|
||||
// Skills
|
||||
#define SKILL_NONE 0
|
||||
#define SKILL_SHOES 1
|
||||
#define SKILL_GLOVES 2
|
||||
#define SKILL_PANTS 4
|
||||
#define SKILL_BAG 8
|
||||
#define SKILL_NONE 0
|
||||
#define SKILL_SHOES 1
|
||||
#define SKILL_GLOVES 2
|
||||
#define SKILL_PANTS 4
|
||||
#define SKILL_BAG 8
|
||||
|
||||
// Parts
|
||||
#define PART_NONE 0
|
||||
#define PART_FILTER 1
|
||||
#define PART_PUMP 2
|
||||
#define PART_TIMER 4
|
||||
#define PART_SALT 8
|
||||
#define PART_PIPE 16
|
||||
#define PART_ELBOW 32
|
||||
#define PART_NONE 0
|
||||
#define PART_FILTER 1
|
||||
#define PART_PUMP 2
|
||||
#define PART_TIMER 4
|
||||
#define PART_SALT 8
|
||||
#define PART_PIPE 16
|
||||
#define PART_ELBOW 32
|
||||
|
||||
namespace actor
|
||||
{
|
||||
struct actor_t
|
||||
{
|
||||
char name[16];
|
||||
draw::surface *surface;
|
||||
char bmp[16];
|
||||
SDL_Rect bmp_rect;
|
||||
SDL_Point bmp_offset;
|
||||
char name[16];
|
||||
draw::surface *surface;
|
||||
char bmp[16];
|
||||
SDL_Rect bmp_rect;
|
||||
SDL_Point bmp_offset;
|
||||
|
||||
vec3_t pos;
|
||||
vec3_t size;
|
||||
vec3_t pos;
|
||||
vec3_t size;
|
||||
|
||||
int orient;
|
||||
int anim_cycle;
|
||||
int anim_frame;
|
||||
int anim_wait;
|
||||
int anim_wait_count;
|
||||
int orient;
|
||||
int anim_cycle;
|
||||
int anim_frame;
|
||||
int anim_wait;
|
||||
int anim_wait_count;
|
||||
|
||||
int flags;
|
||||
int push;
|
||||
int flags;
|
||||
int push;
|
||||
|
||||
int react_mask;
|
||||
int react_push;
|
||||
int react_mask;
|
||||
int react_push;
|
||||
|
||||
int movement;
|
||||
int mov_push;
|
||||
int movement;
|
||||
int mov_push;
|
||||
|
||||
actor_t *below;
|
||||
actor_t *above;
|
||||
actor_t *below;
|
||||
actor_t *above;
|
||||
|
||||
actor_t *prev;
|
||||
actor_t *next;
|
||||
actor_t *next_alpha;
|
||||
actor_t *prev;
|
||||
actor_t *next;
|
||||
actor_t *next_alpha;
|
||||
|
||||
int inner_x;
|
||||
int inner_y;
|
||||
int inner_x;
|
||||
int inner_y;
|
||||
|
||||
int tag;
|
||||
int tag;
|
||||
int template_category;
|
||||
};
|
||||
|
||||
void resetTag();
|
||||
@@ -130,13 +131,15 @@ namespace actor
|
||||
|
||||
actor_t *replaceWithTemplate(actor_t *act, const char *name);
|
||||
|
||||
void cleanName(actor_t *act);
|
||||
|
||||
void setUniqueName(actor_t *act);
|
||||
|
||||
actor_t *alphaOrder(actor_t *act);
|
||||
|
||||
void saveToFile(FILE *f, actor_t *act);
|
||||
void saveToFile(FILE *f, actor_t *act, bool tab=false);
|
||||
|
||||
void setDirty(actor_t *act, const bool force=false);
|
||||
void setDirty(actor_t *act, const bool force = false);
|
||||
|
||||
void select(actor_t *act);
|
||||
|
||||
@@ -144,11 +147,11 @@ namespace actor
|
||||
|
||||
uint8_t push(actor_t *source, actor_t *act, uint8_t push);
|
||||
|
||||
void update(actor_t *act, const bool update_all=true);
|
||||
void updateEditor(actor_t *act, const bool update_all=true);
|
||||
void update(actor_t *act, const bool update_all = true);
|
||||
void updateEditor(actor_t *act, const bool update_all = true);
|
||||
|
||||
void drawAt(actor_t * act, const int x, const int y);
|
||||
void draw(actor_t *act, const bool draw_all=true);
|
||||
void drawAt(actor_t *act, const int x, const int y);
|
||||
void draw(actor_t *act, const bool draw_all = true);
|
||||
|
||||
actor_t *find(std::string name);
|
||||
|
||||
@@ -166,13 +169,16 @@ namespace actor
|
||||
|
||||
actor_t *getPicked();
|
||||
|
||||
void clear(const bool all=false);
|
||||
void clear(const bool all = false);
|
||||
|
||||
namespace templates
|
||||
{
|
||||
void load();
|
||||
void save();
|
||||
const int size();
|
||||
//const int size();
|
||||
std::vector<actor::actor_t> getByCategory(const char* category);
|
||||
std::vector<std::string> getCategories();
|
||||
const int newCategory(const char *name);
|
||||
actor_t *get(const int index);
|
||||
actor_t *getByName(const char *name);
|
||||
void copy(actor_t *dest, actor_t *source);
|
||||
@@ -181,7 +187,7 @@ namespace actor
|
||||
|
||||
namespace hero
|
||||
{
|
||||
void init(const bool complete=true);
|
||||
void init(const bool complete = true);
|
||||
int getLives();
|
||||
void setLives(int value);
|
||||
|
||||
|
||||
@@ -435,6 +435,7 @@ namespace modules
|
||||
draw::color(WHITE);
|
||||
draw::fillrect(0, 0, 100, 240);
|
||||
|
||||
/*
|
||||
int result = ui::combo(actor::templates::get(editor::getCurrentTemplate())->name, 2, 2, 76, 11);
|
||||
if (result)
|
||||
{
|
||||
@@ -451,7 +452,7 @@ namespace modules
|
||||
actor::select(new_act);
|
||||
room::editor::modify();
|
||||
}
|
||||
|
||||
*/
|
||||
draw::color(LIGHT+WHITE);
|
||||
draw::fillrect(2, 15, 96, 223);
|
||||
draw::color(PAPER);
|
||||
|
||||
Reference in New Issue
Block a user