Problem with Timer

alexullealexulle Member Posts: 27
edited November -1 in Working with GS (Mac)
Hi there,

I would be pleased if you can help me.
I'd like to drop objects during gameplay every X seconds. And the Timeperiod between the drops should became shorter and shorter. But in this case it doesn't work and I don't know why.

I made it this way:

Timer
every 1/game.gamespeed seconds

spawn actor
...

change Attribute
game.gamespeed = game.gamespeed+0.1

(spawn actor and change Attribute are part of Timer)

but the time period sill keeps at 1 second but it should became shorter
With using the display text atribute I know, that game.gamespeed gets higher over a time.
there is also an other object using Timer 1/gamespeed and that does its job correctly.

I would be pleased if you can help

Thanks
«1

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I am having the same problem and it is really hurting my game. Here is what I think is happening. When the spawner actor is loaded into the scene the game engine checks to see what the value of the attribute is and sets it for the entire scene. I had a timer with an attribute for the time. then I had a rule that changed that attribute every so often so that the spawn rate would increase. But the spawner would only spawn at whatever the attribute was initially set to. I even did a display text behavior and could watch the spawner time attribute go up, yet the objects kept being spawned at exactly the same rate.

    This is a HUGE PROBLEM that I hope GS fixes.

    What I am doing now (which seems to be a bit buggy) is to have rules that say

    Have atimer that counts up

    When timer = 0
    For 20 secs
    Spawn every 5 secs

    When timer = 20
    For 20 seconds
    Spawn every 4 secs

    and on and on

    Does anybody know of a way to have a changing attribute in the timer that actually makes the timer rate change during the scene? Devs?
  • scorelessmusicscorelessmusic Member Posts: 565
    For Mozart To Infinity, I make extreme use of timers and I'd like to say that it's giving me the biggest headaches too. And for music where every 0.01 second counts, it's no laughing matter if the timers miss their cue.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I'm very excited that this is possible, but I really can't figure out how to use this to spawn things at an increasing rate. Anyone feel like trying to explain how this could be done using this method?

    Thanks in advance!
  • scorelessmusicscorelessmusic Member Posts: 565
    Nice tip, CodeMonkey! I'll try it out and see if it helps make Mozart To Infinity more stable.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    scoreless, you understand this wiki topic? I'm clueless as to how it works, or how to use it to increase spawn rate.
  • scorelessmusicscorelessmusic Member Posts: 565
    Well, scitunes, I must admit that I didn't really get it so I went back to the drawing board and opened a new project to fiddle around. For Mozart To Infinity, it's not really a spawning issue but more of many things happening at different set intervals. In the end, I'm employing something different from what is directly suggested here, but I believe CodeMonkey got me started down this alternate path that should work out to be more stable.

    The truth is that I'm still not too clear on how to implement the self.currentInterval and self.newInterval. Maybe a working demo tutorial with open source can help.

    In the meantime, I believe I should be publishing an optimised Mozart To Three soon. Will announce my findings then.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Codemonkey, care to explain how this works?
  • alexullealexulle Member Posts: 27
    Nice Tip CodeMonkey. But i can't get it to work. Would you please describe us how to use it.
  • alexullealexulle Member Posts: 27
    !!! IT WORKS !!!

    But I've done it a little bit different from the example in the How to's

    Here it is:

    When the game starts, game.GameSpeed is set to 1 and game.OldGameSpeed is set to 0.8

    Rule
    When:
    Attriute game.GameSpeed > game.OldGameSpeed

    Timer
    Every 1/game.GameSpeed seconds

    Spawn Actor
    Change Atribute game.OldGameSpeed to game.GameSpeed

    otherwise:
    ChangeAtribute: game.GameSpeed to game.GameSpeed * 1.1 (Here you can put in your new gamespeed)

    Hope you can use it for your projects
  • scorelessmusicscorelessmusic Member Posts: 565
    Nice one Alexulle :D
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I made a test project with alexulle's exact code and the spawned actors just keep appearing at the same rate. Not sure what I did wrong. alexulle, are you sure this works? The actors spawn rate is really changing for you?

    Codemonkey, can we get a little love, man?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I know there are a bunch of GS games that have spawned enemies (z is for zombie, kfright has one I think, as well as other shooter games by a number of different people). How did you guys manage to get the enemies to spawn in a way that makes the game get harder the longer you play? Did you use an attribute in the timer and then have the attribute change as the game goes on? If so, how did you gt to actually work? I've got a game that I am really liking but being able to make it get increasly more dificult would really improve the game play. Any ideas would be great!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I am sorry to keep bumping this, but I just can't get this to work. Any ideas? Anything I do always results in things being spawned at the same rate instead of coming faster and faster.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I tried to figure out that wiki page, it kinda makes sense in theory to me, but I don't know how it really works :)

    I guess the only way to adjust the timer speed is to reset the timer with the new speed, so i think the wiki page is kinda forcing the reset?

    In my games I did it the lazy way

    if progress > 100
    spawn every 5

    if progress is > 300
    spawn every 3

    if progress is > 500
    spawn every 1

    something like that anyways.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    this is what I am currently using, but I want this game to be "endless" at least in theory. If I can have a timer with an attribute that changes then I can have a system that makes the game get more and more difficult no mater how long it is played. Under my current system (like the one you suggest) at a certain point the difficulty just levels off and stays the same. I can live with it as it is, but knowing that there is a possible solution that is just out of my grasp is torture!
  • alexullealexulle Member Posts: 27
    I'm sure that it works. It works in my game. Every time an actor is spawn the game gets a little faster. Did you make the atributes game.GameSpeed and game.OldgameSpeed in the game attributes and set game.GameSpeed to an higher value than game.OldgameSpeed?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    yep did all that. no dice. I even set the numbers so that it would speed up rally fast just to test it and no change at all.

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

    here's my test. it just keeps a steady pace.
  • alexullealexulle Member Posts: 27
    Do you use "real" or "integer" for the gamespeed and oldgamespeed? It should be "real".

    Do you know if it is possible to open your testproject so I can look at it in detail. I only can play it in the moment.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Right click on the blue button to the left and bottom of the game and save it. Change the .zip to .gameproj and it should work.
  • alexullealexulle Member Posts: 27
    execuse me, but I cant open it. Which blue bottom do you mean. On the left bottom there is only an little blue sign. And on the right bottom there is a blue download project button. But which both I cant download a .zip file.
  • alexullealexulle Member Posts: 27
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Awesome! Could you re-upload it and check the little box that lets people download it. I feel like a kid on christmas eve!

    :->
  • alexullealexulle Member Posts: 27
    box is checked and project is re-uploaded. I Hope download works now.

    should be the same link:

    http://gamesalad.com/game/play/43395
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    So I open your project and I have it side by side with mine. Everything is the same (I even redid my rules and my attributes) I made sure they were real attributes, I checked the other wise section, EVERYTHING and my spawner does not speed up. I am going crazy!!!!!!!!

    Thanks for making this demo. Just can't get it to work when I do it - makes no sense!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Anyone else getting this to work?
  • alexullealexulle Member Posts: 27
    I tried to download your project, but I cant get it to work on GS
    I would have a look at your project but I cant open it.
  • alexullealexulle Member Posts: 27
    I tried to download your project, but I cant get it to work on GS
    I would have a look at your project but I cant open it.
    I only get a Chess Game every time
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    maybe my project is corrupted. I'll try making a brand new project and reupload it when I get a chance (at work now). Thanks for all the help with this!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @alexulle: Open the project through the shared games tab in GS Creator, you don't need to download it from the web.
Sign In or Register to comment.