Player goes off screen at Dodge the Creeps

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GuilhermeLR

I am following the tutorial to make Dodge the Creeps and found a problem with the screen. Even using:

postition += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.x, 0, screensize)

The player leaves the screen boundaries (more precisely, to the right and down). It doesn’t move around infinitely, but stops at y 720 (which is actually the size I selected in Project Settings). The problem is that this position does not appear on the screen. I think the problem is not in the code (as i followed the tutorial), but in the project settings, which by the way are:


  • Width: 480
  • Height: 720
  • Resizable: off
  • Borderless: off
  • Fullscreen: off
  • Always on top: off
  • Test width: 0
  • Test height: 0
  • allow dpi: off
  • Use vsync: on
  • Vsyn via compositor: off
    Per pixel transparency:
  • allowed: off
  • enabled: off
  • Orientation: portrait
  • Mode: 2d
  • Aspect: keep
  • Shrink: 1
:bust_in_silhouette: Reply From: magicalogic

This is the line with the error:

position.y = clamp(position.x, 0, screensize)

Replace position.x with position.y