Well heres my idea,
The character(in my game) is centerd in the midle of the JFrame, upon movement, the character animates, but the only thing that actually move's is the environment around him.
Well Here's what I need, I need help making a method that return a image based on a virtual game map with virtual gameCoords.
Evan though the size of the game screen (JFrame) is 1000 x 800, The method should be based on objects near it,
here because you guys dont have my source, Ill show you guys how you can start off:
/** * Return a 1000 x 800 image based on absX, and absY, * * Turned into a ?? x ?? Virtual Map <-- TODO: Come up with a good size, for now 64 by 64 * * @param absX * @param absY * @return */ public BufferedImage getVirtualMap(Player p) { BufferedImage enviorment = Util.toBufferedImage(Main.getImageDatabase().getImages().get("backround").getImage().getScaledInstance(1000, 800, 0)); Graphics g2 = enviorment.getGraphics(); List<GameObject> nearByObjects = new ArrayList<GameObject>(); for(GameObject gameObject : gameMap.getGameObjects()) { if(Util.getDistance(gameObject.getAbsX(), gameObject.getAbsY(), p.getX(), p.getY()) <= /* */) { nearByObjects.add(gameObject); //g2.drawImage(gameObject.getDefinition().getSprite().getImage(), WHERE, null); } } System.out.println("Total nearby objects : " + nearByObjects.size()); /** * TODO: * * Use g2, to draw Objects and such, */ g2.dispose(); return enviorment; }
If you need anything just let me know, Ill gladly post, and here's the inDistance method im using:
/** * @return Returns the distance between two positions. */ public static int getDistance(int coordX1, int coordY1, int coordX2, int coordY2) { int deltaX = coordX2 - coordX1; int deltaY = coordY2 - coordY1; return ((int) Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2))); }
The "GameMap" is the virtual map with the objects and such, the "Player" is just a instance of the person playing the game,
I hope you guys get what I need,