Revision 250
in-game timer
proj_func.c | ||
---|---|---|
40 | 40 |
case D_BREAK_CODE : key_presses.d_pressed = 0; break; |
41 | 41 |
case CTRL_MAKE_CODE : key_presses.ctrl_pressed = 1; break; |
42 | 42 |
case CTRL_BREAK_CODE : key_presses.ctrl_pressed = 0; break; |
43 |
case PLUS_MAKE_CODE : key_presses.plus_pressed = 1; break; |
|
44 |
case PLUS_BREAK_CODE : key_presses.plus_pressed = 0; break; |
|
45 |
case MINUS_MAKE_CODE : key_presses.minus_pressed = 1; break; |
|
46 |
case MINUS_BREAK_CODE : key_presses.minus_pressed = 0; break; |
|
43 |
case PLUS_MAKE_CODE : key_presses.plus_pressed = 1; update_scale(); break;
|
|
44 |
case PLUS_BREAK_CODE : key_presses.plus_pressed = 0; update_scale(); break;
|
|
45 |
case MINUS_MAKE_CODE : key_presses.minus_pressed = 1; update_scale(); break;
|
|
46 |
case MINUS_BREAK_CODE : key_presses.minus_pressed = 0; update_scale(); break;
|
|
47 | 47 |
} |
48 | 48 |
} |
49 | 49 |
} |
... | ... | |
181 | 181 |
return &key_presses; |
182 | 182 |
} |
183 | 183 |
|
184 |
int32_t get_mouse_X(void) { return mouse_x; }
|
|
184 |
int32_t* get_mouse_X(void) { return &mouse_x; }
|
|
185 | 185 |
|
186 |
int32_t get_mouse_Y(void) { return mouse_y; }
|
|
186 |
int32_t* get_mouse_Y(void) { return &mouse_y; }
|
|
187 | 187 |
|
188 | 188 |
double get_mouse_angle(gunner_t *p) { |
189 | 189 |
return atan2(gunner_get_y_screen(p) - mouse_y, mouse_x - gunner_get_x_screen(p)); |
190 | 190 |
} |
191 |
|
|
192 |
text_timer_t* (timer_ctor)(const font_t *fnt){ |
|
193 |
if(fnt == NULL) return NULL; |
|
194 |
text_timer_t *ret = malloc(sizeof(timer_t)); |
|
195 |
if (ret == NULL) return NULL; |
|
196 |
ret->time = 0; |
|
197 |
ret->text = text_ctor(fnt, "000s"); |
|
198 |
ret->array = text_get_string(ret->text); |
|
199 |
text_set_color(ret->text, 0x888888); |
|
200 |
return ret; |
|
201 |
} |
|
202 |
|
|
203 |
void (timer_update)(text_timer_t *p){ |
|
204 |
if (p->time >= 999) return; |
|
205 |
p->time++; |
|
206 |
p->array[2] = p->time % 10 + '0'; |
|
207 |
p->array[1] = (p->time/10) % 10 + '0'; |
|
208 |
p->array[0] = (p->time/100) % 10 + '0'; |
|
209 |
} |
|
210 |
|
|
211 |
void (timer_dtor)(text_timer_t *p){ |
|
212 |
if (p == NULL) return; |
|
213 |
text_dtor(p->text); |
|
214 |
free(p); |
|
215 |
} |
Also available in: Unified diff