hello
I try to create a Break out , my problem When I move my pad with the mouse , my pad Comes out of the screen
How to prevent my pad To exit the screen ?
Thank you
https://www.dropbox.com/s/93o00rk8disai ... t.zip?dl=0
Bernard
problem with to sprite .
Re: problem with to sprite .
Hey!
Please upload a .love file so it is easier for everyone to test it.
Also some code examples are very helpful. To prevent the paddle from going outside the screen, you can add a simple check.
I didn't look at your code, but something like this would work:
Tweak paddle width accordingly. Good luck!
Please upload a .love file so it is easier for everyone to test it.
Also some code examples are very helpful. To prevent the paddle from going outside the screen, you can add a simple check.
I didn't look at your code, but something like this would work:
Code: Select all
gameWidth = love.graphics.getWidth()
paddleWidth = 50
if paddle.x>gameWidth-paddleWidth then
paddle.x = gameWidth-paddleWidth
end
Computer science student and part time game dev! Currently working on Depths of Limbo!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Re: problem with to sprite .
Thank you evgiz
Do you add to which part of the code?
Do you add to which part of the code?
Re: problem with to sprite .
I can see in love.update you set the position of the paddle. Right below it, simply add the check if its out of the screen.
Hopefully you understand what the code does, otherwise you wont learn anything
love.update is called every frame, and is where game logic should take place most of the time. I'd recommend you take a look on the love wiki for more information!
Hopefully you understand what the code does, otherwise you wont learn anything
love.update is called every frame, and is where game logic should take place most of the time. I'd recommend you take a look on the love wiki for more information!
Computer science student and part time game dev! Currently working on Depths of Limbo!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Re: problem with to sprite .
Hi
Thank you but it does not work the paddle comes out of the screen
Thank you but it does not work the paddle comes out of the screen
Re: problem with to sprite .
Your update function needs some logic to not let that paddle come out the screen.
Code: Select all
function love.update(dt)
-- On deplace la raquette avec la souris
raquette.x = love.mouse.getX()
if raquette.x > (largeur - imageRaquette:getWidth()) then
raquette.x = largeur - imageRaquette:getWidth()
end
if (raquette.x < 0) then
raquette.x = 0
end
end
Re: problem with to sprite .
thank you
Who is online
Users browsing this forum: Bing [Bot] and 2 guests