playMaker

Author Topic: [SOLVED] Real time calculating score (Edit solution: Every Frame + Per Second)  (Read 6892 times)

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
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!!
« Last Edit: February 17, 2014, 07:20:13 PM by Yonben »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Real time calculating score
« Reply #1 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Real time calculating score
« Reply #2 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.
« Last Edit: February 17, 2014, 03:44:51 PM by redikann »

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Real time calculating score
« Reply #3 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?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Real time calculating score
« Reply #4 on: February 17, 2014, 04:12:47 PM »
Why not just update every frame?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Real time calculating score
« Reply #5 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?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Real time calculating score
« Reply #6 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)?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Real time calculating score
« Reply #7 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

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Real time calculating score
« Reply #8 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.

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Real time calculating score
« Reply #9 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!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Real time calculating score
« Reply #10 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Real time calculating score
« Reply #11 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?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Real time calculating score
« Reply #12 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Real time calculating score
« Reply #13 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

Yonben

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Real time calculating score
« Reply #14 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?