Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Design question about maps

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Design question about maps

    Greeting, all.

    I'm developing a game that will employ a large world map. This map will have sections on it where different things will happen (player walks into a section of type "water", colors change, and so on).

    I'll need to define a large number of sections like this, and they will be a large variety of shapes and sizes - no simple boxes. The same section will have the same position every time - these sections will not change during gameplay.

    Of course, I'm going to start small first. However, I'd like to make an optimal design so that if I scale the project up, I won't need to rebuild the project.

    I need to define these sections, in some relatyion to the map.

    My initial thought was that each square in my map could be defined as a type in a database- coordinate 1, 1 is "Water", and so on. Now this makes for an easy check to see where the player is: store the visible squares in a 2d array (so I don't have to query a db ALL the time), then look up where Player is at in the array, and get the type.

    This works on a small scale, but if I want to expand my game map to 1000x1000 or 10000X10000 or bigger, I'm going to run into MAJOR performance problems (I expect - right?)

    So I need another more effective approach that will work on a large scale. I am thinking about defining a section as a polygon (with a list of points), but I'm not sure how to store it, or how to check it if I'm in it or not.

    Can anyone offer some guidance? Surely the database model (or 2d array model) would breakdown as the game expanded, right?

    TIA,

    KJ


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Design question about maps

    The 2D array would work alright as you say for a smaller type of game, however when the actual map starts to scale up to the size where it is no longer viable having it all in memory any more you might want to have a look at height maps.

    Heightmap - Wikipedia, the free encyclopedia
    Height Map Editor Home

    // Json

Similar Threads

  1. Need help with String Trimming.. and displaying Keys on maps.
    By bh-chobo in forum Algorithms & Recursion
    Replies: 1
    Last Post: November 9th, 2009, 01:15 PM
  2. Convert Maps of String to Map of Maps
    By abhay8nitt in forum Collections and Generics
    Replies: 1
    Last Post: October 27th, 2009, 07:27 AM