specifically, the elapsed time between calls varies much more with
GTK than it does under Windows. Therefore, I now take my own time
readings on every timer call, and this appears to have made the
animations run at closer to the same speed between platforms. Having
done that, I decided some of them were at the _wrong_ speed, and
fiddled with each game's timings as well.
git-svn-id: svn://svn.tartarus.org/sgt/puzzles@4189
cda61777-01e9-0310-a592-
d414129be87e
enum { LEFT, RIGHT, UP, DOWN, UP_LEFT, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT };
#define GRID_SCALE 48.0F
-#define ROLLTIME 0.1F
+#define ROLLTIME 0.13F
#define SQ(x) ( (x) * (x) )
#define COORD(x) ( (x) * TILE_SIZE + BORDER )
#define FROMCOORD(x) ( ((x) - BORDER + TILE_SIZE) / TILE_SIZE - 1 )
-#define ANIM_TIME 0.1F
-#define FLASH_FRAME 0.1F
+#define ANIM_TIME 0.13F
+#define FLASH_FRAME 0.13F
#define X(state, i) ( (i) % (state)->w )
#define Y(state, i) ( (i) / (state)->w )
#include <stdarg.h>
#include <string.h>
+#include <sys/time.h>
+
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
GdkGC *gc;
int bbox_l, bbox_r, bbox_u, bbox_d;
int timer_active, timer_id;
+ struct timeval last_time;
struct font *fonts;
int nfonts, fontsize;
config_item *cfg;
{
frontend *fe = (frontend *)data;
- if (fe->timer_active)
- midend_timer(fe->me, 0.02); /* may clear timer_active */
+ if (fe->timer_active) {
+ struct timeval now;
+ float elapsed;
+ gettimeofday(&now, NULL);
+ elapsed = ((now.tv_usec - fe->last_time.tv_usec) * 0.000001F +
+ (now.tv_sec - fe->last_time.tv_sec));
+ midend_timer(fe->me, elapsed); /* may clear timer_active */
+ fe->last_time = now;
+ }
return fe->timer_active;
}
void activate_timer(frontend *fe)
{
- if (!fe->timer_active)
+ if (!fe->timer_active) {
fe->timer_id = gtk_timeout_add(20, timer_func, fe);
+ gettimeofday(&fe->last_time, NULL);
+ }
fe->timer_active = TRUE;
}
#define TILE_BORDER 1
#define WINDOW_OFFSET 16
-#define ROTATE_TIME 0.1F
-#define FLASH_FRAME 0.05F
+#define ROTATE_TIME 0.13F
+#define FLASH_FRAME 0.07F
enum {
COL_BACKGROUND,
#define COORD(x) ( (x) * TILE_SIZE + BORDER )
#define FROMCOORD(x) ( ((x) - BORDER + 2*TILE_SIZE) / TILE_SIZE - 2 )
-#define ANIM_TIME 0.1F
-#define FLASH_FRAME 0.1F
+#define ANIM_TIME 0.13F
+#define FLASH_FRAME 0.13F
#define X(state, i) ( (i) % (state)->w )
#define Y(state, i) ( (i) / (state)->w )
HPEN *pens;
HRGN clip;
UINT timer;
+ DWORD timer_last_tickcount;
int npresets;
game_params **presets;
struct font *fonts;
void activate_timer(frontend *fe)
{
- fe->timer = SetTimer(fe->hwnd, fe->timer, 20, NULL);
+ if (!fe->timer) {
+ fe->timer = SetTimer(fe->hwnd, fe->timer, 20, NULL);
+ fe->timer_last_tickcount = GetTickCount();
+ }
}
static frontend *new_window(HINSTANCE inst)
PostQuitMessage(0);
return 0;
case WM_TIMER:
- if (fe->timer)
- midend_timer(fe->me, (float)0.02);
+ if (fe->timer) {
+ DWORD now = GetTickCount();
+ float elapsed = (float) (now - fe->timer_last_tickcount) * 0.001F;
+ midend_timer(fe->me, elapsed);
+ fe->timer_last_tickcount = now;
+ }
return 0;
}