Need Help with trajectory based game equation

  • Thread starter CheatyFace
  • Start date
  • #1

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:

Answers and Replies

  • #2
256
0
If your grid is in pixel , put in pixel
 
  • #3
^how do i convert cm to pixels?? and my screen resolution is 1920 x 1080
 
  • #5
256
0
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
 
  • #6
256
0
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 .
 
  • #7
Doc Al
Mentor
45,029
1,325
angle = atan((v^2 +/- sqrt(v^4g(gx^2+2yv^2)))/gx)
Where did you get this equation?
 
  • #9
6,054
391
Are you designing a game or are you trying to figure out how a particular game works?
 
  • #10
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..
 
  • #11
6,054
391
How did you get g and v? What are their units? x and y should be in the same system of units.
 
  • #12
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..
 
  • #13
6,054
391
The question is where did you get g and v and their units.
 
  • #16
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?
 
  • #17
Doc Al
Mentor
45,029
1,325
Why don't you try measuring it directly? Follow what is said on this wiki page: Pixel density
 
  • #18
172
2
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
Dude I gave you this website
http://members.ping.de/~sven/dpi.html

It will tell your DPI
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..
 
  • #21
256
0
Dude take a scale and measure your diagonal , and put that value there .
Rest is being taken care of at that website .
 

Related Threads on Need Help with trajectory based game equation

Replies
3
Views
3K
  • Last Post
Replies
2
Views
6K
  • Last Post
Replies
1
Views
4K
Replies
7
Views
3K
Replies
11
Views
21K
  • Last Post
Replies
23
Views
2K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
3
Views
14K
Replies
3
Views
1K
  • Last Post
2
Replies
32
Views
7K
Top