Archived

This topic is now archived and is closed to further replies.

louise

Displaying the score...and health

Recommended Posts

louise    122
How do people display the score and health in there games.. The game is about finished just needs to be polished and i''ve had my Dummies programming book lifted from the college library and i cant add the score and health display now. the Score & Health are ints. i''d ideally like to dislay them in the top right hand corner one under the other. Thank in advance for your help lads LOUISE

Share this post


Link to post
Share on other sites
Scheermesje    169
When you now the score and the health(you''ve got them in vars) then the only thing you need to do is put them on screen..

Are you using directx or opengl? For opengl Nehe has a tutorial about puting text on the screen.. I don''t now how this works in directx but just search for a tutorial about putting text to the screen

Goodluck

Share this post


Link to post
Share on other sites
remi    150
Louise as u'r talking about a dummies game programming book, i guest it's Andre Lamothe's Windows Game Programming for Dummies, anyway correct me if i'm wrong

Well, what i get here are 2 ways of solving ur problem:

1.The first is the easiest but it doesn't look so pretty, u just need to put ur iScore and iHealth variables into a String and use the Draw_Text_GDI() function,that comes with the book's library,to draw the string on the screen. Well, u can use the sprintf() function to put ur variables into a string.

2.The second one may look more nice but a little bit hard than the first one(it also depends on what u'r already able to do ). u can create a BOB (that's how he named "sprite" in his book), and u draw numbers as BOB's frames(Load numbers from a *.BMP file) . Then for each number in the variable u draw the correct frame at the correct place. For example, u wanna draw 129, u first draw 1, the 2 and finally 9.

There are surely many other ways to attend the same purpose and mine are in no means the best, but that is how i do it.
I just hope it can help


[edited by - remi on May 1, 2002 8:48:14 AM]

Share this post


Link to post
Share on other sites
louise    122
Thanks Remi

Could you elaborate on the writing the string to screen.. thats if you can of course you might not have the info with ya!

Cheers Louise

AfterMath i dont get you. went to ur links could not see what you meant! Sites nice, although its very cluttered and does''nt make you want to use it! Then different strokes for different fokes!

Share this post


Link to post
Share on other sites
remi    150
Well Louise,
the book's library has a function called Draw_Text_GDI, u can use it to draw text on "any" surface u want, u can do it like this

      
//global variables

int iScore,iHealth;
char Str[100];
///and then in ur Game_Loop u do something like this

sprintf(Str,"SCORE : %d HEALTH : %d ",iScore,iHealth);
///u need to #include <string.h> before using sprintf


Draw_Text_GDI(Str,iXpos,iYpos,iColor,lpddsurface);
//iXpos and iYpos are the coordinates were u'r printing

//iColor the color

///lpddsurafce is a pointer to a surface, it may be ur primary

// or secondary surface, or whatever....surface:)



Hope u can understand that peace of code and that it helps

[edited by - remi on May 1, 2002 9:21:37 AM]

[edited by - remi on May 1, 2002 9:24:02 AM]

Share this post


Link to post
Share on other sites
remi    150

Ooooo no Louise, i just told u what i know and i'm sure u could have done idem.
u can look at what i did, i use Sprites to draw Score and Time in my first game(after reading the same Book )
This is the link


[edited by - remi on May 1, 2002 10:13:46 AM]

Share this post


Link to post
Share on other sites