Code: Select all
class projectile_motion {
var $p1_life;//player one life(human)
var $p2_life;//player two life(computer)
var $turn;//determines who goes next
var $Dx;//distance between opponents
var $wind_speed;//speed of wind
var $wind_direction;//direction of wind
var $image_path = "./images";//without trailing path
function new_session($L1, $L2, $turn = 0) {//initiates a new session, setting player life back to specified level
$this->p1_life = $L1;
$this->p2_life = $L2;
$this->turn = $turn;
}
function generate_world() {
$this->Dx = mt_rand(300,1000);//sets distance between opponents
$this->wind_speed = mt_rand(0,30);//sets wind speed
$this->wind_direction = mt_rand(0,1);//sets wind direction(0=west,1=east)
if($this->wind_speed == 0) {//if wind speed is 0, sets wind direction to 2, meaning no wind in either direction
$this->wind_direction = 2;
}
}
function build_world() {
Print <<< EOT
<center>
<table border=0>
<tr>
<td width=122></td>
<td width={$this->Dx} height="400"></td>
<td width=122></td>
</tr>
<tr>
<td width=122>
<img border=0 src={$this->image_path}/0_tank.gif width=122 height=65></td>
<td width={$this->Dx}></td>
<td width=122>
<img border=0 src={$this->image_path}/1_tank.gif width=122 height=65></td>
</tr>
<tr>
<td width=122></td>
<td width={$this->Dx}>
<center>{$this->Dx} meters</center></td>
<td width=122>Wind:
EOT;
if($this->wind_direction == 0) echo "west at ";
if($this->wind_direction == 1) echo "east at ";
if($this->wind_direction == 2) echo "";
Print <<< EOT
{$this->wind_speed}</td>
</tr>
</table>
</center>
EOT;
}
}to play this game, you have to enter an angle and a power to shoot at then submit, what i need to do is be able to set a var equal to a session or a post $var
i have tried but i cant get it to work
Code: Select all
if(isset($_SESSION['p1_life']))
{
var $p1_life = $_SESSION['p1_life'];
}any suggestions/soultions?