I'm currently making my first game, a Pong clone. How would I make sure that the paddle doesn't go off screen? I tried an if player.y < gameHeight - 80 (gameHeight is love.graphics.getHeight()) but then the player isn't movable.
Thanks in advance!
How to ensure the player doesn't go off screen
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How to ensure the player doesn't go off screen
The "y" coordinate starts from 0 at the top and increases as we go down. I think your code should look something like this:
Tell us if it worked! Good luck!
Code: Select all
if player.y < gameHeight - 80 then
--movement down
else
--nothing, it's the limit
end
Code: Select all
if player.y > 80 then
--movement up
else
--nothing, it's the limit
end
Re: How to ensure the player doesn't go off screen
Oh, wow! I didn't think of putting the up and down movements in seperate blocks. Thanks a ton!
Who is online
Users browsing this forum: Bing [Bot] and 3 guests