The Daily Click ::. Forums ::. Klik Coding Help ::. using Random to create object at random Y coord.
 

Post Reply  Post Oekaki 
 

Posted By Message

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
8th March, 2012 at 08/03/2012 00:04:24 -

I'm trying to get my attacker to spawn at a random Y coordinate. I tried CREATE OBJECT at X,Y and typing in Random(400) in the Y coordinate box (radio button At actual X,Y coordinates),
but it won't accept it.

I tried Ctrl+E (Event Editor);
1.*Start of Frame - (under Invader) *Set Y position to Random(400)

but again, it didn't work.

As always, any tips, suggestions, ideas are greatly appreciated.

 
n/a

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
8th March, 2012 at 08/03/2012 02:37:55 -

Just create an enemy at the X coordinate that you want, doesn't matter the Y value. Then right after that action set the Y position to Random(400)

 
n/a

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
8th March, 2012 at 08/03/2012 21:26:28 -

That's what I thought, but all my Invaders spawn at the same Y coord. I must have set the Y coord somewhere else and its overriding my Random...

 
n/a

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
8th March, 2012 at 08/03/2012 21:35:38 -

Yep, that was it. I had a Start of Frame event which placed my Invader at X:650, Y:0

Deleted that, and it works now.

Thanks!!!

 
n/a

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
19th March, 2012 at 19/03/2012 23:34:06 -

Random(400) generates a random number from 1-400. Does Random(380) +10 work to generate random numbers between 10 and 390?

 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
19th March, 2012 at 19/03/2012 23:45:11 -

Close, it will generate a random number between 10 and 389.

Because, random(x) generates a random number between 0 and x, not 1 and x.

 
n/a

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
21st March, 2012 at 21/03/2012 12:39:55 -

Great. Thanks Chris. I should have known that.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click