The Daily Click ::. Forums ::. Klik Coding Help ::. Need help with the random function
 

Post Reply  Post Oekaki 
 

Posted By Message

PkGamer



Registered
  07/05/2013 19:46:26
Points
  42
29th October, 2013 at 29/10/2013 18:58:57 -

Hi,
Im working on a series of small arcade games.I need help with the random function.

1)
Random position

I need the actives to be randomly places in a defined area

Theres a couple more but I'll post them later as I just relised something.

 
PkGamer-Current Project:Space Explrer 3000 Goals:Random World Generator,Deffense Oriented Combat, Loads of Upgrades, 8 bit graphics(since Im good at only pixel art), Simply Music.
<br />

Akai_R



Registered
  16/04/2008
Points
  436
29th October, 2013 at 29/10/2013 22:05:56 -

X starting position of defined area + random(x end position of defined area - x size of your active)
same for y

So if you want them to spawn between x 20 and x 50 and your active is 5 pixels wide it would be 20 + random(25)



 
______
http://akai-r.com/

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
31st October, 2013 at 31/10/2013 21:40:54 -

Hi PkGamer, i did a little example for you, i hope you'll understand it, if you have any questions, i'm here
Link: https://www.dropbox.com/s/i3c08anomo26ib2/Random%20area.mfa

 
Working on some engines, working for the fun !
   

Post Reply



 



Advertisement

Worth A Click