<?php
class Map {
private $map = array();
private $width = 0;
private $height = 0;
private $firstX = 0;
private $firstY = 0;
public function getMap() {
return $this->map;
}
public function __construct($width, $height, $firstX = 0, $firstY = 0) { // Génère l'array de la carte
$this->width = $width;
$this->height = $height;
$this->firstX = $firstX;
$this->firstY = $firstY;
for($x = 0; $x < $width; $x++) {
$this->map[$x+$firstX] = array();
for($y = 0; $y < $height; $y++) {
$this->map[$x+$firstX][$y+$firstY] = "franchissable";
}
}
}
public function batonDansLesRoues($niveau = 2) { // Ajoutes des cases non-franchissable aléatoirement
for($x = $this->firstX; $x < $this->firstX+$this->width; $x++) {
for($y = $this->firstY; $y < $this->firstY+$this->height; $y++) {
$randomValue = rand(1,10);
if($randomValue <= $niveau) {
$this->map[$x][$y] = "non-franchissable";
}
}
}
}
}
?>