Im pretty decent with php and using mysql.
The map i want to make is simple. Its a Star map of 1 galaxy.
Im going to be using a background image which will stay the same on every block. Then im wanting to echo in the few stars that exist in each block that are clickable. So your basic 2d map.
I also want to allow the user to move left,right,down,up on the map. To do this I will make a link for each side of the block. My problem is how do I select from mysql for that? select the row next to the current block? if so that would only let me to go up or down or left or right. since rows in the table are just in line order.
Im assuming i need two tables. One for the blocks and then one for the stars that match each block by sharing a id number.
Another problem I dont understand is how to tell where each star goes on the block. I was reading the forum and someone mention using div-s which i havnt looked into yet.
If anyone has any good tutor links i would mostly appreciate it.
My first Map
Page 1 of 111 Replies - 754 Views - Last Post: 01 February 2012 - 02:55 AM
Topic Sponsor:
Replies To: My first Map
#2
Re: My first Map
Posted 12 January 2012 - 12:50 PM
SQL is a query language. I don't know why you are trying to use it to render something.
#3
Re: My first Map
Posted 13 January 2012 - 11:34 AM
Thanks for the reply ButchDean
I'm confused. Where did I mention SQL at? I said mysql didnt mention SQL anywhere in my question.
I'm confused. Where did I mention SQL at? I said mysql didnt mention SQL anywhere in my question.
#5
Re: My first Map
Posted 13 January 2012 - 01:04 PM
mysql is a database though SQL is a langauge that mysql can read
#6
Re: My first Map
Posted 13 January 2012 - 01:06 PM
Yes, I see that. But I still can't see why you're using it.
#7
Re: My first Map
Posted 13 January 2012 - 06:18 PM
MySQL is a language for SQL, you can query the databases and get/put data to them but you can't use it to draw images to the screen.
#8
Re: My first Map
Posted 13 January 2012 - 07:30 PM
Okay, show me in code how that method is useful.
#9
Re: My first Map
Posted 16 January 2012 - 02:15 PM
I presume he is creating a web based game and obtaining the map data from a stored webhost database and using MySQL to obtain it.
Obviously he would need some other web based language to interpret and draw the images based on the data retrieved, not drawn from MySQL directly.
Obviously he would need some other web based language to interpret and draw the images based on the data retrieved, not drawn from MySQL directly.
This post has been edited by ShadowsEdge19: 16 January 2012 - 02:16 PM
#10
Re: My first Map
Posted 17 January 2012 - 03:25 PM
You never know what people will try.
#11
Re: My first Map
Posted 01 February 2012 - 02:37 AM
ButchDean, on 17 January 2012 - 03:25 PM, said:
You never know what people will try.
Thanks for the replies guys.
I got it all figured out. Yah im making a web base/text base game. So im grabing cords out of the database for where im placing stuff on the map.
a picture of the map i made.
im curious though cause after i get done learning php really well im going to venture into rendering
what are some rendering languages that i should look into?
This post has been edited by Shadowing: 01 February 2012 - 02:41 AM
#12
Re: My first Map
Posted 01 February 2012 - 02:55 AM
Interesting, in that I'm developing an online game with similar principles. My game is Area Movement, but I'll eventually be implenting grid, hex, and freeform maps.
In terms of the SQL setup, I have quite a few tables just to support the map object, let alone the playable game object. Here's a synopsis of the tables I have:
Aside from that my application necessitates various other tables that are shared between maps and other meta-objects.
You may be able to get away with two tables for what you're doing, in this sort of style...
From there you could have a script that checks whether territories border each other by the following type of code:
In terms of the SQL setup, I have quite a few tables just to support the map object, let alone the playable game object. Here's a synopsis of the tables I have:
- A lookup table for territory types (e.g. - land, sea)
- A lookup table for border types
- A table for map objects
- A table for attachments (i.e. background images)
- A table for territories
- A table for territory borders
Aside from that my application necessitates various other tables that are shared between maps and other meta-objects.
You may be able to get away with two tables for what you're doing, in this sort of style...
Quote
Game
ID (PK)
Width
Height
Territory
ID (PK)
GameID (FK -> Game.ID)
XLocation (int) (constrained between zero and Game.Width)
YLocation (int) (constrained between zero and Game.Height)
ID (PK)
Width
Height
Territory
ID (PK)
GameID (FK -> Game.ID)
XLocation (int) (constrained between zero and Game.Width)
YLocation (int) (constrained between zero and Game.Height)
From there you could have a script that checks whether territories border each other by the following type of code:
// Assuming $source and $target are the source and target territories, and have the same structure as the database
$xDistance = abs($source['XLocation'] - $target['XLocation']);
$yDistance = abs($source['YLocation'] - $target['YLocation']);
if(max($xDistance, $yDistance) == 1 && min($xDistance, $yDistance) == 0)
{
// They border each other
} else {
// They don't border each other
}
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|