trouble with timers

part12studiospart12studios Member Posts: 620
edited November -1 in Working with GS (Mac)
Hi there, I have a game where i want the timer to update over time getting faster and faster.. i put in the timer "every" - x seconds.. now if i put a flat time in there it works fine.. 1 second for example

however what i thought i could do is put a value in there.. (anything from score to number of clicks or anything) however these are the results i get with some and they are confusing behaviors..

x = "player score" variable which starts at 0 which i would assume means don't do anything... but instead i get a flood of objects spawning.. when i click a few at +10points (and seconds) per success the spawning should (i think) from no spawning.. to spawning every 10 seconds and then the next click would make it spawn at 20 seconds.. etc

is it that a timer only accepts an initial value and doesn't change beyond that? if so, how would someone be able to gradually increase, say the scrolling of a background?

Comments

  • JeffreyShimaneJeffreyShimane Member Posts: 372
    You could do it like this...

    Create a game attribute for the speed of the background scrolling (bgspeed) with a default value of 100. Create a timer. For every 1 second, game.bgspeed+1. In the background, add a change velocity behavior with the speed set to game.bgspeed.

    Change the values to suit your needs. This will create the effect of the background scrolling by faster and faster.

    - Jeff
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    If you mean the game.timer or self.timer you can't change them.

    But you can reference them to make your own timer. And then you can create whatever attrubtes you want - then change the attributes based on the game.timer or any other attrubute.
  • part12studiospart12studios Member Posts: 620
    hey guys thanks for the feedback.. the effect i'm trying to achieve would be like imagine snowflakes falling.. one flake falls then gradually more and more.. in my case the snow would also fall faster and faster

    the only timer i have in this game is the "spawn" actor. I don't think i'm referencing the game.timer specifically..

    Jeffrey, looking at what you said, i think i'm doing it that way.. i'll explain what i have as best as i can

    1. i have an actor "spawner"

    2. in that actor i have a rule.. which is basically saying.. "stop spawning if player has 0 lives"

    3. inside that rule i have a timer (the only one in the game so far) set to "every" game.snow_speed

    4. inside that timer i have two behaviors

    - spawn actor which is saying "spawn snow" at top randomly

    - change attribute "increase game.snow_speed"+1 (which of course i guess would technically slow down the rate, but even if i could get that to happen i'd be thrilled :)

    I have a counter on my screen that shows this value gradually going up.. all the while the rate of dropping stays the same..

    thanks again for taking the time to answer..
Sign In or Register to comment.