Free Hero Mesh

Check-in [152aca780c]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Implement death animations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 152aca780ccf073f407b8f782fd9630e2c9ef66f
User & Date: user on 2021-03-20 02:26:02
Other Links: manifest | tags
Context
2021-03-20
04:36
Make some corrections to the implementation of dead animations check-in: d033ec4bd1 user: user tags: trunk
02:26
Implement death animations check-in: 152aca780c user: user tags: trunk
2021-03-19
06:09
Implement sleeping during autotest if the .progress resource is set to a negative number. check-in: a747e28795 user: user tags: trunk
Changes

Modified exec.c from [a0b55bb923] to [08725a980a].

33
34
35
36
37
38
39


40
41
42
43
44
45
46
Uint32 move_number;
unsigned char*quiz_text;
Inventory*inventory;
Uint32 ninventory;
char**levelstrings;
Uint16 nlevelstrings;
Value*array_data;



typedef struct {
  Uint16 msg;
  Uint32 from;
  Value arg1,arg2,arg3;
} MessageVars;








>
>







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Uint32 move_number;
unsigned char*quiz_text;
Inventory*inventory;
Uint32 ninventory;
char**levelstrings;
Uint16 nlevelstrings;
Value*array_data;
Uint16 ndeadanim;
DeadAnimation*deadanim;

typedef struct {
  Uint16 msg;
  Uint32 from;
  Value arg1,arg2,arg3;
} MessageVars;

156
157
158
159
160
161
162













163
164
165
166

167
168
169



170
171
172
173
174
175
176
  return n;
  bad:
  free(o);
  return VOIDLINK;
}

#define animfree free














