Help on GS timers optimisation!

SylvannusSylvannus Member Posts: 21
edited April 2013 in Working with GS (Mac)
Hello, GS community

I came across @domenius 's thread about GS Optimitization tips and more especially to those regarding timers and how to avoid them. I read the whole thread and I was wondering if that would work for me.

I opened up my Gamesalad project then I did exactly how domenius had written in his thread about *EVERY X SECONDS TIMER*. Also, I added a few more attributes/rules and etc. but I couldn't figure out something. I hope everyone who has any idea about its workaround will help me.

Note: I really need this way of avoiding timers because my game project is thought to have a LOT of timers.

WHAT I WANT:

My scene has ~30 both walls and ground tiles. I want EVERY RANDOM seconds to change one of those walls or ground tiles to another actor called superwall/superground. Maximum of five superwalls/supergrounds can be present. Two seconds after being changed to superwall/superground to change back to normal ,in other words, to change back to wall/ground.

WHAT I DO:

I make rules as in domenius thread. I create a real game attribute called 'mod1' set to 0.05 (as well as mod2 set to 0.05) and also I create another real attribute 'WallsNumber' set to 0 then I go to wall/ground prototype and make a rule saying:

*Rule*
If mod1>self.timer%1
If WallsNumber< 5
*Do*
**Change Image**
Change image to Superwall/superground
**Change Attribute**
Change WallsNumber to WallsNumber +1

then another rule on the same prototype:

*Rule*
If self.image IS Superwall/superground
If mod2>self.timer%2
*Do*
**Change Image**
Change image to Wall/ground
**Change Attribute**
Change WallsNumber to WallsNumber -1

WHAT HAPPENS:

Having made those rules, I can see that everything works apart from that one and only wall/ground changes its image and that forever.

****************

Can you explain me or make a simple project about my problem. I want every random seconds random block to become superwall/superground which if collides with player to change back to wall/ground otherwise after 2 seconds of no colliding with player to change back to wall/ground.


I am really looking to use that method of timers rather than timers itself. As I wrote above, my game is thought to have a lot of timers.



I appreciate the fact you read the whole BORING thread and I will feel delighted if any of you can help me!

EDIT: I used the *Change Image* behaviour since I have got no idea how to do it. I do realise that If mod1>self.timer%1 will change image every second but I do not know how to make it random since random(min,max) doesn't work in this case.

Comments

  • ShaunEleryShaunElery Member, PRO Posts: 148
    If you post a simplified example project you're more likely to get help
  • 3itg3itg Member, PRO Posts: 382
    Name your Images so they can be incremented. Image1, Image2, Image3 etc...
    Then this...

    *Rule*
    If mod1>self.timer%1
    If WallsNumber< 5
    *Do*
    **Change Attribute**
    Change WallsNumber to random(1,30)
    **Change Attribute**
    Change self.Image to "Image"..WallsNumber
    Eliminate the Second Rule until you get the first one sorted, then it should be easy to add.
Sign In or Register to comment.