Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am writing a 2d game in java. The game mechanics are similar to the Pokémon game boy advance series e.g. fire red, ruby, diamond and so on.

I need a way to draw a huge map maybe 5000 by 5000 pixels and then load individual in game sprites to across the entirety of the map, like rendering a scene. Game sprites would be things like terrain objects, trees, rocks, bushes, also houses, castles, NPC's and so on. But i also need to implement some kind of camera view class that focuses on the player. the camera view class needs to follow the characters movements throughout the game map but it also needs to clip the rest of the map away from the user's field of view, so that the user can only see the arbitrary proximity adjacent to the player's sprite. The proximity's range could be something like 500 pixels in every direction around the player’s sprite. On top of this, i need to implement an independent resolution for the game world so that the game view will be uniform on all screen sizes and screen resolutions.

I know that this does sound like a handful and may fall under the category of multiple questions, but the questions are all related and any advice would be very much appreciated. I don’t need a full source code listing but maybe some pointers to effective java API classes that could make doing what i need to do a lot simpler. Also any algorithmic/ design advice would greatly benefit me as well.

example of what i am trying to do in source code form below

package myPackage;

/**
 * The Purpose of GameView is to: Render a scene using Scene class, Create a
 * clipping pane using CameraView class, and finally instantiate a coordinate
 * grid using Path class.
 * 
 * Once all of these things have been done, GameView class should then be
 * instantiated and used jointly with its helper classes. CameraView should be
 * used as the main drawing image. CameraView is the the window to the game
 * world.Scene passes data constantly to CameraView so that the entire map flows
 * smoothly. Path uses the x and y coordinates from camera view to construct
 * cells for path finding algorithms.
 */

public class GameView {

    // Scene is a helper class to game view. it renders the entire map to memory
    // for the camera view.
    Scene scene;

    // Camera View is a helper class to game view. It clips the Scene into a
    // small image that follows the players coordinates.
    CameraView Camera;

    // Path is a helper class to game view. It observes and calculates the
    // coordinates of camera view and divides them into Grids/Cells for Path
    // finding.
    Path path;

    // this represents the player and has a getSprite() method that will return
    // the current frame column row combination of the passed sprite sheet.
    Sprite player;
}
share|improve this question
add comment

1 Answer

I don't think Java will be able to deal directly with an image this size very effectively, especially if the intended target is online. I think you would do well to construct a run-time view at screen resolution from multiple tiles at precomputed multiple resolutions.

share|improve this answer
    
When you say "construct a run-time view at screen resolution from multiple tiles at precomputed multiple resolutions." what exactly do you mean? –  kdavis8 Jun 17 '12 at 1:23
    
I mean you need a bunch of smaller images that you only load as needed, and use them to assemble the desired picture at screen resulution. Typically these are also present in a hierarchy of prescaled sizes. Another common technique is to construct an infinitely large map on the fly, from a small number of componnets which are designed to fit together. –  ddyer Jun 17 '12 at 1:47
    
Most maps for 2D overhead-ish games are built up from tiles, which is basically a bunch of indexes into a texture atlas, which itself is a big bitmap of texture blocks designed to draw next to one another. No one really uses a huge 5k x 5k texture (aka 25 megabytes at only 8bit resolution). That's kind of what he means, with the complication he added of multiple resolutions which you'd only need for scaling from phones to pads, for example. –  Patrick Hughes Jun 17 '12 at 1:47
    
thanks your comments sound a lot more effective than what i originally had planned. Quick Question though... should implement these background tiles using Array List or Linked List? –  kdavis8 Jun 17 '12 at 4:55
    
I'd recommend researching existing 2D tile engines, there are many written in Java and their beacon might keep you from sailing into shallow waters and floundering. You also have to consider an Editor for this map, which is a fair bit of work itself. I assume your goal is to build your own engine instead of actualize a game design? –  Patrick Hughes Jun 17 '12 at 5:08
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.