void actor_draw(Actor * self) { int f = self->walk_tick >> 2; if (f > 4) { f = 8 - f; } int d = round(self->angle * 8 / (2 * pi) - 2); d &= 7; LandImage * im = self->kind->images[d + f * 8]; int w = land_image_width(im); int h = land_image_height(im); if (self->dead) { int y = self->anim_tick * h / 120; land_image_draw_partial(im, self->x - w / 2, self->y - h + y, 0, 0, w, h - y); } else { land_image_draw(im, self->x - w / 2, self->y - h); } if (self->selected) { land_color(1, 1, 0, 1); land_rectangle(self->x - w / 2, self->y - h, self->x + w / 2, self->y); } if (self->projectile) { land_image_draw(item_types[self->kind->projectile] ->images[d] , self->px, self->py - 32); } float hp = self->hp / self->max_hp; if (hp > 0.8) { land_color(0, 1, 0, 1); } else if(hp > 0.5) { land_color(1, 1, 0, 1); } else if(hp > 0.2) { land_color(1, 0, 0, 1); } else { land_color(1, 1, 1, 1); } hp *= w; land_filled_rectangle(self->x - w / 2, self->y - h - 5, self->x - w / 2 + hp, self->y - h - 2); }
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)); } }