View Full Version : Random pattern for shoot em up enemy ??
karvee2005
December 18th, 2005, 10:38 AM
Hi all, im new to flash and im trying to make my first shoot 'em up game for fun. I wanted to make one kinda like a western style quick draw type thing. Everything works fine so far, but i was wondering how i can make my thug or "enemy" pop up in random positions in the saloon scene. Right now i just have his mc tweened to pop up behind the bar and his repeating pattern just sucks.
Gawain
December 18th, 2005, 01:42 PM
I would suggest perhaps making an array to hold the different places (x and y coords) of where the "bandit" can pop up, and then just have one chosen by random.
Sammo
December 18th, 2005, 06:26 PM
Use a switch loop
number = Math.floor(Math.random()*3);
switch (number) {
case 1:
// do thing one
break;
case 2:
// do thing one
break;
case 3:
// do thing three
break;
}
karvee2005
December 24th, 2005, 01:28 AM
Can somebody give me an example of using an array to control a movie clips random location at set intervals ? An explanation of the switch loop code ? I just started learning actionscript last week, lol.
Sammo
December 27th, 2005, 08:28 AM
http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.