Free Hero Mesh

Check-in [3ec62d29f5]
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:Add a few of the things necessary to implement timers, for animation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3ec62d29f59fb3e3daaf50111e57becb6c8f4df1
User & Date: user on 2020-12-05 22:29:31
Other Links: manifest | tags
Context
2020-12-06
21:50
Add some corrected dealing with destroyed objects and other corrections in exec.c check-in: 35eb3bec31 user: user tags: trunk
2020-12-05
22:29
Add a few of the things necessary to implement timers, for animation. check-in: 3ec62d29f5 user: user tags: trunk
08:02
Remove the IOF_DEAD and IOF_ANIM flags; use a different implementation check-in: 2f7b9e4144 user: user tags: trunk
Changes

Modified game.c from [cdd25f4bc4] to [265f8fa7b6].

13
14
15
16
17
18
19


20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28







+
+







#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "heromesh.h"
#include "quarks.h"
#include "cursorshapes.h"

static volatile Uint8 timerflag;

static void redraw_game(void) {
  char buf[32];
  SDL_Rect r;
  int x,y;
  r.x=r.y=0;
  r.h=screen->h;
  r.w=left_margin;
108
109
110
111
112
113
114









115
116
117
118
119
120
121


122
123
124
125
126
127
128




129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

144
145
146
147
148
149
150
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168







+
+
+
+
+
+
+
+
+







+
+







+
+
+
+















+







    sqlite3_str_appendall(m,basefilename);
    sqlite3_str_appendall(m,r+c+1);
  }
  s=sqlite3_str_finish(m);
  if(s) SDL_WM_SetCaption(s,s); else SDL_WM_SetCaption("Free Hero Mesh","Free Hero Mesh");
  sqlite3_free(s);
}

static Uint32 timer_callback(Uint32 n) {
  if(!timerflag) {
    static SDL_Event ev={SDL_USEREVENT};
    SDL_PushEvent(&ev);
  }
  timerflag=1;
  return n;
}

void run_game(void) {
  int i;
  SDL_Event ev;
  set_caption();
  begin_level(level_id);
  redraw_game();
  timerflag=0;
  SDL_SetTimer(10,timer_callback);
  while(SDL_WaitEvent(&ev)) {
    switch(ev.type) {
      case SDL_VIDEOEXPOSE:
        redraw_game();
        break;
      case SDL_QUIT:
        exit(0);
        break;
      case SDL_USEREVENT:
        //TODO: animation
        timerflag=0;
        break;
      case SDL_MOUSEBUTTONDOWN:
        if(ev.button.x<left_margin) {
          
          break;
        } else {
          i=exec_key_binding(&ev,0,(ev.button.x-left_margin)/picture_size+1,ev.button.y/picture_size+1,game_command,0);
          goto command;
        }
      case SDL_KEYDOWN:
        i=exec_key_binding(&ev,0,0,0,game_command,0);
      command:
        if(i==-1) exit(0);
        if(i==-2) {
          main_options['e']=1;
          SDL_SetTimer(0,0);
          return;
        }
        redraw_game();
        break;
    }
  }
}

Modified picture.c from [4d5ad5ad22] to [4a851ea778].

434
435
436
437
438
439
440
441

442
443
444
445
446
447
448
434
435
436
437
438
439
440

441
442
443
444
445
446
447
448







-
+







  if(main_options['x']) return;
  optionquery[1]=Q_screenWidth;
  w=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"800",0,10);
  optionquery[1]=Q_screenHeight;
  h=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"600",0,10);
  optionquery[1]=Q_screenFlags;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  if(SDL_Init(SDL_INIT_VIDEO|(strchr(v,'z')?SDL_INIT_NOPARACHUTE:0))) fatal("Error initializing SDL: %s\n",SDL_GetError());
  if(SDL_Init(SDL_INIT_VIDEO|(strchr(v,'z')?SDL_INIT_NOPARACHUTE:0)|SDL_INIT_TIMER)) fatal("Error initializing SDL: %s\n",SDL_GetError());
  atexit(SDL_Quit);
  i=0;
  while(*v) switch(*v++) {
    case 'd': i|=SDL_DOUBLEBUF; break;
    case 'f': i|=SDL_FULLSCREEN; break;
    case 'h': i|=SDL_HWSURFACE; break;
    case 'n': i|=SDL_NOFRAME; break;