void CombatGameInst::draw(GameState *gs) { GameView& view = gs->view(); SpriteEntry& spr = game_sprite_data[sprite]; Colour draw_colour = effects().effected_colour(); if (cooldowns().is_hurting()) { float s = 1 - hurt_alpha_value(cooldowns().hurt_cooldown); draw_colour = draw_colour.multiply(Colour(255, 255 * s, 255 * s)); } int sx = x - spr.width() / 2, sy = y - spr.height() / 2; gl_draw_sprite(view, sprite, sx, sy, vx, vy, gs->frame(), draw_colour); effects().draw_effect_sprites(gs, Pos(sx, sy)); if (is_resting) { GLimage& restimg = game_sprite_data[get_sprite_by_name("resting")].img(); gl_draw_image(view, restimg, x - spr.width() / 2, y - spr.height() / 2); } CoreStats& ecore = effective_stats().core; //Draw health bar int healthbar_offsety = 20; if (target_radius > 16) healthbar_offsety = target_radius + 8; if (ecore.hp < ecore.max_hp) { const BBox statbox(x - 10, y - healthbar_offsety, x + 10, y - healthbar_offsety + 5); gl_draw_statbar(view, statbox, ecore.hp, ecore.max_hp); } }
void AnimatedInst::draw(GameState* gs) { GameView& view = gs->view(); if (sprite > -1) { GLimage& img = game_sprite_data[sprite].img(); int w = img.width, h = img.height; int xx = x - w / 2, yy = y - h / 2; if (!view.within_view(xx, yy, w, h)) return; if (!gs->object_visible_test(this)) return; Colour alphacol(255, 255, 255, 255 * timeleft / animatetime); gl_draw_sprite(view, sprite, xx, yy, orientx, orienty, gs->frame(), alphacol); } Colour wd(255 - textcol.r, 255 - textcol.g, 255 - textcol.b); if (text.size() > 0) { Colour alphacol = textcol; if (timeleft > -1) { int fade = 100 * timeleft / animatetime; alphacol = Colour(textcol.r + fade * wd.r / 100, textcol.g + fade * wd.g / 100, textcol.b + fade * wd.b / 100, 255 - fade); } gl_printf(gs->primary_font(), alphacol, x - view.x, y - view.y, "%s", text.c_str()); } }
void SidebarNavigator::NavigationOption::draw_icon(GameState* gs, bool selected) { Colour col; if (selected) { col = COL_SELECTED_VIEWICON; } else if (icon_bbox.contains(gs->mouse_x(), gs->mouse_y())) { col = COL_HOVER_VIEWICON; } gl_draw_sprite(icon, icon_bbox.x1, icon_bbox.y1, col); }
void StoreInst::draw(GameState* gs) { Colour drawcolour; if (gs->object_radius_test(this, NULL, 0, player_colfilter, x, y, 24)) { drawcolour = Colour(255, 255, 100, 255); } if (last_seen_spr > -1) { gl_draw_sprite(gs->view(), last_seen_spr, x - TILE_SIZE / 2, y - TILE_SIZE / 2, drawcolour); } }
void EffectStats::draw_effect_sprites(GameState* gs, const Pos& p) { GameView& view = gs->view(); for (int i = 0; i < EFFECTS_MAX; i++) { if (effects[i].t_remaining > 0) { EffectEntry& eentry = game_effect_data.at(effects[i].effectid); if (eentry.effected_sprite > -1) { Colour drawcolour(255, 255, 255, 255 * draw_alpha(effects[i])); gl_draw_sprite(view, eentry.effected_sprite, p.x, p.y, drawcolour); } } } }
static void draw_option(GameState* gs, const BBox& bbox, bool option_set, sprite_id sprite, const char* text) { Colour bbox_col = option_set ? COL_WHITE : COL_FILLED_OUTLINE; if (bbox.contains(gs->mouse_pos())) { bbox_col = COL_GOLD; } gl_draw_sprite(sprite, bbox.x1, bbox.y1, COL_WHITE.with_alpha(option_set ? 255 : 100)); /* Draw item name */ gl_printf_bounded(gs->primary_font(), option_set ? COL_WHITE : COL_MID_GRAY, bbox.x1 + TILE_SIZE * 1.25, bbox.y1 + TILE_SIZE / 2, bbox.width() - TILE_SIZE, true, "%s", text); gl_draw_rectangle_outline(bbox, bbox_col); }
void ItemInst::draw(GameState* gs) { GameView& view = gs->view(); ItemEntry& ientry = item.item_entry(); SpriteEntry& spr = game_sprite_data.at(ientry.sprite); int w = spr.width(), h = spr.height(); int xx = x - w / 2, yy = y - h / 2; if (!view.within_view(xx, yy, w, h)) return; if (!gs->object_visible_test(this)) return; gl_draw_sprite(view, ientry.sprite, xx, yy, 0, 0, gs->frame()); if (ientry.stackable && quantity > 1) { gl_printf(gs->primary_font(), Colour(255, 255, 255), xx - view.x + 1, yy - view.y + 1, "%d", quantity); } }
void gl_draw_sprite(const GameView& view, sprite_id sprite, int x, int y, const Colour& c) { gl_draw_sprite(sprite, x - view.x, y - view.y, c); }