Need Fresh Eyes for Number Extraction... meh, just read this.
Kamazar
Member Posts: 287
Ok, so I wanted to incorporate my own font for numbers used to show the score, so I set to work and created a formula for it. It's show below (note, this one only works for 3-digit numbers, but it can be easily modified to handle bigger ones). The variables that'll matter in the end are "a", "b", and "c". "n" is just a stepping stone. "O" stands for original number. And yeah, I'm totally disregarding remainders here. They don't matter at all, which is why I love it so.
O/100 = a
O - a(100)=n
n/10 = b
n - b(10) = c
The formula... or more accurately, the process, it's not really a formula.., anyways, I got it down on paper, so I decided to try it out on GameSalad. I set up a series of integer variables in the game setting. Score (O), A, B, C, and N. Then I put it together like so.
http://img30.imageshack.us/img30/2293/formulax.png
I had all the processing done on the same actor that's my background. I ran it, and I got a black screen. Obviously, I did something wrong. Help me out, guys. It in turn helps you, and I'll write a juicy wiki to sweeten the deal XD
O/100 = a
O - a(100)=n
n/10 = b
n - b(10) = c
The formula... or more accurately, the process, it's not really a formula.., anyways, I got it down on paper, so I decided to try it out on GameSalad. I set up a series of integer variables in the game setting. Score (O), A, B, C, and N. Then I put it together like so.
http://img30.imageshack.us/img30/2293/formulax.png
I had all the processing done on the same actor that's my background. I ran it, and I got a black screen. Obviously, I did something wrong. Help me out, guys. It in turn helps you, and I'll write a juicy wiki to sweeten the deal XD
Comments
You lost me at Ok,
=p
So I have a set of numbers as pictures, and I wanna use them as font. So what I want to be able to do is set up a rule like:
If "number" = 1, spawn actor "number1" (which is an actor with a picture of my number)
I can't necessarily do that with a number like 379, so I had to mathematically break it down. That's what the above process does. That way, I have a variable for the number in the hundred, ten, and one's place, letting me make a rule like the one I just showed you. Make more sense? It's simpler than it sounds.
you should try the floor and %(mod) functions.
a=O/100
b=floor(O%100)/10
c=floor(O%10)
Tried that out. Weird thing happened, though. Every time a number hits five, the number to the left will go up by one. So it'll go: 1, 2, 3, 4, 15, 16, 17... 46, 47, 48, 49, 150. But when it hits nine, it'll just keep one going: 28, 29, 20, 21, 22, 23... until it hits five. I checked the rules that govern what image pops up, they're fine.
I made a demo a few weeks ago showing how to this this:
http://gamesalad.com/game/play/31065
Hope this helps!
Joe
THANK YOU.
You're a star!
Cheers,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Can't wait to see your new game!
Say you have 900 points. You get 200 more points that should take you to 1100.
Instead, it goes to 1900. The '9' gets stuck
If you get some more points, it resets it to 0. So if I get another 400 points say, it'll go from 1900 to 1500 (the correct score).
Have I done something wrong here? We all know I suck at maths, so I won't even TRY and look at it myself!
Cheers mate - it is still a huge help! :P
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
That means Danger Cats! has it as well...rats, I'll have to update it.
Let us know if you get round to fixing it mate - it's a huge help to everyone, I'm sure!
Cheers,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
I checked my custom font score demo again, and it does appear to be behaving correctly.
Here is the demo here:
http://gamesalad.com/game/play/31065
For it to work properly, make sure you adjust the divisor attribute of each Actor instance on the stage...
They need to be set to 10, 100, 1000, etc...
Let me know if it's still not behaving correctly for you.
Joe
You would THINK a time-traveling sheep would get the math stuff pretty easy eh??
Ohwel, I hope it's in the pipe.
It's still doing the same thing. I've double and triple checked all the individual numbers in the scene so that their divisor is by 10, 100, 1000 etc
I added an actor to the scene that puts the score up by 10 if you press 1, 100 if you press 2, 1000 if you press 3 etc to test this - still no dice, and my original bug find still stands
Funnily enough, I tried this in your example and it works fine.
There is one thing I'm doing that's different. Perhaps it's affecting it?
I have a hard and easy mode - in easy mode the score is halved. The way this works is that 'mode' is given the value 1 or 2. Hard mode =1, easy mode =2.
Then the score is divided by that number.
So, shoot a ship in hard mode, you get 90 points. or currentscore = currentscore+90/1 which= 90
Shoot the same ship in easy mode and you get 45 points. currentscore = currentscore+90/2 which =45
Is this what's affecting it do you think?
Thanks for the help!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
just making sure: you are using parentheses with that formula? i.e:
currentscore = currentscore+(90/1)
currentscore = currentscore+(90/2)
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
especially the 9 and 0
i'm just thinking off the top of my head...
I'll try it now.
FOR SHAME, QUANTUM!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Thanks for all the help, fella!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io