Custom font scorekeeping with negative numbers and rightward expansion
Armelline
Member, PRO Posts: 5,372
Wondering if there's any interest in me breaking this off and making it into a template. I ask because I did some fairly extensive searching before trying to solve the first problem and moderate searching before trying to solve the second. Neither yielded any helpful results.
So the game I'm polishing up at the moment deals in fairly large scores, which can go heavily into the negative too. It was essential I use a custom font. My starting point was tshirtbooth's custom font scoring tutorial. This is a great start but has two big limitations:
1. It cannot handle negative numbers.
This was a big issue for me. The game I'm making is fairly punishing - if you aren't fast enough you'll end up with a negative score. Perhaps even a pretty big one. tshirtbooth's method is great for positive numbers but couldn't handle negative ones. I expect there is a better and more elegant solution, but the solution I came up with was to use abs() to invert the negative score into a positive one and use that number to power the scorekeeping when the score dipped into negatives. A simple +/- at the start of the score shows if it's positive or negative.
2. You need to pre-place all the possible numbers.
Let's say you want to track a score with a possible upper limit of 999. That means placing three actors - 000 - and updating each one as the score changes. Adding 1 gives you 001, adding 65 gives 065, adding 156 gives 156 etc. This is great when scores are smallish, and I opted to use this method in a previous game because it just looked better. For the game I'm finishing up at the moment, though, the scores get big. Into the millions, theoretically. So I'd end up with 0000000 when a player started. Not pretty. Instead, I'm growing the score to the right, so if the user has a score of 1243 they see 1243, not 0001243. If they have 10, they see 10, not 0000010. If their score drops, the numbers shift back to the left.
I'm starting to ramble, so I'll cut to the chase. Would anyone be interested in a template for this kind of score keeping Alternatively, can anyone point me at a template that does the same things so I can compare their method to mine, and see if I can optimise mine?
I'm not sure if I'll have time in the immediate future to make such a template, but if there's interest it'll motivate me to at least try
So the game I'm polishing up at the moment deals in fairly large scores, which can go heavily into the negative too. It was essential I use a custom font. My starting point was tshirtbooth's custom font scoring tutorial. This is a great start but has two big limitations:
1. It cannot handle negative numbers.
This was a big issue for me. The game I'm making is fairly punishing - if you aren't fast enough you'll end up with a negative score. Perhaps even a pretty big one. tshirtbooth's method is great for positive numbers but couldn't handle negative ones. I expect there is a better and more elegant solution, but the solution I came up with was to use abs() to invert the negative score into a positive one and use that number to power the scorekeeping when the score dipped into negatives. A simple +/- at the start of the score shows if it's positive or negative.
2. You need to pre-place all the possible numbers.
Let's say you want to track a score with a possible upper limit of 999. That means placing three actors - 000 - and updating each one as the score changes. Adding 1 gives you 001, adding 65 gives 065, adding 156 gives 156 etc. This is great when scores are smallish, and I opted to use this method in a previous game because it just looked better. For the game I'm finishing up at the moment, though, the scores get big. Into the millions, theoretically. So I'd end up with 0000000 when a player started. Not pretty. Instead, I'm growing the score to the right, so if the user has a score of 1243 they see 1243, not 0001243. If they have 10, they see 10, not 0000010. If their score drops, the numbers shift back to the left.
I'm starting to ramble, so I'll cut to the chase. Would anyone be interested in a template for this kind of score keeping Alternatively, can anyone point me at a template that does the same things so I can compare their method to mine, and see if I can optimise mine?
I'm not sure if I'll have time in the immediate future to make such a template, but if there's interest it'll motivate me to at least try
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Comments
http://www.stormystudio.com/game_templates/hearts_score.html
Edit: see my post below.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Score: 1
but also
Score: 135324563
Making the leading 0s invisible leads to odd results in this situation. I'm not offering a template solving a problem quite so simple.
There doesn't seem to be any interest in a template though, so it's all kinda moot
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Ah, okay, I just go it. In that case you'd have to do some fancy footwork by moving the actors to a certain position based on the value of the score. You're right, that is kind of a pain.
I added a rule to this demo (not mine) to show you what I mean, but this doesn't take into account my Aha! moment above.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
What I offered in my original post was a template that takes custom fonts for scores and adds two benefits: Working negative numbers, and expansion to the right (and back to the left when the number decreases again).
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Constrain self.position.X to:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Would love to see your method when you have the time to post it.
Have a good one!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User