From: "Mathew Earle Reuther" <graymere@zipcon.net> > Does anyone have any code they'd be willing to share which draws some kind > of graphical representation of a percentage? I'm thinking of doing this > kind of a bar to track progression or status of certain fields. If anyone > else has some code they'd be willing to toss my way so I can work with it, > I'd be apprecative. :) Here comes a toss[1]: void send_percent_bar(struct char_data *ch, int percent) { int i; char buf[21]; if (percent>100) percent = 100; strcpy(buf, ""); for(i=1;i*5 <= percent;i++) strcat(buf, "*"); /* strcat ok - max length 20+\0 */ send_to_char(ch, "%s", buf); } This can be called like this: send_to_char(ch, "hitpoints: "); send_percent_bar(ch, (GET_HIT(ch) * 100) / GET_MAX_HIT(ch)); output (when at max hits): hitpoints: ******************** or with spells/skills: send_to_char(ch, "Magic missile: "); send_percent_bar(ch, GET_SKILL(ch, SPELL_MAGIC_MISSILE)); output (when 25% learned): Magic missile: ***** Welcor [1] mailer code. -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT