PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Martijn Waeyenbergh   Find the Weird Duck PHP Game   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: main script file
Class: Find the Weird Duck PHP Game
Implements a Web version of the Find the Duck game
Author: By
Last change: changed the path of the images
Date: 2 years ago
Size: 957 bytes
 

Contents

Class file image Download
<?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>