Max/Min on X axis?

DrGlickertDrGlickert Member Posts: 1,135
edited November -1 in Working with GS (Mac)
So I'd like to make my player not be able to move past a certain point on the X axis...(I'd use collisions against a wall, but I need the actor to be able to move slightly past the side walls (so like halfway off).

What's the best way to do that?

Constrain attribute?

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Yes do something like

    if self.position.x>480
    --Constrain self.position.x to 480

    if self.position.x<0
    --Constrain self.position.x to 0

    Atleast that is one way to do it. :)
  • PhoticsPhotics Member Posts: 4,172
    DrGlickert said:
    What's the best way to do that?

    It depends on your control scheme. For games that use paddles that follow the mouse/touch position, min/max could be used. It's very efficient, as it doesn't require extra rules.
Sign In or Register to comment.