-
Word to ya motha's
I have a 'snail racing' game where there is ONE user controlled MC and the other THREE MC's are running on there own timeline.
But the thing is i dont want the other 3 'opponant' MC's to be the same all the time because when a user comes back they will realise that there are only 3 mc's that always play the same.
How do i make the movie load random MC's everytime i load the SWF? (so that the competition is a little different)
Thankyou for the help in advance
Gav
-
Load movie with random
Hey, Phukkin. I've just added a similar function to an RPG I'm working on. But it'll only work for you if you use loadmovie commands.
What I did is create 13 different enemy MCs, named enemy1.swf, enemy2.swf, ect. Then I used:
num = Random (13) + 1
LoadMovieNum ("enemy" add num add ".swf", "targetname")
This loads one of the 13 enemies at random into a holder MC (basically an empty MC I use to control position) but you can also load to a level.
(thanks to Benjamin for help with this code!)
HTH
JG
-
you can do this a few different ways...
start by building the different clips, let's say you have six of em.
it will be easiest to keep them all on the stage to sart, so in each movie put a blank keyframe in frame 1, put a frame action stop(); in that frame too.
place all your clips on the stage.
now you can do one of two things- build an array to list them, or just name them sequentially.
an array would look like:
movies=new Array(firstmove,secondmovie,thirdmovie,fourthmovie ,fifthmovie,sixthmovie);
moviecall=random(6);
_root[movies[moviecall]].dowhatever();
name them sequentially (movie1,movie2,movie3 etc.) and you can go:
moviecall=random(6);
_root["movie"+moviecall].dowhatever();
if they're doing more complicated things, set a variable at level0 which is one of the clips, then just use that variable throughout your code
worx?
-
Hi, thankyou for all of the help, I have created 3 different MC's and it seems to call a different MC yet it doesnt actually play.
Below is what i have got on the 1st frame of my Scene.
moviecall=random(3);
_root["race"+moviecall].gotoandplay (2);
I have three MC's = 'race1', 'race2', 'race3'.
AND sometimes it doesnt load an MC at all (or doesnt appear to load one)
any idea's what im doing wrong?
[Edited by phukkin_username on 08-30-2001 at 08:54 AM]
-
Random
Hey, Phukkin. Random returns sequential integers equal in number to what you enter, beginning with 0. So, random (3) will return 0,1,2. What you need to do is either add random (3) +1 or rename your MCs race0, race1 and race2.
I have no idea what might be causing the clip not to play. Have you tried calling a frame label instead of a number?
HTH
JG
-
thanks for your help japangreg, i thought that the random called '0' aswell, ill change my mc from race1 to race0.
what do you mean "calling a frame label instead of a number" ?
-
Labels vs. Numbers
Hey, Phukkin. Don't mention it, that's what these boards are here for. :)
What I meant was using a frame label in you MCs in the second frame, then calling that label from your movie. For eample, your MCs have a "stop" action in the first keyframe, right? Then you could label the second frame "play" then use
_root.["race" add moviecall].gotoandplay ("play");
I don't think this would solve your problem, but it might be worth a try. I always find it easier to call a label than a number, as I frequently delete/add or move keyframes. A label "start" will always be on my first frame.
Anyway, good luck and let us know how it turns out.
JG
-
Thankyou very much for your help!
I now have a working racing gamee with random opponants!
Now all i need is a way of detecting when my user operated MC crosses the finish line and to see if it wins / loses!