converting a decimal to an int
Hi, good to be here.
I am writing a program that simulates a projectile's trajectory. I have the mathematical equation to do so but I have a problem when I try to implement graphics.
The problem is that when I compute the math the resulting X and Y co-ordanints of the projectile ends up in a long decimal..
for example the X co-ordanint might be 9.2938 and the Y co-ordanint might be 17.3726.
The graphical framework I'm using only excepts integers when drawing objects to the screen so I can't use the exact position of the X and Y co-ordanints. This model does not have to be extremely accurate so I figure the easy way to solve this problem is to round the number with "Math.round()" function.
This is math equation I'm trying to round...
yPos = Math.round((startHeight + velocity * Math.sin(angle) * time - gravity * time * time/2));
xPos = Math.round((startLength + velocity * Math.cos(angle) * time));
when I try to do this I get an error saying, "Possible loss of precision. found: long, required: int"
All the variables in this equation are type "double", and the xPos and Ypos variables are type int...
Can someon please enlighten me on the situation?