Exemplo n.º 1
0
});
    
</script>
<?php 
Mapa::renderizarJs();
?>
 
</head>
<body>
    <div id="toolbar">
        <form method="GET">
        <fieldset>
            <div>
                <label>Hex Tamanho:</label>
                <span><input type="number" name="hex_height" value="<?php 
echo Mapa::getHexHeight();
?>
"></span>
            </div>
            <div>
                <label>Largura:</label>
                <span><input type="number" name="map_width" value="<?php 
echo Mapa::getMapWidth();
?>
"></span>
            </div>
            <div>
                <label>Altura:</label>
                <span><input type="number" name="map_height" value="<?php 
echo Mapa::getMapHeight();
?>
Exemplo n.º 2
0
 public function draw($im, $x, $y)
 {
     $left = Mapa::getMarginLeft();
     $top = Mapa::getMarginTop();
     $left += (Mapa::getHexWidth() - (Mapa::getHexWidth() - Mapa::getHexSide()) / 2) * $x;
     if ($x % 2 == 0) {
         $top += Mapa::getHexHeight() * $y;
     } else {
         $top += Mapa::getHexHeight() * $y + Mapa::getHexHeight() / 2;
     }
     $px = $left - Mapa::getHexHeight() / 2;
     $py = $top - Mapa::getHexHeight() / 2;
     $width = Mapa::getHexHeight() * 2;
     $height = Mapa::getHexHeight() * 2;
     if ($this->cod_situacao == ATIVO) {
         if ($this->posicao == POSICAO_DEITADO) {
             $pessoaPath = $this->getImagem('morto');
         } elseif ($this->sobreAtaque() || $this->animacao == ANIME_COMBATE) {
             $pessoaPath = $this->getImagem('combate');
         } else {
             $pessoaPath = $this->getImagem('parado');
         }
     } else {
         $pessoaPath = $this->getImagem('morto');
     }
     if (!is_null($pessoaPath)) {
         $pessoaPath = dirname(__DIR__) . "/tokens/{$pessoaPath}";
     } else {
         $pessoaPath = dirname(__DIR__) . "/tokens/cavaleiro-parado.png";
     }
     if (in_array($this->getSentido(), array(1, 2, 4, 5))) {
         //$padding = 45;
         $px -= 8;
         $py -= 8;
         $width += 16;
         $height += 16;
     }
     //else
     //    $padding = 30;
     $rotate = (6 - $this->getSentido()) * 60;
     //$tamanho = static::getHexScaledHeight() + ($padding * 2);
     $imPessoa = imagecreatefrompng($pessoaPath);
     if ($rotate > 0) {
         $imPessoa = imagerotate($imPessoa, $rotate, imageColorAllocateAlpha($imPessoa, 0, 0, 0, 127));
     }
     imagecopyresampled($im, $imPessoa, $px, $py, 0, 0, $width, $height, imagesx($imPessoa), imagesy($imPessoa));
     //$color = imagecolorallocatealpha($im, 0, 0, 0, 80);
     //imagefilledrectangle($im, $px, $py, $px + $width, $py + $height, $color);
     imagedestroy($imPessoa);
 }
Exemplo n.º 3
0
 public function drawHex($im, $exibePos = false, $selected = false)
 {
     $left = Mapa::getMarginLeft();
     $top = Mapa::getMarginTop();
     $left += (Mapa::getHexWidth() - (Mapa::getHexWidth() - Mapa::getHexSide()) / 2) * $this->getX();
     if ($this->getX() % 2 == 0) {
         $top += Mapa::getHexHeight() * $this->getY();
     } else {
         $top += Mapa::getHexHeight() * $this->getY() + Mapa::getHexHeight() / 2;
     }
     $hex = $this->getHexCanto();
     if ($selected) {
         $cor = imagecolorallocatealpha($im, 255, 255, 255, 50);
         imagefilledpolygon($im, $hex, 6, $cor);
         $cor = imagecolorallocate($im, 0, 0, 0);
     } else {
         if ($this->getTipo() == AREA_FORA) {
             //$cor = imagecolorallocatealpha($im, 130, 130, 130, 40);
             //imagefilledpolygon($im, $hex, 6, $cor);
             //$cor = imagecolorallocate($im, 0, 0, 0);
         } elseif ($this->getEntrada()) {
             $cor = imagecolorallocatealpha($im, 218, 165, 32, 100);
             imagefilledpolygon($im, $hex, 6, $cor);
             $cor = imagecolorallocate($im, 0, 0, 0);
         } elseif ($this->getTipo() == AREA_PAREDE) {
             $cor = imagecolorallocatealpha($im, 130, 130, 130, 80);
             imagefilledpolygon($im, $hex, 6, $cor);
             $cor = imagecolorallocate($im, 0, 0, 0);
         } elseif (!is_null($this->cor)) {
             $cor = imagecolorallocatealpha($im, $this->cor[0], $this->cor[1], $this->cor[2], 80);
             imagefilledpolygon($im, $hex, 6, $cor);
             $cor = imagecolorallocate($im, 0, 0, 0);
         } else {
             $cor = imagecolorallocatealpha($im, 255, 255, 255, 100);
             imagepolygon($im, $hex, 6, $cor);
         }
     }
     imagesetthickness($im, 15);
     $cor = imagecolorallocatealpha($im, 130, 130, 130, 80);
     for ($i = 0; $i <= 5; $i++) {
         if ($this->lados[$i] == AREA_PAREDE) {
             $l = $i >= 5 ? 0 : $i + 1;
             imageline($im, $cantos[$i]['x'], $cantos[$i]['y'], $cantos[$l]['x'], $cantos[$l]['y'], $cor);
         }
     }
     $cor = imagecolorallocate($im, 0, 0, 0);
     imagesetthickness($im, 1);
     if ($exibePos && $this->getTipo() != AREA_FORA) {
         $texto = $this->getX() . "." . $this->getY();
         $font = 5;
         $fx = $left + (Mapa::getHexWidth() - strlen($texto) * imagefontwidth($font)) / 2;
         $fy = $top + (Mapa::getHexHeight() - imagefontheight($font)) / 2;
         $cor = imagecolorallocatealpha($im, 255, 255, 255, 50);
         imagestring($im, $font, $fx, $fy, $texto, $cor);
     }
 }
Exemplo n.º 4
0
 public static function getScrollByPos($x, $y)
 {
     $left = Mapa::getMarginLeft() + (Mapa::getHexWidth() - (Mapa::getHexWidth() - Mapa::getHexSide()) / 2) * $x;
     $top = Mapa::getMarginTop() + Mapa::getHexHeight() * $y;
     if ($x % 2 == 1) {
         $y += Mapa::getHexHeight() / 2;
     }
     $pos = new stdClass();
     $pos->x = $left;
     $pos->y = $top;
     return $pos;
 }