TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-16-2008, 05:08 AM   #1 (permalink)
The Visitor
 
Join Date: Jan 2008
Posts: 4
Thanks: 0
cosmokramer is on a distinguished road
Default 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...
cosmokramer is offline  
Reply With Quote
Old 01-16-2008, 01:13 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Hum Interesting. Could you perhaps show us your source code so we can take a closer look?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-16-2008, 07:08 PM   #3 (permalink)
The Addict
Upcoming Programmer Top Contributor 
 
Rendair's Avatar
 
Join Date: Nov 2007
Location: UK
Posts: 319
Thanks: 18
Rendair is on a distinguished road
Default

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?
__________________
www.jooney.co.uk - the online portfolio
Send a message via MSN to Rendair
Rendair is offline  
Reply With Quote
Old 01-16-2008, 11:51 PM   #4 (permalink)
The Visitor
 
Join Date: Jan 2008
Posts: 4
Thanks: 0
cosmokramer is on a distinguished road
Default

Quote:
Originally Posted by Rendair View Post
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 is offline  
Reply With Quote
Old 01-17-2008, 12:17 AM   #5 (permalink)
The Visitor
 
Join Date: Jan 2008
Posts: 4
Thanks: 0
cosmokramer is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
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);
        }
    }
}
cosmokramer is offline  
Reply With Quote
Old 01-17-2008, 12:10 PM   #6 (permalink)
The Addict
Upcoming Programmer Top Contributor 
 
Rendair's Avatar
 
Join Date: Nov 2007
Location: UK
Posts: 319
Thanks: 18
Rendair is on a distinguished road
Default

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
__________________
www.jooney.co.uk - the online portfolio
Send a message via MSN to Rendair
Rendair is offline  
Reply With Quote
Old 01-19-2008, 02:13 AM   #7 (permalink)
The Visitor
 
Join Date: Jan 2008
Posts: 4
Thanks: 0
cosmokramer is on a distinguished road
Default

Quote:
Originally Posted by Rendair View Post
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?
cosmokramer is offline  
Reply With Quote
Old 01-19-2008, 04:48 AM   #8 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Right at the very end.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:52 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design