Example #1
0
function fUpdate($aSpel)
{
    $aNieuw = $aSpel;
    for ($i = 0; $i < 6; $i++) {
        for ($j = 0; $j < 5; $j++) {
            $Hier = $aSpel[$i][$j][0];
            $Rechts = $aSpel[$i][$j + 1][0];
            switch ($Hier) {
                case 0:
                    //Eventuele acties voor lege plaats.
                    break;
                case 1:
                    //Eventuele acties voor plant.
                    break;
                case 2:
                    //Acties voor herbivoor.
                    switch ($Rechts) {
                        case 0:
                            $aNieuw = fVerplaats($aSpel, $aNieuw, $i, $j);
                            break;
                        case 1:
                            $aNieuw = fEet($aSpel, $aNieuw, $i, $j);
                            break;
                        case 2:
                            $aNieuw = fVrij($aNieuw);
                            break;
                        case 3:
                            break;
                    }
                    break;
                case 3:
                    //Acties voor carnivoor.
                    switch ($Rechts) {
                        case 0:
                            $aNieuw = fVerplaats($aSpel, $aNieuw, $i, $j);
                            break;
                        case 1:
                            break;
                        case 2:
                            $aNieuw = fEet($aSpel, $aNieuw, $i, $j);
                            break;
                        case 3:
                            $aNieuw = fVecht($aSpel, $aNieuw, $i, $j);
                            break;
                    }
                    break;
            }
        }
    }
    $leeg = fCount($aNieuw, 0);
    $aNieuw = fPlantenSpawn($aNieuw, $leeg);
    return $aNieuw;
}
Example #2
0
function fActies()
{
    //Spawn plant (max 10)
    $aPlanten = fArraySoort(1);
    if (count($aPlanten["x"]) < 10) {
        fSpawnSoort(1);
    }
    // $aCarnivoren = fArraySoort(3);
    $rActieHerbivoor = rand(1, 3);
    // $rActieHerbivoor="";
    switch ($rActieHerbivoor) {
        case 1:
            fDoeNaConditieRechts(2, 1, function ($x, $y) {
                $_SESSION["spel"][$y][$x + 1][0] = 0;
                $_SESSION["spel"][$y][$x][1] += 1;
            });
            break;
        case 2:
            fDoeNaConditieRechts(2, 2, function () {
                fSpawnSoort(2);
            });
            break;
        case 3:
            fDoeNaConditieRechts(2, 0, function ($x, $y) {
                fVerplaats($x, $y);
            });
            break;
    }
    $rActieCarnivoor = rand(1, 3);
    // $rActieCarnivoor=3;
    switch ($rActieCarnivoor) {
        case 1:
            fDoeNaConditieRechts(3, 2, function ($x, $y) {
                $_SESSION["spel"][$y][$x + 1][0] = 0;
                $_SESSION["spel"][$y][$x][1] += $_SESSION["spel"][$y][$x + 1][1];
            });
            break;
        case 2:
            fDoeNaConditieRechts(3, 2, function ($x, $y) {
                if ($_SESSION["spel"][$y][$x][1] != $_SESSION["spel"][$y][$x + 1][1]) {
                    if ($_SESSION["spel"][$y][$x][1] > $_SESSION["spel"][$y][$x + 1][1]) {
                        $_SESSION["spel"][$y][$x][1] += $_SESSION["spel"][$y][$x + 1][1];
                        //verloren carnivoor legen
                        $_SESSION["spel"][$y][$x + 1][0] = 0;
                        $_SESSION["spel"][$y][$x + 1][1] = 0;
                    } else {
                        $_SESSION["spel"][$y][$x + 1][1] = $_SESSION["spel"][$y][$x][1];
                        //verloren carnivoor legen
                        $_SESSION["spel"][$y][$x][0] = 0;
                        $_SESSION["spel"][$y][$x][1] = 0;
                    }
                }
            });
            break;
        case 3:
            fDoeNaConditieRechts(3, 0, function ($x, $y) {
                fVerplaats($x, $y);
            });
            break;
    }
}