<?php
// index.php
if(isset($_GET['level']) && !empty($_GET['level'])){
$level = $_GET['level'];
}else{
$level = 1;
}
?>
<style>
.pool{
width: 500px;
height: 500px;
border: 1px solid black;
margin: 0 auto;
}
.pool img{
width: <?=(500/$level)?>px;
height: <?=(500/$level)?>px;
float: left;
}
</style>
Current Level: <?=$level?><br>
<div class='pool'>
<?php
$numberOfDucks = $level * $level;
$positionStrangeDuck = mt_rand(0,$numberOfDucks-1);
$ducks = array("blauw","groen","rood","geel");
for($i=0;$i<$numberOfDucks;$i++){
if($i == $positionStrangeDuck){
$newLevel = $level + 1;
echo "<a href='?level=$newLevel'>
<img src='./eend_vreemd.jpg'>
</a>";
}else{
$newLevel = $level - 1 ;
$randomDuck = $ducks[mt_rand(0,3)];
echo "<a href='?level=$newLevel'>
<img src='./eend_".$randomDuck.".jpg'>
</a>";
}
}
?>
</div>
|