Libgdx tutorial beginner Part 5 – Collision, Camera

Like the previous part for animations heere we will look into collision and camera logic.

  • Bounds is a rectangle that we check for collision with tiles on the map.
  • We get the tiles for collision using fetchCollidableRects.
  • We do two checks for collision, one for left/right and the other for top/bottom
  • In fetchCollidableRects we get the tiles around the player, in case CUBE is fixed we also get its tile

  • OrthographicCamera is our camera that follows bob. Constructs a new OrthographicCamera, using the given viewport width and height.
  • At start it will be positioned in the same position as Bob.
  • To change its position we are using lerp. Lerp linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector.
  • If we are following cube, cubes position will be used.

Recent Posts