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

Thread: Class Waypoints

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    13
    My Mood
    Relaxed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Class Waypoints

    Hello everyone!

    I know that in Java is class WayPoint but I do not have a clue how it works. Is it just for gps systems?

    I need to create program where are waypoints and white point is following them. That white point is controlled by keys - W (forward), A (left), S (backward), D (right), but it is moving like a car. That means if it (point) is "looking" to the north and want to go on west then class Robot has to press W and A at the same time (for cca 1 sec. to turn left - 90°).

    I think it will be difficult to write it.

    I guess there has to be another function (or 'constructor' is right?) which will be returning current position of white point. Something like this Help with Robot Class ?
    Last edited by Vergil333@gmail.com; January 28th, 2012 at 02:05 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Class Waypoints

    What package is the WayPoint class in?

    What kind of program are you trying to write? Are you going to use the Java SE classes?

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    13
    My Mood
    Relaxed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Class Waypoints

    For now I have only one package. Do I need to create new package? I am not even sure what is their purpose. I installed NetBeam just 2 weeks and I wasn't programming in Java before.

    Java SE... had to use google to find out what SE means (Standard Edition). Yes, I am using Java SE classes so far.

    There is a car simulator. On left bottom corner is mini-map. White point is position of the car. And I want to add to the mini-map waypoints and let Robot to control the car. And I need to know how to do that, what to use and everything that can help me because I am just beginner in Java

    I am not sure if I have to use class WayPoints or not.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Class Waypoints

    I know that in Java is class WayPoint
    Where did you see that there was a WayPoint class in Java? I've never seen it.

    What is a car simulator? How does that connect with a java program?
    Same question about the mini-map, What is it and how does connect with a java program?

    If you are just beginning java there are many things you will have to learn before starting to write this program.

  5. #5
    Junior Member
    Join Date
    Jan 2012
    Posts
    13
    My Mood
    Relaxed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Class Waypoints

    WayPoint (Envinsa 4.1 Java Edition)
    I found it on google when I was looking for creating waypoints... So it is not in Java SE then?

    I wanted to use this for detecting car's position:

    import java.awt.*;
    import java.awt.Toolkit;
    import java.awt.image.BufferedImage;
    import java.awt.Dimension;
     
    public class PixelScan
    {
        static Robot r;
        static BufferedImage bi;
        static Toolkit toolkit = Toolkit.getDefaultToolkit();
        static Dimension scrn = toolkit.getScreenSize();
        public static void main (String[] args)throws AWTException
        {
            r=new Robot();
            bi=r.createScreenCapture(new Rectangle(1153,525,206,209));
            Color c=new Color(222,222,221); //we are looking for white colour
            for(int x=0;x<ff.scrn.width;x++)
            {
                for(int y=0;y<ff.scrn.height;y++)
                {
                    if(bi.getRGB(x, y)==c.getRGB())
                    {
                        return x,y; // this has to be fixed, not sure how to return coordinates
                    }
                }
            }
        }
    }

    In Rectangle: 1153 is 'x' and 525 is 'y' coordinate of the beginning point/pixel of rectangle (mini-map in our case) - left upper corner.
    206 is width to the right of rectangle and 209 is height to the down of the rectangle, right?


    x=1153,525
    x---------------> End of this point is 1153+206 (width of mini-map)
    |
    |
    |
    |
    |
    |
    ˇ End of this point is 525+209 (height of mini-map)

    Robot r will create a screen of that rectangle and then double 'for' and 'if' will find position of white point/pixel.

    Based on that the robot will be simulating keypress (W,A,S,D) to control the car.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Class Waypoints

    .. So it is not in Java SE then?
    That's correct, it is not in Java SE. That link goes to some third party's code.

Similar Threads

  1. Replies: 7
    Last Post: July 21st, 2011, 02:29 PM
  2. In a class create an array list of elements of another class, help!
    By LadyBelka in forum Collections and Generics
    Replies: 3
    Last Post: May 4th, 2011, 05:00 PM
  3. Replies: 3
    Last Post: April 13th, 2011, 03:30 PM
  4. Help requested - testing a class with a tester class, no methods allowed.
    By miketeezie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 21st, 2011, 10:40 PM
  5. Replies: 0
    Last Post: April 11th, 2010, 08:56 AM