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 4 of 4

Thread: Some serious questions,

  1. #1
    Member
    Join Date
    May 2010
    Posts
    39
    Thanks
    4
    Thanked 3 Times in 3 Posts

    Default Some serious questions,

    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,


  2. #2
    Member
    Join Date
    May 2010
    Posts
    39
    Thanks
    4
    Thanked 3 Times in 3 Posts

    Default Re: Some serious questions,

    Come on, anyone? the idea is the center of the screen is the point of intrest, I need a method to draw a image based on the virtual map in perspective to that point

  3. #3
    Member
    Join Date
    May 2010
    Posts
    39
    Thanks
    4
    Thanked 3 Times in 3 Posts

    Default Re: Some serious questions,

    Solved, )

    Mod lock this

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: Some serious questions,

    Congratulations on solving your issue. Sorry I didn't get round to posting sooner..

    How did you solve this in the end?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. [SOLVED] Questions About Threads
    By neo_2010 in forum Threads
    Replies: 4
    Last Post: March 15th, 2010, 09:04 AM
  2. A Few Quick, Easy Questions
    By TheAsianMenace in forum Object Oriented Programming
    Replies: 1
    Last Post: February 24th, 2010, 01:47 PM
  3. Java Questions! :)
    By xs4rdx in forum Java Theory & Questions
    Replies: 0
    Last Post: February 21st, 2010, 07:40 AM
  4. Few very basic Java questions.
    By 01001010 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 13th, 2010, 12:14 PM
  5. Some basic questions.
    By trips in forum Java Theory & Questions
    Replies: 5
    Last Post: July 21st, 2009, 02:15 AM