Results 1 to 16 of 16

Thread: Yo Java Help

  1. #1
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default Yo Java Help

    Im trying to make a program that when I click the screen it tell me if I am farther or closer to the desired point from my last click. Unfortunately I don't have the code on hand, but this is the important part.

    Remember I am rather new at this, don't throw anything huge at me.

    mice is the click cordinates and secret is the hidden point

    lastX=nowX
    lastY=nowY
    nowX=secretX-mouseX
    nowY=secretY-mouseY

    then I have an if statement to make the nows positive

    This was the key part that I need help with, what I currently have

    if (nowX<=lastX)
    {
    if (nowY<=lastY)
    message="Hotter";
    else
    message="Colder";
    }
    else
    message="Colder";

    It works OVERALL, but it has some bugs dealing with if you get closer move so on one axis, but move away tiny bit on the other, then it shows it as colder.

    Im this close to using the Pythagorean theorem.

  2. #2
    Defenestration is imminent pichubro's Avatar
    Join Date
    Mar 2005
    Location
    Kaleidoscope Of Mathematics
    Posts
    18,290

    Default

    ... Rather messy, okay...

    Replace message with System.out.println and put the quoted text in ()

    You are also missing a ton of brackets. I would make a rewritten version but I'm on my iPad and screw typing code with my iPad...

  3. #3
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    This is just a short overview, in reality there is mad code all around these.

    I have no idea what you mean with the message. Probably because we aren't that far, I found out how to use the mouse just last week.

  4. #4
    Defenestration is imminent pichubro's Avatar
    Join Date
    Mar 2005
    Location
    Kaleidoscope Of Mathematics
    Posts
    18,290

    Default

    I guessing you are using a modified java grinder.

    System.out.println is the call for java to output. In this case, text.

  5. #5
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    I think I have a String message = "Find the Snail"; initialized

  6. #6
    is good for you
    Join Date
    May 2010
    Posts
    2,783

    Default

    What's your problem, exactly? Like, "(0,0) is your destination. Your first click is at (12,0). Your second one is at (9,0). Hotter. your third one is at (9,1). Colder."

  7. #7
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    No that works (I think).

    If the third one was like (1,3) (or something like that) it would be colder.

    I might just copy the whole thing tommorow.

  8. #8
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    yeah I can't seem to correlate the X and Y, again Pythagorean theorem is in the back og my mind, but that seems messy

  9. #9
    is good for you
    Join Date
    May 2010
    Posts
    2,783

    Default

    Seems like you got some sort of PRIORITY problems going on

  10. #10
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    What do you mean.

  11. #11
    is good for you
    Join Date
    May 2010
    Posts
    2,783

    Default

    One pixel away from the wanted "Y" value has priority over many pixels towards the wanted "X" value. You'd have to show more code if we are to solve it, really. I'm trying to think of a way where you could have just one formula for determining the messages so that they don't conflict, like, for example, if you had one to calculate the net gain of distance towards the point to determine if you are hot or cold

  12. #12
    is good for you
    Join Date
    May 2010
    Posts
    2,783

    Default

    I'm thinking "nowX+nowY<=lastX+lastY" or some BS

  13. #13
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    Quote Originally Posted by Celery View Post
    I'm thinking "nowX+nowY<=lastX+lastY" or some BS
    I don't know how one would code 2 values like that.

  14. #14
    is good for you
    Join Date
    May 2010
    Posts
    2,783

    Default

    What do you mean?

  15. #15
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    last time I did something that it was syntax error fool

  16. #16
    is good for you
    Join Date
    May 2010
    Posts
    2,783

    Default

    Um, put each one under an alias and then put those aliases in the equation? http://opendap.org/api/javaDocs/dods/dap/Alias.html

    If not that, than I am lost as to what your problem is. Do you mean putting two values going IN or two values going OUT?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •