void runner_redraw(LandRunner * self) { All * a = global_a; #line 279 double t = - land_get_time(); add_time(); #line 282 redraw(); #line 284 t += land_get_time(); a->direct_speed_measure = t; }
void add_time(void) { All * a = global_a; a->frame_times [a->ftpos] = land_get_time(); a->ftpos += 1; if (a->ftpos >= a->FPS) { a->ftpos = 0; } }
void redraw(void) { #line 67 All * a = global_a; #line 69 if (a->load_after_redraw) { if (! a->overview) { render_loading_screen(); } #line 72 if (a->load_after_redraw == 1) { a->load_after_redraw = 2; } #line 74 else if (a->load_after_redraw == 2) { // wait for logic code to advance #line 74 ; } #line 77 if (a->load_after_redraw > 2) { a->load_after_redraw++; double t = land_get_time(); while (1) { if (! blocks_preload(game->blocks)) { a->load_after_redraw = 0; #line 84 if (a->overview) { overview_render_next(game->overview); } #line 86 break; } #line 87 if (land_get_time() > t + 0.01) { break; } } } #line 90 if (! a->overview) { #line 90 return ; } } float w = land_display_width(); float h = land_display_height(); //float fh = land_font_height(a->font) #line 97 if (a->title) { title_render(); } #line 98 else { #line 100 render(game, w, h); } if (a->show_fps) { double f1, f2; get_fps(& f1, & f2); land_text_pos(w, 0); land_font_set(a->font); land_color(a->text.r, a->text.g, a->text.b, a->text.a); land_print_right("FPS: %4d +- %-4d", (int) f1, (int) f2); land_print_right("%4d / sec", (int)(1.0 / a->direct_speed_measure)); } }
void input_tick(void) { All * a = global_a; #line 51 int count = 0; bool any = 0; for (int ti = 0; ti < 11; ti += 1) { double mx = land_touch_x(ti); double my = land_touch_y(ti); #line 57 bool holding = land_touch_down(ti); bool clicked = holding && land_touch_delta(ti); bool released = ! land_touch_down(ti) && land_touch_delta(ti); #line 61 if (! holding && ! released) { continue; } if (check_pause_button(mx, my)) { if (clicked) { input_toggle_pause(); } #line 66 return ; } #line 69 if (check_title_button(mx, my)) { a->show_map = 0; main_switch_to_title(0); #line 71 return ; } #line 74 if (check_menu(mx, my, released)) { break; } if (a->overview) { overview_click(game->overview, mx, my, clicked, released); break; } if (a->editor) { editor_click(mx, my, clicked, released); break; } if (! land_touch_down(ti)) { continue; } #line 87 any = 1; count++; #line 90 double rr = land_display_width() / 8 * 0.8; if (a->dpad == 2 || a->dpad == 3) { rr *= 1.5; } double dx = 0, dy = 0; #line 96 if (a->dpad > 3) { double p = 0.97; if (a->dpad == 4 || (a->dpad == 5 && count == 1)) { dx = mx - a->swipex; dy = my - a->swipey; a->swipex = a->swipex * p + mx * (1 - p); a->swipey = a->swipey * p + my * (1 - p); } if (! a->swipe) { a->swipe = 1; #line 107 if (a->dpad == 4) { if (land_get_time() < a->swipet + 0.25) { // double tap if (! a->swipej) { a->swipej = 1; } #line 111 else { // after heaving, just push // (so can lift+push, not lift+jump) #line 115 a->swipej = 0; } } #line 115 else { #line 117 a->swipex = mx; a->swipey = my; a->swipej = 0; dx = 0; dy = 0; } } #line 122 else if (a->dpad == 5) { a->swipex = mx; a->swipey = my; a->swipej = 0; dx = 0; dy = 0; } a->swipet = land_get_time(); } #line 129 else { #line 131 if (a->dpad == 5) { if (count == 1) { a->swipej = 0; } #line 134 if (count > 1) { a->swipej = 1; } } } #line 137 if (a->swipej) { a->jump = 1; } } #line 138 else { #line 140 double rx = rr; if (a->dpad == 1 || a->dpad == 3) { rx = land_display_width() - rr; } #line 143 double ry = land_display_height() - rr; if (a->dpad == 1 || a->dpad == 3) { rx = land_display_width() - rr; } #line 146 dx = mx - rx; dy = my - ry; } // move control // c // b d // a e // 9 f // 8 0 // 7 1 // 6 2 // 5 3 // 4 #line 160 bool move = 0; if (a->dpad == 4 || (a->dpad == 5 && count == 1)) { if (dx * dx + dy * dy > rr * rr / 256) { move = 1; } } #line 164 if (a->dpad < 4) { if ((fabs(dx) < rr && fabs(dy) < rr)) { if (dx * dx + dy * dy > rr * rr / 16) { move = 1; } } } #line 169 if (move) { double ang = atan2(dy, dx); // we use 16 subdivisions, the main directions get 12 // out of that and the diagonals 4 ang += pi / 16; if (ang < 0) { ang += pi * 2; } #line 176 int i = ang * 8 / pi; if (i <= 3 || i >= 0xd) { a->right = 1; } #line 179 if (i >= 1 && i <= 7) { a->down = 1; } #line 181 if (i >= 5 && i <= 0xb) { a->left = 1; } #line 183 if (i >= 9) { a->up = 1; } #line 185 a->swipet = land_get_time(); } // jump control if (a->dpad == 4 || a->dpad == 5) { #line 188 ; } #line 188 else { #line 191 double rx = land_display_width() - rr; double ry = land_display_height() - rr; if (a->dpad == 1 || a->dpad == 3) { rx = rr; } #line 195 dx = mx - rx; dy = my - ry; if (dx * dx + dy * dy < rr * rr) { a->jump = 1; } } } #line 200 if (! any) { if (a->dpad == 5) { a->swipej = 0; } #line 203 if (a->dpad == 4) { if (a->swipe) { a->swipet = land_get_time(); } } #line 206 a->swipe = 0; } }