<!DOCTYPE html>
<html lang="en">
<head>
<title>Rock Paper Scissors Game</title>
</head>
<body>
<h1> Rock Paper Scissors Game</h1>
(2nd Page) this is a rock paper scissors game involving images...the images do show up after the user inputs (rock, scissors or paper) but usually itll be like (output= image of rock vs paper and then it'll say you win! instead of you lose! or when its a draw nothing shows up)
$playerthrows = $_POST['playerthrows'];
$Choosefrom= array('rock', 'paper', 'scissors');
$Choice= rand(0,2);
$Computer=$Choosefrom[$Choice];
if($playerthrows == 'rock')
{
echo '<img src="rock1.png" alt="rock" />';
}
if($playerthrows == 'paper')
{
echo '<img src="paper1.png" alt="paper" />';
}
if($playerthrows == 'scissors')
{
echo '<img src="scissors1.png" alt="scissors" />';
}
if($Computer == 0)
{
echo '<img src="paper2.png" alt="paper" />';
}
if($Computer == 1)
{
echo '<img src="scissors2.png" alt="scissors" />';
}
if($Computer == 2)
{
echo '<img src="rock2.png" alt="rock" />';
}
Did i mess up with the if statements?
if ($playerthrows == $Computer)
{
echo'<br />';
echo 'Draw.';
}
else if($playerthrows == 'rock' && $Computer == 1 )
{
echo'<br />';
echo 'You Win!';
}
else if($playerthrows == 'rock' && $Computer == 0 )
{
echo'<br />';
echo 'You Lose!';
}
else if($playerthrows == 'scissors' && $Computer == 2 )
{
echo'<br />';
echo 'You Lose!';
}
else if($playerthrows == 'scissors' && $Computer == 0 )
{
echo'<br />';
echo 'You Win!';
}
else if($playerthrows == 'paper' && $Computer == 2 )
{
echo'<br />';
echo 'You Win!';
}
else if($playerthrows == 'paper' && $Computer == 1 )
{
echo'<br />';
echo 'You Lose!';
}
?>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire