Need Fresh Eyes for Number Extraction... meh, just read this.

KamazarKamazar Member Posts: 287
edited November -1 in Working with GS (Mac)
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

Comments

  • JGary321JGary321 Member Posts: 1,246
    You had me at....err

    You lost me at Ok,

    =p
  • KamazarKamazar Member Posts: 287
    lol, ok, I think I left a chunk out that would make this a lot more understandable.

    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.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    I hope you did put the * in there to multiply, the '()' by itself won't cut it.

    you should try the floor and %(mod) functions.

    a=O/100
    b=floor(O%100)/10
    c=floor(O%10)
  • KamazarKamazar Member Posts: 287
    Didn't have a clue () doesn't work. Been doing too much algebra 2 lately XP

    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.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    I made a demo a few weeks ago showing how to this this:

    http://gamesalad.com/game/play/31065

    Hope this helps!
    Joe
  • KamazarKamazar Member Posts: 287
    Thanks! Definitely'll be helpful!
  • quantumsheepquantumsheep Member Posts: 8,188
    Firemaple - in a rare showing of non-laziness from the sheep, I just implemented this system into my game.

    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

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Awesome! Glad I could help!
    Can't wait to see your new game!
  • quantumsheepquantumsheep Member Posts: 8,188
    Aha! I've found a bug (I think - I may have implemented it wrongly though!).

    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

  • firemaplegamesfiremaplegames Member Posts: 3,211
    ha! good catch! yep, that's a bug alright! I'll fix it in a little while...Trying to finish up stunt squirrels for the competition.

    That means Danger Cats! has it as well...rats, I'll have to update it.
  • quantumsheepquantumsheep Member Posts: 8,188
    heh - glad to help out, even if it's not quite the altruistic gesture it should be ;)

    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

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey QS,

    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
  • JGary321JGary321 Member Posts: 1,246
    Yea QS has very tough time with math.... even if he is just copying =)

    You would THINK a time-traveling sheep would get the math stuff pretty easy eh??
  • ORBZORBZ Member Posts: 1,304
    Guys, doesn't it seem that with a tool like GS that it should be EASY to do something like put numbers on the screen in a custom font?

    Ohwel, I hope it's in the pipe.
  • quantumsheepquantumsheep Member Posts: 8,188
    Ok - I've looked at this again as I was adding a hi-score function.

    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

  • firemaplegamesfiremaplegames Member Posts: 3,211
    hmmm...

    just making sure: you are using parentheses with that formula? i.e:

    currentscore = currentscore+(90/1)
    currentscore = currentscore+(90/2)
  • quantumsheepquantumsheep Member Posts: 8,188
    yes, yes I am!

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • firemaplegamesfiremaplegames Member Posts: 3,211
    also confirm that in the number glyph actor, the images are all correct...
    especially the 9 and 0

    i'm just thinking off the top of my head...
  • quantumsheepquantumsheep Member Posts: 8,188
    I feel incredibly stupid. I forgot to put the when self = 0 show 0 image.

    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

  • firemaplegamesfiremaplegames Member Posts: 3,211
    oooh, I'm good!
  • quantumsheepquantumsheep Member Posts: 8,188
    I'm glad you are! It's good to have you on 'our' side ;)

    Thanks for all the help, fella!

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.