Results 1 to 8 of 8
  1. #1
    TacoManStan is offline Member
    Join Date
    Sep 2011
    Posts
    50
    Rep Power
    0

    Default What is the standard way of making 2D terrain?

    Hey all, well I didn't know whether to consider this an "advanced" topic or not, but I thought I might as well put it here.

    I am making a top down WASD game, based on a grid system. Each tile in the "map" is assigned a "GameObject" object, which extends JComponent. In other words, I can have up to 500 JComponents loaded at once, all with a lot of detail. A lot of them (actually, 90% of them) are off-screen.

    So, is there standard way of doing this? Would it be okay to load a GameObject only when it comes within say 2 "tiles" of actually being on screen? Would adding all tiles to one JComponent be better? That wouldn't be ideal, as it would require re-writing my entire system on "interacting" with object.

    So, any ideas?

  2. #2
    TacoManStan is offline Member
    Join Date
    Sep 2011
    Posts
    50
    Rep Power
    0

    Default Re: What are the benefits of Java?

    Thanks guys. By the way I was just asking about Paypal and such for future reference. It isn't something that will be relevant for a while, unfortunately.

    But yeah, this has clarified a bunch. I have a question that probably should be in a new thread, but it sort of relates indirectly so I will post it here if anyone has a quick answer.

    You claim that Java has a "heap". In fact, I found that out the hard way yesterday when my game was loading. I got an memory error in the compiler. I have terrain in the map. Right now it looks pretty much exactly like Pokemon. Each of the "tiles" has an image, and each image is animated. So for example I have a patch of grass that looks like it it swaying back and forth in the wind. Each tile is loaded as a separate class that extends JComponent. This is actually another reason why I asked this question.

    I loaded a map the size of 50x50, which is what, 2,500 JComponents? My solution was to, because the only visible part of the screen is 21x10, to only load the tiles when they are needed. My question is, why does this take up so much memory? I am aware that I am obviously doing this in an incredibly inefficient way, but could something like C++ handle that?

    Oh and sorry I couldn't resist, I know this part should really be in a separate thread, but how should I be doing this? Should I be loading everything onto one JComponent? Should I even be using JComponent at all? Should I even be using Swing? I really don't know these things, but it seemed like Swing was the way to go.

  3. #3
    TacoManStan is offline Member
    Join Date
    Sep 2011
    Posts
    50
    Rep Power
    0

    Default Re: What is the standard way of making 2D terrain?

    Any mod want to move this to the beginner forum, as it is clearly not advanced enough for this forum?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: What is the standard way of making 2D terrain?

    There's a Java Gaming bit further down the forum list.
    Might have more luck there, since they do a lot of this sort of thing.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: What are the benefits of Java?

    I wouldn't use components.
    They're pretty hefty things just for tiling.
    Does each one have its own image?

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: What are the benefits of Java?

    You could even customize a JTable for tiling. The values in the table could be ImageIcons and the columnClass would be Icon.class

    That's probably what I would try.

    db

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default Re: What is the standard way of making 2D terrain?

    Quote Originally Posted by TacoManStan View Post
    Any mod want to move this to the beginner forum, as it is clearly not advanced enough for this forum?
    done.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: What is the standard way of making 2D terrain?

    I've merged the related posts from the other thread. Let's keep this discussion all in one place.

    db

Similar Threads

  1. Standard input
    By Jey in forum New To Java
    Replies: 2
    Last Post: 08-18-2011, 10:31 AM
  2. standard deviation calculation
    By rochla16 in forum New To Java
    Replies: 5
    Last Post: 04-28-2011, 07:27 PM
  3. JSP standard actions
    By subhashis_mohanty in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 11-27-2010, 07:35 AM
  4. Replies: 0
    Last Post: 11-23-2010, 08:48 PM
  5. 3D Terrain on Sphere?
    By quddusaliquddus in forum Advanced Java
    Replies: 1
    Last Post: 06-22-2009, 11:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •