Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Yonben on February 17, 2014, 12:07:12 PM

Title: [SOLVED] Real time calculating score (Edit solution: Every Frame + Per Second)
Post by: Yonben on February 17, 2014, 12:07:12 PM
Hi,

It's me again ^_^
My game is getting a better shape but I have a question (as usual :D).
It's an incremental game, so for now I re-calculate the score every second. However, as some upgrades give you +0.x score per second, I'd like to have a "real time" score update (I don't even know if it's the right way to say it :x).

Any tips (if you understood what I ask for ^^').

Thanks!!
Title: Re: Real time calculating score
Post by: Lane on February 17, 2014, 03:37:01 PM
Hmm, so you want a single score number to update fast when you do those per second score changes, then do the standard update every second?

It sounds like you might need to maintain two score types, fast and slow that compose the final score amount. You could have two states on your final score setup where it updates with the fast score, then every one second moves to a state where it processes the slow score and goes back to the fast update state.

It sounds like a rather convoluted kind of system/idea, really. Maybe I misunderstand what you're going after.
Title: Re: Real time calculating score
Post by: redikann on February 17, 2014, 03:42:49 PM
Sounds like you have a fast paced scoring system that at any given time your player might have a multiplier affecting their incoming score. The key would be to filter the incoming score and add logic that says hey Multiplier or no multiplier and then add that into an overall score.
You wouldn't ever want to multiply by a 0x multiplier because that would only return zero when you would actually want to add the base score.
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 03:48:36 PM
No that's what I meant :x
I meant that right now it updates every second, but it's not good, because if I have 1.5score/sec, then I want it to increase in "real time", like if I move 6 meters/seconds, it doesn't mean that I move 6 meters every seconds, but that I move 1 meter every .1 second, is it more understandable?
Title: Re: Real time calculating score
Post by: Lane on February 17, 2014, 04:12:47 PM
Why not just update every frame?
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 04:23:17 PM
I'm so noob but how do I loop from an idle state to an update state every frame (that's exactly what I want), without getting a loop limit?
Title: Re: Real time calculating score
Post by: Lane on February 17, 2014, 04:25:45 PM
Can you post a picture of your score fsm and what its doing in the state(s)?
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 04:31:39 PM
Well I'm redoing it from scratch but it's a scorepersec variable (including all the upgrades) added to the final score variable.. So you're free to give me the best way before I make a huge mess :x
Title: Re: Real time calculating score
Post by: redikann on February 17, 2014, 04:32:18 PM
I don't know if this is a bad practice but sometimes I use a "Send Event " action and set the interval to like .01. This usually kills the 1000 loop warning. FSM will loop as fast as they can execute which can throw that warning if not gated.
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 04:43:15 PM
Gonna wait a little to see if someone has a "good practice" but thanks it's better than nothing!
Title: Re: Real time calculating score
Post by: Lane on February 17, 2014, 04:47:29 PM
Depending on how the score is accrued I usually try to make the enemies send an Add to the current score when they die and display the current score in some gui, that keeps things simple. I haven't tried it with Per Second changes yet.
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 04:49:22 PM
Well my thing is an incremental kind of game, so upgrades change the scorepersec var, and clicking the main sprite add a scoreperclick var, these to vars are mixed together to the finalscore one. My goal is to have the scorepersec var to be added to the score "every frame" as you said. So probably converting it to a scoreperframe var?
Title: Re: Real time calculating score
Post by: Lane on February 17, 2014, 04:56:59 PM
If you have a value that is the amount of score you want to add per sec... Then you just need to use a Float Add of scorepersec to your currentscore variable and check the Every Frame and Per Second box.
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 05:06:26 PM
So my FinalScoreUpdate FSM is just one state? I didn't even know that one state could run in continue #TotalNoob
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 06:04:29 PM
Ok, so 80%SOLVED !! It works but one last question: Do I have to convert it to int to get a finite number? Is there a way to always have a finite number with a float? Or is it too complicated and I should just convert the final score to an before updating my label?
Title: Re: Real time calculating score
Post by: Lane on February 17, 2014, 06:37:23 PM
if you want a decimal point then you need to use a float. Integers do not have decimals.
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 06:41:12 PM
Wow.. Is my english that bad? :x
I want to calculate everything with decimal (floats) but I want the final score to be without decimal. So I NEED to convert it to int I guess.. Anyway I guess it's solved :) Thanks!
Title: Re: Real time calculating score
Post by: Lane on February 17, 2014, 07:07:56 PM
Wow.. Is my english that bad? :x
I want to calculate everything with decimal (floats) but I want the final score to be without decimal. So I NEED to convert it to int I guess.. Anyway I guess it's solved :) Thanks!

Oh, yeah you need to convert it into an Int at the end, before you display it if that is your final goal. Sorry =)
Title: Re: Real time calculating score
Post by: Yonben on February 17, 2014, 07:10:44 PM
Thanks a lot! Really improved my game thanks to you guys!! Good job :) On my way to get out of the Noob Zone I promise :p
Title: Re: [SOLVED] Real time calculating score (Edit solution: Every Frame + Per Second)
Post by: jeanfabre on February 17, 2014, 11:29:13 PM
Hi,

 Yes, you can use the action "Convert float to int".

bye,

 Jean