Need Help with trajectory based game equation

Homework Statement

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

Homework Equations

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

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:

If your grid is in pixel , put in pixel

^how do i convert cm to pixels?? and my screen resolution is 1920 x 1080

any1?

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 .
http://members.ping.de/~sven/dpi.html

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 .

Doc Al
Mentor
angle = atan((v^2 +/- sqrt(v^4g(gx^2+2yv^2)))/gx)
Where did you get this equation?

Where did you get this equation?

the equation is from "Angle θ required to hit coordinate (x,y)" taken from Wikipedia..

here: http://en.wikipedia.org/wiki/Trajectory_of_a_projectile#Angle_required_to_hit_coordinate_.28x.2Cy.29

Are you designing a game or are you trying to figure out how a particular game works?

Are you designing a game or are you trying to figure out how a particular game works?

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..

How did you get g and v? What are their units? x and y should be in the same system of units.

How did you get g and v? What are their units? x and y should be in the same system of units.

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..

The question is where did you get g and v and their units.

This is the equation for angle

Attachments

• 8380d78ccac32ae4bcfdb6f3ef840613.png
1.5 KB · Views: 330
Sorry for png file
this one looks good

Attachments

• 8380d78ccac32ae4bcfdb6f3ef840613.jpg
4.1 KB · Views: 386
Sorry for png file
this one looks good

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?

Doc Al
Mentor
Why don't you try measuring it directly? Follow what is said on this wiki page: Pixel density

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.

Dude I gave you this website
http://members.ping.de/~sven/dpi.html