void objtrash(Uint32 n) {
  Object*o=objects[n];
  if(!o) return;

  if(n==traced_obj.u && o->generation==traced_obj.t && main_options['t'] && !main_options['e']) {
    printf("# Object traced at (%d,%d)\n",o->x,o->y);
    Throw("Object traced");



  }
  animfree(o->anim);
  if(o->down==VOIDLINK) playfield[o->x+o->y*64-65]=o->up;
  else objects[o->down]->up=o->up;
  if(o->up!=VOIDLINK) objects[o->up]->down=o->down;
  if(!(o->oflags&OF_DESTROYED)) {
    if(firstobj==n) firstobj=o->next;







>
>
>
>
>
>
>
>
>
>
>
>
>




>
|
|
|
>
>
>







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
  return n;
  bad:
  free(o);
  return VOIDLINK;
}

#define animfree free

static void set_dead_animation(const Object*o) {
  DeadAnimation*d;
  deadanim=realloc(deadanim,(ndeadanim+1)*sizeof(DeadAnimation));
  if(!deadanim) fatal("Allocation failed\n");
  d=deadanim+ndeadanim++;
  d->class=o->class;
  d->x=o->x;
  d->y=o->y;
  d->s=o->anim->step[o->anim->vstep];
  d->vtime=o->anim->vtime;
  d->vimage=o->anim->vimage;
}

void objtrash(Uint32 n) {
  Object*o=objects[n];
  if(!o) return;
  if(!main_options['e']) {
    if(n==traced_obj.u && o->generation==traced_obj.t && main_options['t']) {
      printf("# Object traced at (%d,%d)\n",o->x,o->y);
      Throw("Object traced");
    } else if(ndeadanim<0x1000 && o->anim && o->anim->status==ANISTAT_VISUAL && !(o->oflags&OF_INVISIBLE)) {
      if(o->up==VOIDLINK || (objects[o->up]->oflags&OF_DESTROYED)) set_dead_animation(o);
    }
  }
  animfree(o->anim);
  if(o->down==VOIDLINK) playfield[o->x+o->y*64-65]=o->up;
  else objects[o->down]->up=o->up;
  if(o->up!=VOIDLINK) objects[o->up]->down=o->down;
  if(!(o->oflags&OF_DESTROYED)) {
    if(firstobj==n) firstobj=o->next;
1792
1793
1794
1795
1796
1797
1798



1799
1800
1801
1802
1803
1804
1805
  nobjects=0;
  free(objects);
  objects=0;
  gameover=0;
  clear_inventory();
  for(i=0;i<nlevelstrings;i++) free(levelstrings[i]);
  nlevelstrings=0;



}

static void execute_animation(Uint32 obj) {
  Object*o=objects[obj];
  Animation*a=o->anim;
  if(!(a->step[a->lstep].flag&ANI_ONCE)) return;
  if(a->ltime>=a->step[a->lstep].speed) {







>
>
>







1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
  nobjects=0;
  free(objects);
  objects=0;
  gameover=0;
  clear_inventory();
  for(i=0;i<nlevelstrings;i++) free(levelstrings[i]);
  nlevelstrings=0;
  free(deadanim);
  deadanim=0;
  ndeadanim=0;
}

static void execute_animation(Uint32 obj) {
  Object*o=objects[obj];
  Animation*a=o->anim;
  if(!(a->step[a->lstep].flag&ANI_ONCE)) return;
  if(a->ltime>=a->step[a->lstep].speed) {

Modified game.c from [bcf987b98f] to [6482a4e0d5].

132
133
134
135
136
137
138

139
140
141
142
143
144
145
  set_cursor(XC_arrow);
}

static void continue_animation(void) {
  Uint32 n=firstobj;
  Object*o;
  Animation*a;

  int i;
  for(i=0;i<8;i++) if(anim_slot[i].length && ++anim_slot[i].vtime==anim_slot[i].speed && (anim_slot[i].vtime=0,++anim_slot[i].frame==anim_slot[i].length)) anim_slot[i].frame=0;
  while(n!=VOIDLINK) {
    o=objects[n];
    if((a=o->anim) && (a->status&ANISTAT_VISUAL)) {
      i=a->vstep;
      if(a->step[i].flag&ANI_SYNC) {







>







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
  set_cursor(XC_arrow);
}

static void continue_animation(void) {
  Uint32 n=firstobj;
  Object*o;
  Animation*a;
  DeadAnimation*d;
  int i;
  for(i=0;i<8;i++) if(anim_slot[i].length && ++anim_slot[i].vtime==anim_slot[i].speed && (anim_slot[i].vtime=0,++anim_slot[i].frame==anim_slot[i].length)) anim_slot[i].frame=0;
  while(n!=VOIDLINK) {
    o=objects[n];
    if((a=o->anim) && (a->status&ANISTAT_VISUAL)) {
      i=a->vstep;
      if(a->step[i].flag&ANI_SYNC) {
169
170
171
172
173
174
175


















176
177
178
179
180
181
182
          advance:
          if(a->step[i].end>=a->step[i].start) ++a->vimage; else --a->vimage;
        }
        draw_cell(o->x,o->y);
      }
    }
    n=o->next;


















  }
  SDL_Flip(screen);
}

static void show_mouse_xy(SDL_Event*ev) {
  char buf[32];
  int x,y;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
          advance:
          if(a->step[i].end>=a->step[i].start) ++a->vimage; else --a->vimage;
        }
        draw_cell(o->x,o->y);
      }
    }
    n=o->next;
  }
  if(ndeadanim) {
    for(i=0;i<ndeadanim;i++) {
      d=deadanim+i;
      draw_cell(d->x,d->y);
      if(!d->s.flag) continue;
      if(d->vimage<classes[d->class]->nimages)
       draw_picture((d->x-1)*picture_size+left_margin,(d->y-1)*picture_size,classes[d->class]->images[d->vimage]&0x7FFF);
      if(++d->vtime>=d->s.speed) {
        if(d->vimage==d->s.end) d->s.flag=0;
        if(d->s.end>=d->s.start) ++d->vimage; else --d->vimage;
      }
    }
    for(i=0;i<ndeadanim;i++) while(i<ndeadanim && !deadanim[i].s.flag) {
      draw_cell(deadanim[i].x,deadanim[i].y);
      if(i<ndeadanim-1) deadanim[i]=deadanim[ndeadanim-1];
      --ndeadanim;
    }
  }
  SDL_Flip(screen);
}

static void show_mouse_xy(SDL_Event*ev) {
  char buf[32];
  int x,y;

Modified heromesh.h from [6692b185fe] to [97efdb5c5e].

205
206
207
208
209
210
211






212
213
214
215
216
217
218
typedef struct {
  Uint8 flag,start,end;
  union {
    Uint8 speed; // unsynchronized
    Uint8 slot; // synchronized
  };
} AnimationStep;







#define ANISTAT_LOGICAL 0x01
#define ANISTAT_VISUAL 0x02
#define ANISTAT_SYNCHRONIZED 0x80

typedef struct {
  Uint8 lstep,vstep,status,ltime,vtime,vimage,count;







>
>
>
>
>
>







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
typedef struct {
  Uint8 flag,start,end;
  union {
    Uint8 speed; // unsynchronized
    Uint8 slot; // synchronized
  };
} AnimationStep;

typedef struct {
  Uint8 x,y,vtime,vimage;
  Uint16 class;
  AnimationStep s;
} DeadAnimation;

#define ANISTAT_LOGICAL 0x01
#define ANISTAT_VISUAL 0x02
#define ANISTAT_SYNCHRONIZED 0x80

typedef struct {
  Uint8 lstep,vstep,status,ltime,vtime,vimage,count;
250
251
252
253
254
255
256


257
258
259
260
261
262
263
extern Uint32 move_number;
extern unsigned char*quiz_text;
extern Inventory*inventory;
extern Uint32 ninventory;
extern char**levelstrings;
extern Uint16 nlevelstrings;
extern Value*array_data;



const char*value_string_ptr(Value v);
void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void objtrash(Uint32 n);
void annihilate(void);







>
>







256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
extern Uint32 move_number;
extern unsigned char*quiz_text;
extern Inventory*inventory;
extern Uint32 ninventory;
extern char**levelstrings;
extern Uint16 nlevelstrings;
extern Value*array_data;
extern Uint16 ndeadanim;
extern DeadAnimation*deadanim;

const char*value_string_ptr(Value v);
void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void objtrash(Uint32 n);
void annihilate(void);