Jump to content
Banner by ~ Wizard
  • entries
    21
  • comments
    131
  • views
    2,911

It Starts to Look Somewhat Awesome! :D


Rikifive

1,570 views

Step by step, I'm slowly finishing the status screen. :) 
I've added things here and there and now it starts to look like a legit thing! :yay: 

 

A thing, where I got stuck for a little moment was: How to write a single line of text with multiple colors,

that will be centered like this? :ooh: 
 

And turns out, that it is kinda messy to achieve and there were some maths behind that one as well, because why not! :muffins: 
First of all, again, I'm not sure if I approached that in the best way, but well, it works! :P 

The thing with coloring text is, that I had to set the font color before drawing the text- so to make it have multiple colors, I had to split it into parts and basically draw each word/part separately, with correct positions to make it all be drawn next to each other in one line. 


The tool that was helpful there was a function, that calculated the width of the string (text).

 

So as I've mentioned ages ago, I wanted to do this:

Quote


Here are some examples of the formula&format, that will be displayed there:
POWER     20
Without any bonuses, it will just show its plain total value in white color.

POWER     22 (17+3+10%)
That's how it will be displayed, when wearing an equipment that will give bonus points to the parameter.
There will be two types of that bonus: Additional Point Increment and Bonus Multiplier.

POWER     cHWDbIt.gif
That's how it will be displayed, when having a status/buff, that multiplies the parameter.
The value will go RED when getting below 0%, due to debuffs, for example.

POWER     H9oS4EL.gif
And that's the full formula. The color from status/buff takes priority.

 

 

First thing first, I needed to calculate the width of each part to know how much space it will take. 


To show how that does look like... let's take the second possible number as for example:

rscfklI.png

That part contains [ +3 ]

First, I needed to get the value form the character.

var value = actor.eq_bonus_mhp

This will store the character's MAX HP bonus from equipment into a variable.


Then, since [ + ] isn't drawn by default, but [ - ] is, I had to put an 'if statement' to check if that value is above or below 0 and add [ + ] if above 0 or leave it without symbols when below 0.

if value > 0 { sym = "+" } else { sym = "" }

If the value is greater than 0, store [ + ] in a [ sym ] variable. Otherwise leave it empty.

 

and now merging things together...
that [ +3 ] will be a string:

string = sym + value

where sym either has [ + ] or nothing; value is a number.

Now the last part, just get its width. ;) 

value_width = string_width(string)

This will store the string's width in a [ value_width ] variable.

^_^ -{ Well that was complex, wasn't it? )

 

:ooh: -{ But what if the character wouldn't have any bonus? Is there any need to draw "+0"? )

( Of course not you silly! }- ^_^

For that let's use another 'if statement' before merging stuff:

if value == 0 { string = ""; value_width = 0 } else { ...

Putting that before merging will simply check if the value equals 0. If it does, it will leave the string empty and we manually can tell, that the width will be just 0, thus basically skipping that part.

 

And now we have one part configured...

i3YdFRj.png

 

Now do the same for the others...

Ktv5ya6.png
And you probably got your own lame code :derp: 

:P -{ This looks funnier, doesn't it? )

So as you can see, I specified the center value - 344th pixel (horizontally) then calculated widths of the parts and merged it all in the end.
The last line sums everything up ~ divides the result by 2 to make it centered, by moving the 50% of the text to the left. The rest 50% will go to the right.

 

Now the drawing method is simpler, simply put the part in the result we got, then add its width to a variable, then put the second part in the result+width; add its width to that variable; draw 3rd part in the result+width and so on...

 

So now that you've read (or not) that boring wall of text, let's head to the results. :wub: 

Note, that it's still a work in progress.

JwxNR2a.gif

  • Brohoof 6

11 Comments


Recommended Comments

That was a wonderful read. :D

So, recently I've finally got around to trying to program games of my own (I'm in the very very very early stages). Finally found some motivation to get back to it, and your posts really help me find the inspiration to go with that motivation, a combo necessary to actually get something done. Thanks Riki! :pinkie:

  • Brohoof 2
Link to comment

Glad to hear! ^_^ 

Oooh that's awesome! I'm really happy to hear that! :pinkie: Good luck with everything you'll be working on and don't forget to share the results, because I'm really curious! :yay: 

  • Brohoof 2
Link to comment

Will do! Might be with just you at first, til I have something I can be proud of. Not a finished product, but something more than scraps of code, and getting a bit of advice here and there would be awesome. ;)

  • Brohoof 2
Link to comment

That is awesome! And it is so simple to code when you look at it in chunks! I just wish I had the time and patience to sit down and try a project like this. Well done with what you have so far @Rikifive! :D 

  • Brohoof 2
Link to comment
41 minutes ago, Totally Lyra said:

Will do! Might be with just you at first, til I have something I can be proud of. Not a finished product, but something more than scraps of code, and getting a bit of advice here and there would be awesome. ;)

Oh sure, that's understandable. :) No need to haste, it's good to start small. ;) While I'm not an expert (I still don't know many things), you can count on me to at least take a look. :) 

 

37 minutes ago, Sparklefan1234 said:

@Rikifive Awesome work as always, My Friend! :D

Question:

 

"What is the main objective of your game?"

 

Thank You *so* much for answering my question! :D

Thank you very much! :wub: 

Basically to go through the story seen in MLP, but in a game with RPG elements. To be honest idea and my vision both, sound and look great, but how it will turn out- no idea, it's kinda an experiment if I could say so. I mean, there are plots (let's say, episodes), that will work perfectly in the game, some however, not exactly, but I'll try my best to make it all work as a one big storyline.

You're welcome! :) 

1 minute ago, Nye said:

That is awesome! And it is so simple to code when you look at it in chunks! I just wish I had the time and patience to sit down and try a project like this. Well done with what you have so far @Rikifive! :D 

Yep, even though there may be a wall of text in the end, it's always easier to follow its step-by-step creation. ^_^ I perfectly know what you feel - While I do have patience, I don't really have time, hence it goes so slow. :P 

Either way, thank you! :wub: 

Edited by Rikifive
  • Brohoof 4
Link to comment
7 minutes ago, Nye said:

I just noticed that it has PlayStation controls. :) 

After playing on PlayStation for years, it's my preferred set of buttons. :P Xbox ones are still slightly confusing for me.

Nevertheless, I plan to support multiple types of buttons- you'll be able to set the ones you prefer in the settings. PlayStation and Xbox buttons will be there for sure, perhaps the PC set (the one with only numbers) as well, though I'm not sure if anybody will use it... :derp: 

  • Brohoof 2
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...