random creation

IWantSumCrusha

  • Posts: 20
Right, i wish to have a game which involves jumping from building to building, infinitely. until of corse you fall and die.
 I have a short, med and tall building and want them to be created on a scene every 1 second and have the hight be random.
 i've tried sveral ways but i can't figure it out. can any1 help me?

Hectate

  • *
  • Posts: 4645
When Created:
Do every 1 second:
Set RandomNumber to [Random Number between 1 and 3]
If ( RandomNumber = 1)
: Create Tall Building actor at...
Otherwise If (RandomNumber = 2)
: Create Medium Building actor at...
Otherwise
: Create Short Building actor at...
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

IWantSumCrusha

  • Posts: 20
the same problem occurs as the other attempts i've tried
EDIT: i've noticed the between 0-4 and changed it but it is still the same...

and here is what happens- (mp4 download)
http://www.mediafire.com/?47pk5q2ra0j9jfi

« Last Edit: April 09, 2014, 02:49:06 am by IWantSumCrusha »

Ganu

  • Posts: 224
Well I found it buggy becuase when I want it to find random number between 0 (just 0) and in example 5 it will generate even numbers like 0.56 etc, and then gets freezed. I have posted this even in bugs section.
Currently waiting for joints in stencylworks.

captaincomic

  • *
  • Posts: 6108
@IWantSumCrusha
Did you put the "do every 1 seconds" in "always"? This would spawn a new "do every" task every frame. Instead you would have to put it in "when created" (like Hectate said).

@Ganu
The "random number between _ and _" block should only generate integers. Could you post a screenshot of your code?

IWantSumCrusha

  • Posts: 20
wow i'm dyslexic.... i did put it under the always. wow.

captaincomic

  • *
  • Posts: 6108
Hehe :D I think one facepalm would have been enough - it's a very common mistake ;).

Ganu

  • Posts: 224
@IWantSumCrusha
Did you put the "do every 1 seconds" in "always"? This would spawn a new "do every" task every frame. Instead you would have to put it in "when created" (like Hectate said).

@Ganu
The "random number between _ and _" block should only generate integers. Could you post a screenshot of your code?
The code is just random number from:0 to: maybe 5, or from 5 to 0 I don`t remember, the problem was the 0 number the second one can be any, I don`t have the code at now I will try to find it.

« Last Edit: March 18, 2012, 10:04:44 am by Ganu »
Currently waiting for joints in stencylworks.