Hi everyone, this is my first post here, and I am quite new to actionscript (although I have been working on gamemaker 8 without coding for some time). I am trying to make a basic target shooting game to start off with but so far it looks very rigid and pre-set so I decided to add some randomness. If anyone could explain in noob language how to a. make a movie clip jump to a random "y" location (between 1 and 400). and b. set a timer to go off at a random time between 2000 and 5000 millisecond (I already know how to make basic timers)
This stuff is not that hard... you probably could've found it on google as well
anyway, what language are you aiming at? AS2 or AS3? For AS2 I'm probably not the right person... but I can give you some stuff for AS3
a: movieclip.y = 1 + Math.random()*399 (0 - 400 would be Math.random()*400)
b: timer = new Timer(2000 + Math.random() * 3000); if you want to change it for each cycle, use timer.delay = 2000 + Math.random() * 3000 in the TimerEvent.TIMER handler
//create a timer with a delay between 2000 and 5000 ms, which runs forever timer = new Timer(2000 + Math.random()*3000);
//add the event listener, the function the timer calls every time the timer goes off timer.addEventListener(TimerEvent.TIMER, timerTick);
//start the timer, ofcourse timer.start();
//the function the timer calls private function timerTick(e:TimerEvent):void { trace("tick!" }
So, this is a 'static' delay - the timer's delay is set just once, and never changes. If you want it to change each time the timer goes off, just add the following line to timerTick, and it will be randomized after each time it goes off: