PDA

View Full Version : [AS2] First Person Shooter Game


keepy123
05-20-2011, 08:43 AM
So i'm making a first person shooting game where characters appear in the windows of a house and you have to shoot them. everything works fine, but i was wondering if there was any way i could make the characters appear at RANDOM in the windows of the house???
Its action script 2 and Flash CS5 that i'm using.
Thanks in advance :)

Noct
05-20-2011, 01:32 PM
Welcome aboard.

Generating a random number is easy, but how you apply that to this would depend on how you have created it so far.

What is the difference between when one enemey appears versus another? As in, does it just go to a new place on the timeline, does it attach them dynamically, etc?

If its timeline based, you will generate a random number from an array of the frames on the timeline in which they appear. If they are dynamically generated, it would probably be easiet to assign each one a linkage ID with a number in it that you could then apply a random number to when you call them.

Sandile
05-20-2011, 01:35 PM
yeah sure, you just make a variable that choses witch house it will spawn in. I dont exactly know how to explain, I will make an example.

var windowappear:Number = random(3);

if (windowappear == 0) {
badguy._x = windowposition0;
badguy._y = windowposition0;
}
if (windowappear == 1) {
badguy._x = windowposition1;
badguy._y = windowposition1;
}

And so on and so on. I hope that made it a bit more clear on how you could do it :)

keepy123
05-22-2011, 12:13 PM
yeah sure, you just make a variable that choses witch house it will spawn in. I dont exactly know how to explain, I will make an example.

var windowappear:Number = random(3);

if (windowappear == 0) {
badguy._x = windowposition0;
badguy._y = windowposition0;
}
if (windowappear == 1) {
badguy._x = windowposition1;
badguy._y = windowposition1;
}

And so on and so on. I hope that made it a bit more clear on how you could do it :)

hmm cant seem to get this to work... do you have a working example by any chance???

Sandile
05-23-2011, 07:04 PM
hmm cant seem to get this to work... do you have a working example by any chance???
Well, yes. But it would be easier if you gave me some of the code you have been using so that I can see how you have done it so far.

you are supposed to replace windowposition0 and windowposition1 with the x/y coordinates of the first and second window position.
Of course the code I wrote wont just work by itself but you need to add it to your existing code thats why I wanted to see what you have done so far.