set random angle with exclusion

Get help using Construct 2

Post » Thu Mar 01, 2012 10:38 pm

yeah I was too tired I guess
You can notice that I didn't even use the "choice" variable I built

And I also made a mistake building this variable

Code: Select all
Global number Last_Left_Angle=-1 // no discarding at start
+TrenchTile: Wall = "Left"
+TrenchTile: Pick nearest to (0,0)
+TrenchTile: Y > 60
  Local choice = ""  // to store the possible angles 0,1,2,3 * 90
  +System: repeat 4 times
  +System: loopindex is not equal to Last_Left_Angle
    -> System: set choice to (choice = "") ? loopindex : choice&","&loopindex
  -> System: Create object TrenchTile on layer "Tiles Front" at (Left_Wall+Wall_Move, TrenchTile.Y-TrenchTile.Height)
  -> System: set Last_Left_Angle to int(tokenat(choice,floor(random(tokenCount(choice,","))),","))
  -> TrenchTile: set angle to Last_Left_Angle*90



with an example
randomWithExclusion.capx
Last edited by Yann on Sun Sep 14, 2014 9:30 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Mar 02, 2012 12:55 am

Now it's perfect, thanks @Yann. I've learned events...again :)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests