Login   Register  
PHP Classes
elePHPant
Icontem

File: example

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of msdn11  >  Game Lines Class  >  example  >  Download  
File: example
Role: Example script
Content type: text/plain
Description: example
Class: Game Lines Class
Web based minesweeper game
Author: By
Last change:
Date: 2006-05-26 08:21
Size: 2,957 bytes
 

Contents

Class file image Download
<?
require_once("lines.php");
session_start();
$lines = new lines();

if ( !
$_SESSION['field'] ){
$begin 1;
$field $lines->begin();
$field[111][111] = 0;
$_SESSION['field'] = $field;
$new $lines->newpoint($field);
$_SESSION['new'] = $new;
} else {
$field $_SESSION['field'];
}

if (
$_GET['select1']){
//
for( $i 1$i 11$i++ ){
    for( 
$j 1$j 11$j++ ){
    
$c[$i][$j] = 0;
    }
}
$sel1 = (int)$_GET['select1'];
$sel2 = (int)$_GET['select2'];
$sel3 = (int)$_GET['select3'];
$sel4 = (int)$_GET['select4'];

if ( 
$field[$sel4][$sel3]  == ){
$b $lines->reach($sel2,$sel1,$field,$c);
if ( 
$b[$sel4][$sel3] == $checkmove 1;
}
//
if ( $checkmove )
    
$field $lines->move($_GET['select2'],$_GET['select1'],$_GET['select4'],$_GET['select3'],$field);
}


$field1 $field;
$field $lines->kill($field);

for( 
$i 1$i 11$i++ ){
    for( 
$j 1$j 11$j++ ){
    if (
$field[$i][$j] == 0)$k2++;
    if (
$field1[$i][$j] == 0)$k1++;
    }
}


if( 
$_SESSION['new'] && $checkmove && $k2 == $k1 ){
    
$field $lines->placenew($field,$_SESSION['new']);
    }

$field1 $field;
$field $lines->kill($field);


if( 
$lines->checkloose($field) == ){
header("Location: ./result.php?res=".$field[111][111]);
-- 
INSERT --                                                                                                                                59,1          Top
if( $lines->checkloose($field) == ){
header("Location: ./result.php?res=".$field[111][111]);
exit;
}


if ( 
$checkmove ){
$_SESSION['new'] = $lines->newpoint($field);
}

$lines->draw($field,"./img/".session_id().".gif",$_SESSION['new'],$field[111][111]);
$_SESSION['field'] = $field;

if ( 
$checkmove !== and $begin !== ){
echo 
"ERROR! WRONG MOVE!<br/>";
}
?>

            <img src="img.php?s=<?=session_id()?>&rnd=<?=rand(1,10000)?>" alt="" /><br/>
            <form action="example.php" method="get">
            <input type="hidden" name="check" value="1"/>
            <select name="select2">
            <? for( $i 1$i 11$i++ ){ ?>
                <option value="<?=$i?>"><?=$lines->alphabet($i)?></option>
            <? ?>
            </select>
            <select name="select1">
            <? for( $i 1$i 11$i++ ){ ?>
                <option value="<?=$i?>"><?=$i?></option>
            <? ?>
            </select><br/>

              <select name="select4" title="select">
             <? for( $i 1$i 11$i++ ){ ?>
                <option value="<?=$i?>"><?=$lines->alphabet($i)?></option>
            <? ?>

              </select>
              <select name="select3" title="select">
            <? for( $i 1$i 11$i++ ){ ?>
                <option value="<?=$i?>"><?=$i?></option>
            <? ?>
              </select><br/>
              <input type="submit" value="ok"/>
              </form>