1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Need Help with trajectory based game equation

  1. Aug 25, 2012 #1
    1. The problem statement, all variables and given/known data

    i Pmed some mentors but they said i should post it at forum, i asked Astronuc that if its ok to post this in forum and he told me to post it in this section.. i know some users here are very senior and surely have the knowledge to this and i want to learn. it is a trajectory based game where you shoot an object up in air and it should hit the ground where your target is located (where you want it to hit) so you have to fix the angles, distance of you and your target and how deep/high your target is in order to you.. as the speed is always constant FULL POWER. this equation is at nr.2

    2. Relevant equations

    angle = atan((v^2 +/- sqrt(v^4g(gx^2+2yv^2)))/gx)

    3. The attempt at a solution

    for this game the relevant constants are:
    g = 1, v = 0.287p, where p is a value from 5-100 (5 is minpower, 100 is maxpower). Distances are in pixels. for one reason: Shooting at max power (full bar) eliminates any measurement error in determining the muzzle velocity of the projectile, as firing at maximum power guarantees that p is always exactly 100.

    Example of how the game works..

    here you can see me shooting few shots and then aiming and trying to hit the target it takes me 3-4 tries to fix the angle and hit perfect.. but using the above equation, putting in distance, height/weight of target, it would give you an angle to shot in (full power) and it would hit your target with just 1 try..

    another video different map.

    WHAT IS THE PROBLEM? : i am wondering which values to put in x and y.. i am guessing x would be the Distance between me and the target and Y would be the how deep/high the target is.. but how should i find x and y? if i use a ruler to find the distance between me and Target it would give me in cm/inches so should i put x in cms or must i convert it to Pixels? i have almost solved it out, just need help with what values i must put in x and y.

    solving the above equation would give a angle to shot in. I can also give reward to the one who helps me, Astronuc said it is not allowed to give reward to homework helps, but this is not kinda homework its something different so lets c if anyone can help.
    Last edited by a moderator: Sep 25, 2014
  2. jcsd
  3. Aug 25, 2012 #2
    If your grid is in pixel , put in pixel
  4. Aug 25, 2012 #3
    ^how do i convert cm to pixels?? and my screen resolution is 1920 x 1080
  5. Aug 26, 2012 #4
  6. Aug 26, 2012 #5
    hellow , cheaty
    The thing is DPI ( dots per square inch)
    You need to know how much pixels are there per inch or cm^2 , depending on your preferance .
    If you know the area of your screen , you get the ratio to convert pixels in cm .
  7. Aug 26, 2012 #6
    This website did not show my screen's diagonal correctly , since I know its 15 I put that value in the website . You check yourself the diagonal of you screen in inches .
  8. Aug 26, 2012 #7

    Doc Al

    User Avatar

    Staff: Mentor

    Where did you get this equation?
  9. Aug 26, 2012 #8
  10. Aug 26, 2012 #9
    Are you designing a game or are you trying to figure out how a particular game works?
  11. Aug 26, 2012 #10
    i am trying to study the game and i am soo close to it just need a small push.. as i have already found out which equation should be used and WHAT are the relevant constants for that game: g = 1, v = 0.287p and where P is always 100 (MAX POWER) now i need help with how should i find the X and Y. which values to to sit instead of X and Y.. i am guessing x would be distance and Y would be the height of target. but how should i measures the X and Y that is my main question..
  12. Aug 26, 2012 #11
    How did you get g and v? What are their units? x and y should be in the same system of units.
  13. Aug 26, 2012 #12
    g = gravitational constant (which is 1 for this game)
    v = velocity (0.287p, where p = 100)

    x = distance from entity
    y = difference in Y position from entity and player

    the question is how should i measure and find x and y..
  14. Aug 26, 2012 #13
    The question is where did you get g and v and their units.
  15. Aug 26, 2012 #14
    This is the equation for angle

    Attached Files:

  16. Aug 26, 2012 #15
    Sorry for png file
    this one looks good

    Attached Files:

  17. Aug 26, 2012 #16
    yeah i have posted the equation see post nr.8 my problem isnt that... i need to know how to measure X and Y.. how do i measure X and Y. as X = distance of me and target and Y = height of me and the target.. if i use a ruler i would get it in cm must i convert it to Pixels? and as my screen resolution is 1920x1080 how do i find what will be the DPI?
  18. Aug 26, 2012 #17

    Doc Al

    User Avatar

    Staff: Mentor

    Why don't you try measuring it directly? Follow what is said on this wiki page: Pixel density
  19. Aug 26, 2012 #18
    One way you could measure the number of pixels is to make sure the game is set to its actual size (not stretched) and take a screenshot. Crop the part of the screenshot that you want to measure, and check the dimensions of the image.

    If you want to be able to use a real distance measurement (I.E. inches), measure the width of the image on your screen; You can use your two measurements to make a proportion for pixels/inch, and you can use this as a conversion factor. Keep in mind, though, that this conversion factor will only work on your monitor, or one with the same pixel density.
  20. Aug 26, 2012 #19
  21. Aug 26, 2012 #20
    how much i try to change the Diagonal wont change...my screen is 1920x1080 i dont know if it gives me the right value or not cuz even if i put some random numbers the diagonal wont change at all..
  22. Aug 26, 2012 #21
    Dude take a scale and measure your diagonal , and put that value there .
    Rest is being taken care of at that website .
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook