Results 1 to 7 of 7
  1. #1
    Ruuhkis is offline Member
    Join Date
    Feb 2011
    Posts
    19
    Rep Power
    0

    Default Help me with maths on my program!

    Hello, i am in need of help with doing some calculations on my program. I am not really in all the math functions but i want to learn the way how can i calculate the right x and y speed for ball to go on correct angle. like if ball's y speed was 1 it would go just up. (0) Actually i want the ball go in the direction of certain position to mouse's position. Can anyone help me with this, i found much similar stuff to this but not well explained. Heres example: YouTube - Little Java game also theres source for the code used but its commented in norway and the maker havent responsed yet. Can you guys please help me with this?

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Have you actually attempted to write any code for this?

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  3. #3
    ojn
    ojn is offline Senior Member
    Join Date
    Aug 2008
    Location
    Stockholm, Sweden
    Posts
    119
    Rep Power
    0

    Default

    This isn't a coding factory and I seriously doubt anyone's gonna visit several external sites checking someone else's(!!!) code when you haven't even tried for yourself first.

    Come back when you have own attempts to show us. Although I get a strong feeling you have no idea how to even begin, which means you're in way over your head. Feel free to prove me wrong.

  4. #4
    Ruuhkis is offline Member
    Join Date
    Feb 2011
    Posts
    19
    Rep Power
    0

    Default

    This was not about managing to do it, i want to learn the way how to do it. I did it with the help of the code from the video i linked and it works, but now i want to figure out why it works, where do i need squareroot of distances and so on. I show you the code and please explain the calculation part for me if you're such kind person! :)
    Java | import java.awt.Dimension; import java.awt.Graphi - BallTest

  5. #5
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    If you are concerned about what happens inside the sqrt method of Math class, then it's just a static method which takes the parameter and returns the positive square root of it. Have a look at Math.sqrt(double d) documentation.

    If you are starting along the path of Java, I would strongly recommend you to have a look at the Java API documentation provided here: Java 6 API

    There would be many things along the way, that you might not understand and going through documentation will help you out.

    Best of luck,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  6. #6
    Ruuhkis is offline Member
    Join Date
    Feb 2011
    Posts
    19
    Rep Power
    0

    Default

    I am wondering how i can get the right and x and y speed throught the sqrt of distances between 2 objects ;o

  7. #7
    Ruuhkis is offline Member
    Join Date
    Feb 2011
    Posts
    19
    Rep Power
    0

Similar Threads

  1. Maths for programming
    By ron2794 in forum New To Java
    Replies: 3
    Last Post: 12-17-2010, 08:17 AM
  2. Maths Packages
    By Anish in forum Advanced Java
    Replies: 7
    Last Post: 11-27-2008, 06:46 AM
  3. Whats wrong with my maths???
    By soc86 in forum New To Java
    Replies: 4
    Last Post: 11-03-2008, 05:52 PM
  4. Replies: 15
    Last Post: 11-30-2007, 05:19 PM
  5. Generates random maths questions
    By cachi in forum New To Java
    Replies: 4
    Last Post: 08-01-2007, 04:48 AM

Posting Permissions

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