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.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Beginner Question

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Thanked 0 Times in 0 Posts

    Default Beginner Question

    Ok, so long story short, I am just trying to pick up some knowledge on Java. I am learning Java for a specific project, but I need some help on some stuff that no tutorials on the net seem to cover.
    At the moment, I only need to know how to 2 different things that I canít find anywhere else (nor do I know what to Google to try to find a guide on them as I donít know exactly how to go about doing it).
    What I am attempting to do is to write a very simple macro/bot for an MMO, what I need the bot to do is check that something is present (in this case it is a wreck), I need this program to check a specific pixel location, and if it is white do one thing, if its black, do another. I could find the exact hex code for the color I need it to check for and all that and I know how to make the IF statement and the functionality for what it would do after that, but I donít know how to write the function where the bot checks what color that pixel is. It is a picture as well, so I could take a screenshot and have it check for the entire picture (it is only probably 5px by 5px). To sum this question up, how to I make the program check pixel location ( x , y ) to see if it is color (#xxxxxx) or if it is color (#yyyyyy) at which point I would make an IF statement to do one thing (what I want it to do) if the pixel is (#xxxxxx) or go somewhere else and check again if it is (#yyyyyy). I keep rambling but all in all I need it to check ( x , y ) for what color that pixel is.

    Secondly, the game I am writing this for displays the distance between you and the selected item in KM in 2 spots consistently, and I need it to approach (simple as double clicking it) if the distance is greater than a certain number (50 for example), or do something else if the selected entity is greater than 50 KM. For this, the program would have to check those two locations and be able to convert the image to a number, as it isnít anything you can copy, it is just displayed. So how would I have it convert a displayed number to a number I could use to define the distance and write another IF/THEN statement for if distance>x and for x>distance. Could anyone point me toward a script that will do this or tell me how at all?

    Those are my two questions for now that I canít seem to find anywhere else, though I am sure that I will find another 100 questions before I am done with this. Any help with these two would be greatly appreciated. Thanks!

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Beginner Question

    The Robot class can create a BufferedImage screenshot. The BufferedImage can give you the pixel value of a particular coordinate. The API is your friend: Java Platform SE 6

    I think what you're talking about in the second part has something to do with image recognition or OCR, which is actually a really complicated field. I'd try looking for a third party library that does what you're looking for.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] Simple question from a beginner
    By jimmylee7706 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 6th, 2011, 09:57 PM
  2. Quick, beginner-level Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2011, 01:06 PM
  3. [SOLVED] While Loop Help (beginner)
    By Perplexing in forum Loops & Control Statements
    Replies: 4
    Last Post: October 23rd, 2010, 02:00 PM
  4. Basic Beginner Help
    By SRD in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 11th, 2010, 04:27 PM
  5. I need a help ! i am beginner
    By yinky in forum Java Theory & Questions
    Replies: 3
    Last Post: September 30th, 2009, 07:22 AM