Effectively implementing a game view using java

Posted by kdavis8 on Game Development See other posts from Game Development or by kdavis8
Published on 2012-06-17T00:01:50Z Indexed on 2012/06/17 3:25 UTC
Read the original article Hit count: 876

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;

}

© Game Development or respective owner

Related posts about java

Related posts about game-design