void ChatMessage::draw(const font_data& font, float alpha, int x, int y) const { Colour sendcol = sender_colour, msgcol = message_colour; sendcol.a *= alpha, msgcol.a *= alpha; Dim offset(0, 0); if (!sender.empty()) { offset = gl_printf(font, sendcol, x, y, "%s: ", sender.c_str()); x += offset.w; } offset = gl_printf(font, msgcol, x, y, message.c_str()); x += offset.w; print_dupe_string(*this, font, Pos(x, y), alpha); }
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()); } }
static void draw_player_inventory_slot(GameState* gs, ItemSlot& itemslot, int x, int y) { if (itemslot.amount > 0) { ItemEntry& ientry = itemslot.item.item_entry(); GLimage& itemimg = game_sprite_data[ientry.sprite].img(); gl_draw_image(itemimg, x, y); if (ientry.stackable) { gl_printf(gs->primary_font(), Colour(255, 255, 255), x + 1, y + 1, "%d", itemslot.amount); } } }
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); } }
static void print_dupe_string(const ChatMessage& cm, const font_data& font, const Pos& location, float alpha) { if (cm.exact_copies > 1) gl_printf(font, Colour(0, 191, 255, alpha * 255), location.x, location.y, " x%d", cm.exact_copies); }
void gl_draw( void ) { int i, j; GLfloat len, lmax, r[8], g[8], b[8], a; glClear( GL_COLOR_BUFFER_BIT ); for( i = 0; i < 8; i++ ) { for( j = 0; j < 3; j++ ) { if( fps ) { if( ! ( rand() % (int) ( fps * 16.0f ) ) ) { dir[i][j] = (GLfloat) ( rand() % 3 ) - 1; } phi[i][j] += dir[i][j] / fps; } } } for( i = 0; i < 8; i++ ) { r[i] = ( (GLfloat) sin( phi[i][0] ) + 1.0f ) / 2.0f; g[i] = ( (GLfloat) sin( phi[i][1] ) + 1.0f ) / 2.0f; b[i] = ( (GLfloat) sin( phi[i][2] ) + 1.0f ) / 2.0f; } if( fps ) { rx += vx / fps; ry += vy / fps; } glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0f, 0.0f, -8.0f ); glRotatef( rx, 1.0f, 0.0f, 0.0f ); glRotatef( ry, 0.0f, 1.0f, 0.0f ); a = alpha; lmax = 1.4f + 0.12f * bmode; glBegin( GL_QUADS ); for( len = lmax; len > 0.0f; len -= 0.12f ) { glColor4f( r[0], g[0], b[0], a ); glVertex3f( -len, -len, -len ); glColor4f( r[1], g[1], b[1], a ); glVertex3f( -len, -len, len ); glColor4f( r[2], g[2], b[2], a ); glVertex3f( -len, len, len ); glColor4f( r[3], g[3], b[3], a ); glVertex3f( -len, len, -len ); glColor4f( r[4], g[4], b[4], a ); glVertex3f( len, -len, -len ); glColor4f( r[5], g[5], b[5], a ); glVertex3f( len, -len, len ); glColor4f( r[6], g[6], b[6], a ); glVertex3f( len, len, len ); glColor4f( r[7], g[7], b[7], a ); glVertex3f( len, len, -len ); glColor4f( r[0], g[0], b[0], a ); glVertex3f( -len, -len, -len ); glColor4f( r[1], g[1], b[1], a ); glVertex3f( -len, -len, len ); glColor4f( r[5], g[5], b[5], a ); glVertex3f( len, -len, len ); glColor4f( r[4], g[4], b[4], a ); glVertex3f( len, -len, -len ); glColor4f( r[3], g[3], b[3], a ); glVertex3f( -len, len, -len ); glColor4f( r[2], g[2], b[2], a ); glVertex3f( -len, len, len ); glColor4f( r[6], g[6], b[6], a ); glVertex3f( len, len, len ); glColor4f( r[7], g[7], b[7], a ); glVertex3f( len, len, -len ); glColor4f( r[0], g[0], b[0], a ); glVertex3f( -len, -len, -len ); glColor4f( r[3], g[3], b[3], a ); glVertex3f( -len, len, -len ); glColor4f( r[7], g[7], b[7], a ); glVertex3f( len, len, -len ); glColor4f( r[4], g[4], b[4], a ); glVertex3f( len, -len, -len ); glColor4f( r[1], g[1], b[1], a ); glVertex3f( -len, -len, len ); glColor4f( r[2], g[2], b[2], a ); glVertex3f( -len, len, len ); glColor4f( r[6], g[6], b[6], a ); glVertex3f( len, len, len ); glColor4f( r[5], g[5], b[5], a ); glVertex3f( len, -len, len ); } glEnd(); if( fps && info ) { gl_printf( 0.7f, 0.7f, 0.7f, 1.0f, width - 114, height - 40, font, "%5.1f fps", fps ); } glFinish(); frames++; if( timer( &tv, 0 ) >= 0.2f ) { fps = (GLfloat) frames / timer( &tv, 1 ); frames = 0; } }