TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   php mini map (http://www.talkphp.com/advanced-php-programming/1971-php-mini-map.html)

cosmokramer 01-16-2008 05:08 AM

php mini map
 
I am trying to create a mini map with php, like this one from this tutorial, PHP Game Creation - Minimap Static-Chaos.net
but it will not work for me, I have made sure gd is working on my site it is, checked the mysql script that all fine but when I go to the page it just ouputs the url of the page, any help? btw the site where the tutorial came from has no way of contacting the creator and the forums are not there anymore...

Wildhoney 01-16-2008 01:13 PM

Hum Interesting. Could you perhaps show us your source code so we can take a closer look?

Rendair 01-16-2008 07:08 PM

Ah yeah i have checked this tutorial out awhile back but i changed it to suit my own needs. I shall put my own tutorial on this mini map yes?

cosmokramer 01-16-2008 11:51 PM

Quote:

Originally Posted by Rendair (Post 8644)
Ah yeah i have checked this tutorial out awhile back but i changed it to suit my own needs. I shall put my own tutorial on this mini map yes?

oh please do :-) , I am creating a web based game and this would be awesome for it

cosmokramer 01-17-2008 12:17 AM

Quote:

Originally Posted by Wildhoney (Post 8612)
Hum Interesting. Could you perhaps show us your source code so we can take a closer look?

ok and keep in mind this is straight from the tutorial, just changed mysql stuff,
PHP Code:

<?php
Header
("Content-type: image/png"); // set as png
mysql_connect("myhost""myusername""mypassword") or die("There was an error connecting to the mysql server.");
mysql_select_db("");
// Image Size
$height 247;
$width 247;

// Image Pointer, turn on antialiasing 
$im ImageCreate($width$height); // this is the image
ImageAntiAlias($imtrue); // turn it on, just for fun
// Colors
$grass ImageColorAllocate($im67,154,67);
$enemy ImageColorAllocate($im255,0,0);
$bgcolor ImageColorAllocate($im39,104,39);

// exmaple color, not relevant to program.
$white ImageColorAllocate($im25500);
ImageFill($im00$bgcolor); // Fill the image with the background color
$size 5// size of a block, 5 x 5
$size2 $size 1// don't change this, it is for spacing  


$query "SELECT * FROM `mytable`"// get all user information
$result mysql_query($query);
$userarray// initialize variable
while($row mysql_fetch_array($result))
{
    
$userarray[$row['x'] . ',' $row['y']] = true// load all the user info we need into an array
}
for(
$b=0$b<=40$b++) // the grid is 40 x 40, this will make the Y columns
{
    for(
$i=0$i<=40$i++) // the grid is 40 x 40, this will make the X rows
    
{
        if (
$userarray[$i ',' $b] == true// If the $userarray says that there is sombody in this location
        
{

            
ImageFilledRectangle($im1+$i*$size21+$b*$size2$size+$i*$size2$size+$b*$size2$enemy);

        }
        else
        {
            
// Nobody lives there, draw some grass.
            
ImageFilledRectangle($im1+$i*$size21+$b*$size2$size+$i*$size2$size+$b*$size2$grass);
        }
    }
}


Rendair 01-17-2008 12:10 PM

The only thing i cant see in that script...unless its just me is the following.

PHP Code:

imagejpeg($im''100); 
imagedestroy($im); 

or something along them lines anyway

cosmokramer 01-19-2008 02:13 AM

Quote:

Originally Posted by Rendair (Post 8728)
The only thing i cant see in that script...unless its just me is the following.

PHP Code:

imagejpeg($im''100); 
imagedestroy($im); 

or something along them lines anyway

where would I add that in?

Wildhoney 01-19-2008 04:48 AM

Right at the very end.


All times are GMT. The time now is 06:30 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0