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;
}
}
}
|