|
|
| Displaying HP |
|
HappyBoy
Member #13,462
September 2011
|
How do I display numeric HP, like in a Final Fantasy RPG game? NOTE: I am a super, super noob, so please be sure that any answers or example codes are spoon-fed to me painstakingly clearly and fully; please do not underestimate my noobness. |
|
Trent Gamblin
Member #261
April 2000
|
textprintf_ex or al_draw_textf depending on your Allegro version.
|
|
Niunio
Member #1,975
March 2002
|
BTW, what programming language are you using?::) ----------------- |
|
North~
Member #12,192
August 2010
|
Trent said: textprintf_ex or al_draw_textf depending on your Allegro version. Considering that we shouldn't "underestimate your noobyness", I'll assume you're using A4 since A5 is more complicated to setup so, with that being said: int HP = 100; textprintf_ex(screen,font,5,5,makecol(255,255,255),-1,"Health: %d",HP); A little not-so-pseudo-code for you to use to your hearts content. Also. Don't blit to the screen. Use double buffering. 1BITMAP* Buffer = create_bitmap(SCREEN_W,SCREEN_H);
2
3//Loop
4while(1)
5{
6clear_bitmap(Buffer);
7
8// Blit whatever here to the buffer.
9
10blit(Buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
11}
-------------------------------------------------- If this is possible if you don't correctly initialize memory, it should be a priority of the highest order. |
|
Trent Gamblin
Member #261
April 2000
|
DOUBLE BUFFER BONUS!!!
|
|
North~
Member #12,192
August 2010
|
Trent Gamblin said: DOUBLE BUFFER BONUS!!! I'm not the best at problem solving or programming concept in general so when someone has a problem that I actually can answer, I go all out with it xD -------------------------------------------------- If this is possible if you don't correctly initialize memory, it should be a priority of the highest order. |
|
Trent Gamblin
Member #261
April 2000
|
Cool man.
|
|
HappyBoy
Member #13,462
September 2011
|
I'm using Allegro 4.2.3. Here's my code right now: int main () textout_ex(Buffer , font , hp1.c_str() , 10 , 10 , makecol(255,255,255) , makecol(0,0,0)); textprintf_ex(Buffer , font , 10 , 30 , makecol(255,255,255) , -1 , "HP: %s" , hp1.c_str()); blit (Buffer , screen , 0, 0, 0, 0, 640, 480); readkey (); // just waits for user to press any key to continue Notice that we are displaying HP. But, it's a string rather than an integer, so I don't know how to make this value go down when I get hit. Lots of games display your HP, so this must be simple, no? |
|
Trent Gamblin
Member #261
April 2000
|
Use %d instead of %s and pass an int.
|
|
HappyBoy
Member #13,462
September 2011
|
Solved! Thank you so much, Norther! Hugs Norther PS. Huh??? What is Double Buffering? Could you please put it into my updated code? ----------------- int main () while (done == false) textprintf_ex(Buffer,font,5,5,makecol(255,255,255),-1,"Health: %d", HP ); clear_bitmap (Buffer); readkey (); // just waits for user to press any key to continue Please do not answer in the format that Trent Gamblin did. I had no idea what he meant. As I said, I am a complete n00b and will not understand what you mean unless I see the code on action. |
|
Trent Gamblin
Member #261
April 2000
|
Funny how you will not understand, yet I was the only one to mention %d which is what you ended up using. Stop being a lazy prick or maybe people like me won't help you next time. For the record HappyBoy said: be sure that any answers or example codes are spoon-fed to me painstakingly clearly and fully This is being lazy. HappyBoy said: Please do not answer in the format that Trent Gamblin did. And this is being a prick.
|
|
Jonatan Hedborg
Member #4,886
July 2004
|
Why are you even helping this entitled-acting child? This might be the worst case of noob-rudeness I've seen on this forum, and we've had a LOT. Judging by his answers, he lacks the basic level of engagement and/or willingness to search for answers to learn programming, so stop wasting your time.
|
|
Tobias Dammers
Member #2,604
August 2002
|
Read this: http://www.catb.org/~esr/faqs/smart-questions.html This is actually more help than you deserve after showing such attitude. --- |
|
Matthew Leverton
Supreme Loser
January 1999
|
Jonatan Hedborg said: This might be the worst case of noob-rudeness I've seen on this forum, and we've had a LOT. You have to appreciate his honesty. Tobias Dammers said: This is actually more help than you deserve after showing such attitude. Attitude? Have a lot of thin skin? That page is incredibly useless. The intersection of the people willing to read all of that and the people who ask dumb questions is empty. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Matthew Leverton said: That page is incredibly useless. The intersection of the people willing to read all of that and the people who ask dumb questions is empty. You made me L0L. And I never say L0L. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
North~
Member #12,192
August 2010
|
Tobias Dammers said: Read this: I still remember that raging frenchman who came here and asked a beginner level question. When we responded with answers about googling and searching the forum, his response contained a commodious amount of profanity, vulgarity, and what I like to call the Angry Ghetto Six Year Old Syndrome :x @OP: There's only one thing wrong with the double buffering you have now and that's the fact that you made the buffer (800,600) bigger than the screen (640,480). they should be the same size (unless you're doing some sort of software map scrolling, in which case I don't think that's what you're getting at.) -------------------------------------------------- If this is possible if you don't correctly initialize memory, it should be a priority of the highest order. |
|
|