11 Replies - 754 Views - Last Post: 01 February 2012 - 02:55 AM Rate Topic: -----

Topic Sponsor:

#1 Shadowing  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 26-November 11

My first Map

Posted 12 January 2012 - 09:07 AM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: My first Map

#2 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

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. :mellow:
Was This Post Helpful? 0
  • +
  • -

#3 Shadowing  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 26-November 11

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.
Was This Post Helpful? 0
  • +
  • -

#4 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: My first Map

Posted 13 January 2012 - 11:57 AM

View PostShadowing, on 13 January 2012 - 06:34 PM, said:

Thanks for the reply ButchDean

I'm confused. Where did I mention SQL at? I said mysql didnt mention SQL anywhere in my question.

You mention MySQL in your initial post. :unsure:
Was This Post Helpful? 0
  • +
  • -

#5 Shadowing  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 26-November 11

Re: My first Map

Posted 13 January 2012 - 01:04 PM

mysql is a database though SQL is a langauge that mysql can read
Was This Post Helpful? 0
  • +
  • -

#6 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

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.
Was This Post Helpful? 0
  • +
  • -

#7 RandomOctopus  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 18
  • Joined: 12-January 12

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.
Was This Post Helpful? 0
  • +
  • -

#8 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: My first Map

Posted 13 January 2012 - 07:30 PM

Okay, show me in code how that method is useful.
Was This Post Helpful? 0
  • +
  • -

#9 ShadowsEdge19  Icon User is offline

  • D.I.C Addict


Reputation: 140
  • View blog
  • Posts: 660
  • Joined: 16-January 10

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.

This post has been edited by ShadowsEdge19: 16 January 2012 - 02:16 PM

Was This Post Helpful? 0
  • +
  • -

#10 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: My first Map

Posted 17 January 2012 - 03:25 PM

You never know what people will try.
Was This Post Helpful? 0
  • +
  • -

#11 Shadowing  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 26-November 11

Re: My first Map

Posted 01 February 2012 - 02:37 AM

View PostButchDean, 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?

Posted Image

This post has been edited by Shadowing: 01 February 2012 - 02:41 AM

Was This Post Helpful? 0
  • +
  • -

#12 e_i_pi  Icon User is online

  • = -1
  • member icon

Reputation: 361
  • View blog
  • Posts: 1,020
  • Joined: 30-January 09

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:
  • 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)


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
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1