Geodesic_D
04-08-2007, 04:35 AM
I'm trying to create a two-player fighting game in Flash, but I've ran into some problems.
When the game starts, I want to randomly pick the names of two fighters and then show their picture under their name.
The name is going to show up in a dynamic textbox called 'player1' and the picture is controlled by a movieclip called 'p1charpic'. The same applies to Player Two, except its 'player2' and 'p2charpic'.
This is the code I have just now (which doesn't work). I am using the same code for both characters, so it appears twice.
var p1character=Math.round(Math.random()*4);
var p2character=Math.round(Math.random()*4);
if (p1character="0")
{
player1.value="Fred"
p1charpic.gotoAndStop(2)
}
else if (p1character="1")
{
player1.value="John"
p1charpic.gotoAndStop(3)
}
else if (p1character="2")
{
player1.value="Joanne"
p1charpic.gotoAndStop(4)
}
else if (p1character="3")
{
player1.value="Bill"
p1charpic.gotoAndStop(5)
}
else if (p1character="4")
{
player1.value="Ethel"
p1charpic.gotoAndStop(6)
}
Can someone help me please?
Also, I want to prevent the game choosing the same character for both players.
When the game starts, I want to randomly pick the names of two fighters and then show their picture under their name.
The name is going to show up in a dynamic textbox called 'player1' and the picture is controlled by a movieclip called 'p1charpic'. The same applies to Player Two, except its 'player2' and 'p2charpic'.
This is the code I have just now (which doesn't work). I am using the same code for both characters, so it appears twice.
var p1character=Math.round(Math.random()*4);
var p2character=Math.round(Math.random()*4);
if (p1character="0")
{
player1.value="Fred"
p1charpic.gotoAndStop(2)
}
else if (p1character="1")
{
player1.value="John"
p1charpic.gotoAndStop(3)
}
else if (p1character="2")
{
player1.value="Joanne"
p1charpic.gotoAndStop(4)
}
else if (p1character="3")
{
player1.value="Bill"
p1charpic.gotoAndStop(5)
}
else if (p1character="4")
{
player1.value="Ethel"
p1charpic.gotoAndStop(6)
}
Can someone help me please?
Also, I want to prevent the game choosing the same character for both players.