ewcreators
Mar 28 2008, 05:57 PM
| | Well, i was just wondering if something simple and basic could be made (like a small map where you could move around on, like you click up, and your position moves up and reports it to the database..etc) with co-ordinates in php . Taking the x-axis and the y-axis into consideration. Things like maps which online games have such as web-based space games or legacy-game.net.
Thanks for any feedback, ~Aldo |
Reply
shadowx
Mar 28 2008, 06:27 PM
Well this is possible but i would suggest using AJAX, the interaction between javascript and PHP (google the term AJAX) As this would make the system run smoother. With AJAX it would work as you said, the user clicks a position and something moves there or it is reported to the DB, without AJAX the user would click, then the page would have to reload or go to another page to display the movement or save it to the DB. The second problem you will have is detecting the co-ords (now referred to as CDs) one solution would be to use HTML image maps. Basically use an image as the background or clickable area then define regions within it using HTML. The downside is these regions would essentially make the clickable area into a grid so the user would be able to click on these little squares but it would be crude and would not use CDs but it could be used to move a player one or more squares in any direction. The other option if you need to use CDs is to use Java as i dont think javascript has the capability to track the mouse or mouse clicks. but i kno nothing of Java so i'll let someone else help there.
Reply
ewcreators
Mar 28 2008, 09:13 PM
QUOTE(shadowx @ Mar 28 2008, 02:27 PM)  Well this is possible but i would suggest using AJAX, the interaction between javascript and PHP (google the term AJAX) As this would make the system run smoother. With AJAX it would work as you said, the user clicks a position and something moves there or it is reported to the DB, without AJAX the user would click, then the page would have to reload or go to another page to display the movement or save it to the DB.
The second problem you will have is detecting the co-ords (now referred to as CDs) one solution would be to use HTML image maps. Basically use an image as the background or clickable area then define regions within it using HTML. The downside is these regions would essentially make the clickable area into a grid so the user would be able to click on these little squares but it would be crude and would not use CDs but it could be used to move a player one or more squares in any direction.
The other option if you need to use CDs is to use Java as i dont think javascript has the capability to track the mouse or mouse clicks. but i kno nothing of Java so i'll let someone else help there. the site i play it on )which is a mega hit( , it refreshes..etc and uses co-ords. *waits for alex to butt in
Reply
jlhaslip
Mar 28 2008, 11:15 PM
Just happen to have been checking this out the other day... http://javascript.internet.com/page-detail...oordinates.htmlHere is a javascript snippet/function that snags the mouse co-ordinates relative to the top/left of the display window. Sounds like it would work for what you are needing. Use Ajax or php to communicate the co-ordinates back to the server and you are all set.
Reply
galexcd
Mar 29 2008, 06:09 AM
Well... I wasn't going to post here but since you were waiting for me to "butt in" I'll give you my two cents. There are a few ways you can do it. One would be just plain refreshing as you had mentioned. This should be easy enough. Just have an x position and a y position for every user in sql. Then what you do is you have a table called map with x(int), y(int), and image(string), where x and y are the x/y coord of that tile and image is the url to the image of that tile. You then decide how many tiles you want your viewable area to be (lets say 10). And then have sql select all tiles and users grater than or equal to your y -10 and x -10, but less than your y+10 and x+10. And then you can lay them out in a table. Now that way would work but if you really wanted to make it fancy you could do it with javascript and ajax like shaddow suggested. And yes javascript can get the mouse position. But be sure to use javascript, DO NOT use java. It is TERRIBLE. It is slow, buggy and just loves to run out of memory. Trust me it's not pretty.
Reply
ewcreators
Mar 29 2008, 10:04 AM
You nailed it  <3 Thanks, I wanted to do it that way but never knew how. Everyone, thanks for your feedback  Although , don't "resolve" this thread yet, im going to try it out. Ok, I took a portion of a cleared out map from a game i play (using the map to test only), so now im just trying to code it in a square sort of way, like a graph with a x-axis and a y-axis i already made the database and the table , filled it with the co-ords..etc. Using a while loop doesn't look to promising, so im trying with a for loop. Ok, i did it with a for loop : CODE <?php //connection details echo "<table cellpadding=0 cellspacing=0><tr>";
$select=mysql_query("SELECT * FROM map WHERE x >=1 && y <= 6");
while($map=mysql_fetch_array($select)) {
$x=$map['x']; $y=$map['y'];
if ($x==5) { echo "<td><img src='$map[image]'></td></tr>"; }
else { echo "<td><img src='$map[image]'></td>"; }
}
echo "</tr></table>";
mysql_close($conn); ?>
Reply
ewcreators
Mar 30 2008, 07:07 AM
Quick question, i have everything setup , i am now coding some advanced stuff for my map,so far for now the map displays its entire self, and i want to set the viewable grid/area of the map to like howyou said. So how do i execute my query? I mean what query? SHould i just add x>=..etc because i tried it and my map comes all messed up then.
Reply
jlhaslip
Mar 30 2008, 07:16 AM
Can you post the code and maybe a link to the page so we can see what you have done so far?
Reply
ewcreators
Mar 30 2008, 08:04 AM
QUOTE(jlhaslip @ Mar 30 2008, 03:16 AM)  Can you post the code and maybe a link to the page so we can see what you have done so far? Sure. well, ive only allowed it to be seen by my website staff . Details : Database : Table `map` x(int),y(int),image(varchar), Main Image : http://i98.photobucket.com/albums/l274/Ada...field_3copy.pngSliced it into 225 small images. The map is a 15x15 square grid. But here's the code so far : CODE $select3=mysql_query("SELECT * FROM map_user WHERE username='$_GET[a]'"); $us=mysql_fetch_array($select3); $xu=$us['x']; $yu=$us['y']; $select222=mysql_query("SELECT * FROM ships_users WHERE user='$_GET[a]' && status='roam'"); $coun1t=mysql_num_rows($select222); if ($coun1t < 1) { echo "YOU CANNOT ENTER SPACE WITHOUT A SPACE-SUITED AIRCRAFT!"; } else { echo "<table cellpadding=0 cellspacing=0><tr>"; $select111=mysql_query("SELECT * FROM map WHERE x >=1 && y <=15"); while($map=mysql_fetch_array($select111)) { $x=$map['x']; $y=$map['y']; //if ($xu==$x && $yu==$y) { //if ($x==15) { //echo "<td><img src='$map[image]' border=1></td></tr>"; //} //else { //echo "<td><img src='$map[image]' border=1></td>"; //} //}
if ($x==15) { echo "<td><img src='$map[image]'></td></tr>"; } else { echo "<td><img src='$map[image]'></td>"; }
} echo "</tr></table>";
}
Reply
galexcd
Mar 30 2008, 05:12 PM
QUOTE(ewcreators @ Mar 30 2008, 01:04 AM)  Sure. well, ive only allowed it to be seen by my website staff . Details : Database : Table `map` x(int),y(int),image(varchar), Main Image : http://i98.photobucket.com/albums/l274/Ada...field_3copy.pngSliced it into 225 small images. The map is a 15x15 square grid. CODE $select111=mysql_query("SELECT * FROM map WHERE x >=1 && y <=15"); A few problems. First of all I've never used && in sql. I'm not quite sure if that works or not. I'd try capital AND. Also where are your other two comparisons? Remember you want to select the tiles between something. This is just kind of an odd query. I wouldn't suggest using separate numbers here unless you wanted the player to be off center. So here is how you would figure out your query: CODE $verticaltiles=10; $horizontaltiles=10; //SET PLAYER X AND Y TO THESE VARIABLES: $x=playerx $y=playery
$select111=mysql_query("SELECT * FROM map WHERE x>=".($x-$horizontaltiles/2)." AND x<=".($x+$horizontaltiles/2)." AND y>=".($y-$verticaltiles/2)." AND y<=".($y+$verticaltiles/2)); Tell me if this works.
Reply
Latest Entries
ewcreators
Apr 1 2008, 04:48 PM
tried it out, didn't work as expected . Thanks for the help alex, but tis' okay. I'll show the map as an entire .
Reply
ewcreators
Apr 1 2008, 12:14 PM
i just used a while loop to display the images, cool cat. And i set the images to the backround of the table data cell. And during the while loop, if the current image x,y co-ords being generated == to the current player's co-ordinates, it places a small image to show where the player is. And alex , ill try out your code.
Reply
Recent Queries:--
pc san andreas co-ordinates - 187.79 hr back.
-
legacy-game.net cheat - 451.04 hr back.
Similar Topics
Keywords : creating ordinates php web based php games som- Evilboard (forum Software) - Multiple Categorys - Don't Work :(
- I am creating a forum and i can't fix more then 1 category. (6)
I am at the moment trying to program my own forum, but i need more then a single category, here is
my source: CODE function cat () { include("functions/functions.php");
echo '<table width="100%" border="0" cellspacing="0">
<tr> <td class="eb_top" colspan="3" style="border-bottom-width:
0; height: 30px; font-size: 12px;"> <b>Forum</b></td>
</tr>'; global $catid; $db = new db; $db->connec...
Sending E-mails Based On Intervals?
- (7)
Remove A Value From A Php Array Based On Its Value
- (5)
I have an index array CODE $array[0] = 10; $array[1] = 12; ...
Its kinda late and I'm falling asleep now but I had a quick look through PHP.net, and could not
find what I'm after, Maybe I'm too sleepy, sorry, but if anyone knows off the top of their
head a way to removed members in that array based on its value, i.e. I wanna remove values 12. I
don't really want to do a loop but if I cant find any existing function to do it, then I may
have to. Thanks for any help....
Creating Profiles In Php/mysql ?
- (7)
i've started to learn php..im familiar to basics of php and mysql now.Now for example i want
that some user can register to my website , and after that he can Login and log out , and he can see
his profile.is there any tutorial about this ? or any helping url .. or any helping answer please
/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />...
Looking For Command Line Based Sql Modification
- Program Needed For SQL? (1)
How I use Windows command prompt client and do modifications to my SQL database. If yes, please
write the commads I should know for that. If no, please get me the software with which I can do it.
Topic title modified. Proper English is always required when posting in our forum. ...
Php And Flash Image Gallery
- Need some help in creating or editing an xml file while viewing some o (5)
Hello there and thanks for the helping hand you are offering. PHP newbie here! /ph34r.gif"
style="vertical-align:middle" emoid=":ph34r:" border="0" alt="ph34r.gif" /> So here is my problem:
On my website I have a flash image gallery.The way the gallery works is by uploading pictures in a
folder and editing? an xml file.(pics.xml) where it adds the following code when you upload a
picture: CODE <pictures> <image location="nameofpicture1.jpg"
desc="" /> <image location="nameofpicture2.jpg" desc="" /...
Php And Irc
- PHP-based IRC web client (5)
I am wondering whether or not you could create a basic client for IRC using PHP. I know that PHP
does have IRC functions which I read about on php.net. I am not quite sure whether or not a client
could be built around this. I do know that there is a CGI IRC client on the web. I use this while I
am on my Wii I am wanting to incorporate a PHP IRC client into my website and use AJAX to
automatically reload the chat. Well, if anybody could help that would be great....
Graphical Gaming?!
- In some games you see those...... (1)
In some games you see those graphical bars which show your experience or your hp/life ..etc How can
i make something like that in php?...
Dynamically Select From 2 Tables Based On Id
- dynamically select from 2 tables based on id (1)
hi there, im working on a performance request system, and i have three tables that im working with
right now. the performances table holds the info about the performance (date, times, status, etc.),
and has two columns, org_type and org_id, which both hold an int value to tell me where the
organization info is. there are two org types which have respective tables, because we collect
different information based on the type of org that is registering. is there any way to select info
from all three tables (dynamically selecting between the two org tables based on org_type,...
Creating A Login Box That Links To My Phpbb Forum
- Have my phpBB Forum Intergrated with my Website (4)
Can someone please give me a code that I can use to put a login box on my website, that will login a
user into my phpBB Forum? Sort of like Having my phpBB Forum Intergrated with my Website? Thank you
so much if you can! /angel.gif" style="vertical-align:middle" emoid=":angel:" border="0"
alt="angel.gif" /> Ex. ...
Multiplayer Php Games?
- i have an inefficient idea (4)
Well I was thinking about making a little multiplayer game in php today and I was wondering, how
would I do this. Well I came up with an enormous and quite inefficient way..Lets say I wanted to
show what users were at the same place as you. Well, I would use databases, 1 to say what location
and 1 to say if the players are online. Then if the player is online and at the location, say
they're their. I think this is inefficient, but is there any other way?...
Creating Communities/groups In Php ?
- (2)
for example , if on my website, i have made some kind of members area.that the users can join.i want
to learn that , they can create the groups...and then others can join their groups... for example ,
some one creates the group "fun" , and the others existing users can join that ... etc ? can some
one give me some idea about it ?? if possible some kind of tutorial/Script/ url link etc ?? thanks.....
Php Programmers, How Long To Finish Your Scripts?
- time spent on creating php scripts (23)
Hello. I am currently working on kShoutBox 0.5 which has many new features. Now I realize that
it's really really and i mean really difficult to create a PHP script because it really do takes
your time. Example when I don't know what to do or what function to use, i check out the php
manual, and you know, i use the old tradition "Trial and Error"....
Flash Games And Post Data
- (0)
i want to put a highscore section for a bunch of flash games on a website. i know that when most
games are done the score is in the post data, which can be viewed if you have the firefox live http
headers extension. but how would you insert the postdata from the flash games into the database?...
PHP Games
- (5)
I was wondering (and also wanted to ask the PHP experts, since I'm not /dry.gif"
style="vertical-align:middle" emoid=" ) about those PHP games, the turn-based strategy games like
Kings of Chaos, Dark Throne, etc... Is there a set of code or better yet a tutorial that tells how
to create PHP games, or you just have to learn PHP and utilize what you learn? I'm afraid it
might be the second one... /unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0"
alt="unsure.gif" />...
Looking for creating, ordinates, php, web, based, php, games, map, som
|
|
Searching Video's for creating, ordinates, php, web, based, php, games, map, som
|
advertisement
|
|