The Daily Click ::. Forums ::. Klik Coding Help ::. Making a fast loop run to the value of a counter?
 

Post Reply  Post Oekaki 
 

Posted By Message

Jon C-B

I create vaporware

Registered
  23/04/2008
Points
  237

I'm an alien!VIP MemberWii OwnerI donated an open source project Santa Hat
13th March, 2010 at 16:24:53 -

How can I make a fast loop run to the value of a counter? For example- Counter equals 2 then run fast loop 2 times.
Thanks.

P.S.Sorry for posting so many questions.

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
13th March, 2010 at 16:34:11 -

When you call the fastloop, it will ask how many times to run the loop. Just give it the counter value.

It'll look like this:

Start loop "Bob" value("Counter") times

 

  		
  		

Jon C-B

I create vaporware

Registered
  23/04/2008
Points
  237

I'm an alien!VIP MemberWii OwnerI donated an open source project Santa Hat
13th March, 2010 at 16:43:54 -

Hmmm I've tried that already but it didn't work. I'll just tell you whats happening in the code, if that helps at all.
First off, that counter thing you helped me with a little while ago is working. I'm making the fastloop "Wave" run "the value of that counter" times. Then on loop "Wave"+every 1.5 seconds create zombie at spawn point. Once all zombies are dead and the loop is still "Wave" add one ot gloal value A (which makes that counter go up 1) Then I want "Wave" to run twice this time, bacuse its on the next wave of zombies. But it only spawns one zombie from each spawn point and it goes on and on the same way. Thanks for replying so quickly btw




 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
13th March, 2010 at 17:15:06 -

The problem is most likely that your loop finishes before the timer has a chance to get 1.5 seconds further! I think this might be a case where you don't want to use fastloops.

Try this instead:

Set some value "wave" to global value A.
Every 1.5 seconds AND "Wave" is greater than 0: Create zombie + Subtract 1 from "Wave."

Then set your global value A as you do now.

Edited by OMC

 

  		
  		

Jon C-B

I create vaporware

Registered
  23/04/2008
Points
  237

I'm an alien!VIP MemberWii OwnerI donated an open source project Santa Hat
13th March, 2010 at 17:31:45 -

Ok, I used a counter so I could see the value easier. Nothing changed and the counter is always one ahead of the wave counter

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
13th March, 2010 at 17:59:26 -

Don't use fastloops with timers - that's not what they're for at all!

Do what OMC suggested instead, and then go read an article or two on fastloops (eg. http://www.create-games.com/article.asp?id=106 )

 
n/a

Solgryn

Solgryn dot org

Registered
  20/12/2008
Points
  12572

GOTW Winner!VIP MemberWii OwnerIt's-a me, Mario!The Cake is a LieGOTM 2ND PLACE! - APRIL 2009GOTM 2ND PLACE - JUNE 2009PS3 OwnerKlikCast #15 Compo Winner!LOL Sign
You've Been Circy'd!GOTM WINNER - JANUARY 2010I am an April FoolGOTW MARCH 2010 WINNER!Santa Hat
13th March, 2010 at 20:48:33 -

This is what I'd do if I wanted to make that:

I have these objects:
(Spawner) Active (Used for spawning, alterable values and stuff) this is not seen in the playfield
(Enemy) Active

When a new wave is spawned, set flag 0 of (Spawner) to be on

if flag 0 of (Spawner) is on:
}add 1 to alterable value A

if alterable value A == 25 (means that enemies spawn every ½ second, 50 for a second etc. if your frame rate is 50):
}create (Enemy)
}set alterable value A to 0
}add 1 to alterable value B

if alterable value B == some value determining how many enemies per wave (ex. 5)
}set alterable value B to 0
}set flag 0 to off

Example:
http://www.solgryn.org/Stuff/Random/EnemySpawner.zip

You can change the alterable values in the spawner object to change the settings, press Enter to spawn a wave

Dunno, I just don't like the "every" condition

Edited by Solgryn

 
www.Solgryn.org

Image

Jon C-B

I create vaporware

Registered
  23/04/2008
Points
  237

I'm an alien!VIP MemberWii OwnerI donated an open source project Santa Hat
13th March, 2010 at 23:50:42 -

Thank you all a ton!!! I'm perfectly set for my game now, I can't thank you enough

 
n/a
   

Post Reply



 



Advertisement

Worth A Click