void ship_draw(const ship *s) { // draw the bullets bullet_draw(s->bullets); // draw the ship const uint32_t bitmap_width = al_get_bitmap_width(s->bitmap); const uint32_t bitmap_height = al_get_bitmap_height(s->bitmap); if (s->attr.is_immune) { const double time_passed = al_get_time() - s->attr.time_stamp; if (time_passed - floor(time_passed) < 0.5) { al_draw_tinted_scaled_rotated_bitmap(s->bitmap, color_gray(), bitmap_width / 2, bitmap_height / 2, s->center.x, s->center.y, SHIP_SIZE / bitmap_width, SHIP_SIZE / bitmap_height, s->direction, 0); } else { al_draw_scaled_rotated_bitmap(s->bitmap, bitmap_width / 2, bitmap_height / 2, s->center.x, s->center.y, SHIP_SIZE / bitmap_width, SHIP_SIZE / bitmap_height, s->direction, 0); } } else { al_draw_scaled_rotated_bitmap(s->bitmap, bitmap_width / 2, bitmap_height / 2, s->center.x, s->center.y, SHIP_SIZE / bitmap_width, SHIP_SIZE / bitmap_height, s->direction, 0); } #ifdef DEBUG al_draw_circle(s->center.x, s->center.y, 5, al_map_rgb(255, 0, 0), 3); #endif }
bool draw_window(Window* window) { if (window->user_backed) { return true; } //blit_layer(window->layer, window->content_view->layer, rect_make(window->content_view->frame.origin, window->layer->size), rect_make(point_zero(), window->content_view->frame.size)); //return; //if window is invisible, don't bother drawing if (!window->layer->alpha) return false; //if window has a redraw handler, call it if (window->redraw_handler) { //draw_rect(window->content_view->layer, rect_make(point_zero(), window->content_view->frame.size), window->content_view->background_color, THICKNESS_FILLED); event_handler redraw = window->redraw_handler; redraw(window, NULL); blit_layer(window->layer, window->content_view->layer, rect_make(window->content_view->frame.origin, window->layer->size), rect_make(point_zero(), window->content_view->frame.size)); window->last_draw_timestamp = time(); return true; } //if window doesn't need to be redrawn, no work to do if (window->layer->alpha == 1.0 && !window->needs_redraw) { return false; } //dirtied = 1; //paint window draw_rect(window->layer, rect_make(point_zero(), window->frame.size), window->border_color, window->border_width); //only draw a title bar if title_view exists if (window->title_view) { //update title label of window Label* title_label = (Label*)array_m_lookup(window->title_view->labels, 0); title_label->text = window->title; draw_view(window->title_view); blit_layer(window->layer, window->title_view->layer, rect_make(point_zero(), window->layer->size), window->title_view->frame); draw_rect(window->layer, window->title_view->frame, color_gray(), 2); } //only draw the content view if content_view exists if (window->content_view) { draw_view(window->content_view); //if there's a redraw callback, call it if (window->redraw_handler) { event_handler redraw = window->redraw_handler; redraw(window, NULL); } blit_layer(window->layer, window->content_view->layer, rect_make(window->content_view->frame.origin, window->layer->size), rect_make(point_zero(), window->content_view->frame.size)); //draw dividing border between window border and other content if (window->border_width) { //inner border draw_rect(window->content_view->layer, rect_make(point_zero(), window->content_view->frame.size), color_gray(), window->border_width); } } //draw window border draw_rect(window->layer, rect_make(point_zero(), window->frame.size), color_black(), 1); window->needs_redraw = 0; window->last_draw_timestamp = time(); return true; }