PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Tomas Pavlatka   PHP Snake Game   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Snake Game
Manage and process the moves in a snake game
Author: By
Last change: Update of index.php
Date: 7 months ago
Size: 475 bytes
 

Contents

Class file image Download
<?php
header
('content-type: text/plain; charset=utf-8');

require_once
'./bootstrap.php';
use \
Ptx\Snake;

$snake_obj = new Snake();
$moves_2_test = [
   
'FLERFF', 'EEEELLLL'
];

foreach(
$moves_2_test as $move) {
    try {
       
$snake_obj->reset();
       
$result = $snake_obj->move_snake($move);

        echo
$move . ': ';
        echo (
$result == -1) ? 'YES' : $result;
        echo
"\r\n";
    } catch(\
Ptx\SnakeException $e) {
        echo
$e->getMessage();
    }
}