Are we All agree?

irongirong Member Posts: 41
edited November -1 in Working with GS (Mac)
Hi all

It's better to use :

"CHANGE Attribute OLDtime to SELF.TIME
THEN a RULE :
IF SELF.TIME = OLDtime+2
Then Do i want etc.."

THAN :
"TIMER : Every 2 sec
Do i want etc."

Better performance with 1st case? anyone agree?

thanks guys

Comments

  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    I think that is the way you said.

    Someone who really knows please comment.
  • AppsRacKAppsRacK Member Posts: 346
    You should put the rule first>
    if self.time = oldtime+2>>
    >>do whatever you want
    then place this inside the rule as well
    >>Change attribute oldtime= self.time.

    and the cycle goes on & on & on.

    :)
  • irongirong Member Posts: 41
    Thanks for your answers
    drahc : Are you agree that is better than "TIMER every 2sec?"
  • LBGLBG Member Posts: 277
    Sorry if this is a dim question...

    how do input "oldtime" as an expression. Do I just type "oldtime"?

    Cheers
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    @LBG you'd make a new game.attribute and call it old time.. and keep updating that.

    Not sure if its actually better than a timer or not?
  • LBGLBG Member Posts: 277
    Right got it. Was just experimenting and did that. Think I got confused as it was written as oldtime rather than game.oldtime. Getting the hang of this though.

    Thanks stormystudio
  • POMPOM Member Posts: 2,599
    irong said:
    Hi all

    It's better to use :

    "CHANGE Attribute OLDtime to SELF.TIME
    THEN a RULE :
    IF SELF.TIME = OLDtime+2
    Then Do i want etc.."

    THAN :
    "TIMER : Every 2 sec
    Do i want etc."

    Better performance with 1st case? anyone agree?

    thanks guys

    Hey if you want to make a timer "every 2 sec"

    The best way to do it is :
    ****************************
    create an attribute - integer - call it "temp timer" - value:0
    Rule:
    when "temp timer" = Self.time%2
    Do what you want
    ****************************

    This method will not have the"run to completion" option , so you should consider that as well !

    Roy.
  • AppsRacKAppsRacK Member Posts: 346
    irong said:
    Thanks for your answers
    drahc : Are you agree that is better than "TIMER every 2sec?"

    I think so. Like i said in my previous post its quite logical to just use the timer thats been running on the system already than putting another timer that will add up to your ram usage. I've read it somewhere here in the forum while searching for a best way to optimized a game that he removes every timer he have use in his game and replace it with self.time and he gain 15-20 fps. Not bad right.
  • Rob2Rob2 Member Posts: 2,402
    wow pom...good score, that is one efficient timer, and it works (always a plus)
  • irongirong Member Posts: 41
    OMG POM your method is sooooo clean!!! Thanks Man!
    Just to understand so the self.time%2 is equal to 0 every 2 seconds right?

    So self.time%0.3 will be equal to 0 every 0.3 seconds i guess.

    Wow great! thanks
  • irongirong Member Posts: 41
    Thanks Drahc you motivated me to redo everything :))
  • POMPOM Member Posts: 2,599
    irong said:
    OMG POM your method is sooooo clean!!! Thanks Man!
    Just to understand so the self.time%2 is equal to 0 every 2 seconds right?

    So self.time%0.3 will be equal to 0 every 0.3 seconds i guess.

    Wow great! thanks

    Yes you got it right ;)
    Glad it helped you

    Roy.
  • Rob2Rob2 Member Posts: 2,402
    just use game.timer=self.time%game.timer and then game.timer is your delay and it wont fire straight off at 0
  • irongirong Member Posts: 41
    Let's Abuse!! :)

    In the same way, is there a "clean" method to replace the "TIMER : After X seconds" do what i want... ?

    Rob2 is that what you're proposing?
  • LBGLBG Member Posts: 277
    So say I wanted to increase the spawn rate over time I could:

    Create 2 new attributes - spawner (integer 2), temptime (integer 0)

    when temptimer = self.time%game.ptspawn (ptspawn basically updates to be eqaul to self.time every 8 seconds)
    change attribute spawner-0.1

    when spawner = self.time%spawner
    --spawn whetever I want every 2 seconds then decreasing in time by 0.1 seconds every 8 seconds--

    Would this work or am I completely lost?

    EDIT- Just realised the flaw would be that the 8 second timer would increase by 8 every 8 seconds...

    How would I essentially set up a spawn timer that decreased the spawn time of enemies either based upon time or score?
  • irongirong Member Posts: 41
    well i think you're right (if i understood what you written :)

    So let's resume :

    Create an attribute "SpawingDelay" = 2
    create a temp= 0

    then you do a rule WHEN "temp=Self.time%SpawningDelay" spawn my enemy.

    After that if you want a rule to decrease your spawning time, just do something like :
    Rule : WHEN "temp=self.time%30"
    change attribute : SpawningDelay = SpawningDelay - 0.1

    if this case, every 30seconds you minus 0.1 sec to the spawning Delay.

    maybe it's exclatly what you said. at least it's a confirmation ;)
  • LBGLBG Member Posts: 277
    Thanks irong. I'm going to have a play with these ideas today. Hopefully I'll find a solution.
  • LBGLBG Member Posts: 277
    irong said:
    well i think you're right (if i understood what you written :)

    So let's resume :

    Create an attribute "SpawingDelay" = 2
    create a temp= 0

    then you do a rule WHEN "temp=Self.time%SpawningDelay" spawn my enemy.

    After that if you want a rule to decrease your spawning time, just do something like :
    Rule : WHEN "temp=self.time%30"
    change attribute : SpawningDelay = SpawningDelay - 0.1

    if this case, every 30seconds you minus 0.1 sec to the spawning Delay.

    maybe it's exclatly what you said. at least it's a confirmation ;)

    Its spawning but it isn't reducing the spawn time....
Sign In or Register to comment.