From where does the game engines add location of an object?
Posted
by
Player
on Game Development
See other posts from Game Development
or by Player
Published on 2014-06-04T12:24:15Z
Indexed on
2014/06/04
15:46 UTC
Read the original article
Hit count: 280
collision-detection
|ruby
I have started making my first game( a pong game )with ruby (Gosu). I'm trying to detect the collision of two images using their location by comparing the location of the object (a ball) to another one(a player).
For example:
if (@player.x - @ball.x).abs <=184 && (@player.y - @ball.y).abs <= 40
@ball.vx = [email protected]
@ball.vy = [email protected]
But my problem is that with these numbers, the ball collides near the player sometimes, even though the dimensions of the player are correct.
So my question is from where does the x values start to count? Is it from the center of gravity of the image or from the beginning of the image? (i.e When you add the image on a specific x,y,z what are these values compared to the image?
© Game Development or respective owner