public static function makeRaster($array, $grootte) { $arrSoorten = soortService::getAllSoorten(); print "<div class='matrix grootte" . $grootte . " clearFix'>"; for ($rij = 1; $rij <= $grootte; $rij++) { for ($kol = 1; $kol <= $grootte; $kol++) { $bln = organismeservice::checkPositionInArray($kol, $rij, $array); if ($bln == null) { print "<div class='cell'><div class='innercell'></div></div>"; } if ($bln != null) { foreach ($arrSoorten as $soort) { $posSoort = $bln->soort; if ($soort->id == $posSoort) { $imgsrc = $soort->image; $imgtitle = $soort->soort; } if ($posSoort == "1") { $kracht = ""; } else { $kracht = "Kracht:" . $bln->kracht; } } print "<div class='cell'><div class='innercell'><img src='" . $imgsrc . "' alt='" . $imgtitle . "'><span class='tooltip'><strong>ID : " . $bln->id . "</strong> " . $imgtitle . " " . $kracht . "</span></div></div>"; } } } print "</div>"; }
public static function addToArray($soort, $array, $aantal, $grootte, $gameid) { for ($i = 1; $i <= $aantal; $i++) { if (count($array) >= $grootte * $grootte) { return $array; } do { $kolom = rand(1, $grootte); $rij = rand(1, $grootte); $check = organismeservice::checkPositionInArray($kolom, $rij, $array); } while ($check != false); $organisme = new Organisme(0, $soort, 1, $kolom, $rij, $gameid); array_push($array, $organisme); } return $array; }