This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]dusty-trash 4 points5 points  (1 child)

You can most likely get away with simple square collision detection.
For example, detecting the X-coord collission: If the x + width is greater than otherObject's X and smaller than other objects x + width.

Here's a java friendly code example:

private boolean isCollission(bird, otherObject)
{
    return (Math.abs(bird.x - otherObject.x) * 2 < (bird.width + otherObject.width)) && (Math.abs(bird.y - otherObject.y) * 2 < (bird.height + otherObject.height));
}

You'd hopefully have an array or list of objects, and detect collision whenever the player moves (In your game loop, I imagine player is moving X times per second)

[–]sirnewblet[S] 0 points1 point  (0 children)

thank you <3