Exemplo n.º 1
0
// get map file's size
if ($lifetime == -1 || $lifetime >= MAP_TIMEOUT) {
    $status = createTerrainMap($db);
    if ($status != TRUE) {
        die("could not create map file.");
    }
}
$minimap = loadPNG(TERRAIN_MAP);
// check correct map size
if (imagesx($minimap) != $width || imagesy($minimap) != $height) {
    $status = createTerrainMap($db);
    if ($status != TRUE) {
        die("could not create map file.");
    }
}
$minimap = loadPNG(TERRAIN_MAP);
// show minimap
header("Content-type: image/png");
imagearc($minimap, $x - $minX, $y - $minY, 2, 2, 0, 360, imagecolorallocate($minimap, 0xff, 0x0, 0x0));
imagepng($minimap);
imagedestroy($minimap);
/* ***** FUNCTIONS ***** */
function getMapSize()
{
    global $db;
    if ($res = $db->query("SELECT MIN(xCoord) as minX, MAX(xCoord) as maxX, MIN(yCoord) as minY, MAX(yCoord) as maxY FROM Cave")) {
        return $res->nextRow(MYSQL_ASSOC);
    }
    return 0;
}
function createTerrainMap($db)
Exemplo n.º 2
0
        // graph line color
        imagecolortransparent($image, $farbe_body);
        $headline = "FEHLER!";
        if ($status == -1) {
            $headline = "Fehler beim Auslesen des Rankings!";
        }
        if ($status == -2) {
            $headline = "Unbekannte playerID!";
        }
        $x = (150 - imagefontwidth(2) * strlen($headline)) / 2;
        $y = imagefontheight(2) / 2;
        imagestring($image, 2, $x, $y, $headline, $farbe_r);
        ImagePng($image, IMG_FILE);
    }
}
$image = loadPNG(IMG_FILE);
// show graph
imageinterlace($image, 1);
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
// functions ------------------------------------------------
function createImg($db, $playerID)
{
    global $imgX, $imgY, $offsetTop, $offsetBottom, $offsetLeft, $offsetRight, $maxDays;
    $headerSize = 2;
    // Getting the points
    $query = "SELECT * FROM rank_history WHERE playerID = " . $playerID;
    if (!($db_result = $db->query($query))) {
        return -1;
    }
Exemplo n.º 3
0
function mergePiece($board, $piece, $square, $direction)
{
    if ($piece == " ") {
        return;
    }
    $file = $square % 8;
    $rank = ($square - $file) / 8;
    $numCols = imagesx($board);
    $squareSize = getSquareSize();
    $decorationWidth = ($numCols - 8 * $squareSize) / 2;
    if ($direction == 'normal') {
        $x = $decorationWidth + $file * $squareSize;
        $y = $decorationWidth + $rank * $squareSize;
    } else {
        $x = $decorationWidth + (7 - $file) * $squareSize;
        $y = $decorationWidth + (7 - $rank) * $squareSize;
    }
    $pieceImage = loadPNG(pieceFilename($piece));
    $pieceSize = imageSx($pieceImage);
    if (!imageCopyResampled($board, $pieceImage, $x, $y, 0, 0, $squareSize, $squareSize, $pieceSize, $pieceSize)) {
        sendErrorImageAndDie("imageCopy returned false");
    }
    imageDestroy($pieceImage);
}