Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / graphical font issues

Author
Message
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Mar 2012 04:15
Hi Guys,

I'm having some issues here not sure what the 'elegant' solution is.

My game so far looks like this:



You'll notice the score is just plain text.

I am an artist so I made 2 different kinds of graphical fonts. One was an animated sprite with the numbers 0-9 from top to bottom.

I was able to get this to 'play' but I can not figure out how to get it to know that it needs to print a value of 620 for example.

The other set I made was individual graphics of 0.png, 1.png, 2.png, and so on through 9.png

So those work fine when I say paste image, it puts it there. But then again -- I have no idea how to convert the value of 620 into 6,2,0 in order and paste those images in order.

So that's my question how would I go about doing that?

-----------------------
Alternately if that is not possible I have found by loading a particular font, and using this code:



This looks OK .. but if my customer does not have the font Freebooter what will happen?
Can I put freebooter.ttf in my game folder without having to install it on the customers OS?

And finally .. if I'm just taking the entire wrong angle on this please point me in the right direction!

Thank you.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 18th Mar 2012 05:56
I would go with this approach.

Quote: "
The other set I made was individual graphics of 0.png, 1.png, 2.png, and so on through 9.png

So those work fine when I say paste image, it puts it there. But then again -- I have no idea how to convert the value of 620 into 6,2,0 in order and paste those images in order.
"


In this snippet I use two function, one to return the ascii value of each character and the other returns the actual value of each character.



Hope this is helpful. Cheers
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Mar 2012 06:33 Edited at: 18th Mar 2012 06:42
wickedX beat me to it but here's some code i whipped up using actual (individual) images, as suggested:



it's a matter of extracting each digit from the full score and pasting the appropriate image.

if your individual (hand-made) images are varying widths, you'd have to work that into the routine for pasting, ie:



...something like that.

in the code provided, i went with 8 digits no matter the score, as some games do. ie, "00001225" vs "1225"; a sort of "odometer" display/effect but you're free to do whatever you want.

good luck

add:

Quote: "if my customer does not have the font "


you can include any font that you have the right to include

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Mar 2012 16:53
Thanks to both of you

I'll have to go over these two examples today and see if I can implement something similar and get a screenshot with a working graphical font.

Much appreciated.
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Mar 2012 19:59 Edited at: 18th Mar 2012 20:17
Okay I'm super close now with one minor issue.

Because my score does not have leading zeros I had to add +10000000 to the score to get it to work otherwise it behaves extremely oddly.

Other than that it works well. You'll note on the screen shot the plain text score just below the graphical score is the same (good!).



The Code I'm using is this



A couple of things to explain

- the reason I'm adding +575 to the (x*18) is thats how I get it to be where I want on the screen
- the line "TempGraphicScore=(CurrentScore+10000000)" is how I had to get the number to work because otherwise in the given example the score of 1170 prints out something like "11700000" which is really confusing
- the reason I do this " New_Val=Position_Val+200" is because my image numbers for these are 200 through 209 so if the value is 3 I add +200 = 203 and it calls image 203; which is the graphical 3.

So any tips on how to get it to have 8 position accuracy without adding +10000000 ?

Thanks for the help guys much appreciated.
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Mar 2012 23:19 Edited at: 18th Mar 2012 23:20
Ok I figured the above out by using the Len() command like so



Now I just need to either right justify OR center the output and I'm set
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 18th Mar 2012 23:42
You could add the leading zero's. I think it would look nice. This is similar to the code used in a game I'm working on.

erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Mar 2012 23:51
Perfecto .. thanks WickedX ; that worked nicely

screenshot

WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 19th Mar 2012 00:01
Glad I could help. Btw your game is looking really good. I only wish I had that kind of artistic ability. Keep up the good work.
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 19th Mar 2012 03:17 Edited at: 19th Mar 2012 03:27
WickedX ; thank you for the kind compliments.

I've been working on graphics since 1995 when I discovered DOOM II and just started programming recently so I have a real 'head start' in that area.

I'm hoping that the polish I can give my games will add a pleasant atmosphere and vibrance that will perhaps make up for some of my naivete' in game design or programming skills. Guess well see about that

Thanks for all your help !

PS: if I can repay the favor let me know .. although I'm not sure how I would demonstrate how to do a graphic exactly but I could try
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 19th Mar 2012 05:13 Edited at: 20th Mar 2012 02:54
It seems to me your programming skills have developed nicely as well. You made it a pleasure by stating what you wished to accomplish and showing only relevant code. I also enjoyed seeing the development screenshots.

Quote: "
PS: if I can repay the favor let me know .. although I'm not sure how I would demonstrate how to do a graphic exactly but I could try
"


I’m not sure how you can demonstrate how to do graphics either. I have plenty of reference material on that subject. It’s either something your born with or have spent a lot of time developing those skills.

Thank you for the offer, though.
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 20th Mar 2012 02:40
No problem, if you ever have a graphic and want a tip on how to polish it up a bit let me know maybe I can make a suggestion

Login to post a reply

Server time is: 2024-11-22 05:07:31
Your offset time is: 2024-11-22 05:07:31