How can i draw a line in this [SOLVED]
Posted: Thu Apr 20, 2023 1:35 pm
Hi,
This is dvd screensaver thingy and i was wondering that how can i draw lines where the square goes
The code
Thanks !
This is dvd screensaver thingy and i was wondering that how can i draw lines where the square goes
The code
Code: Select all
function love.load()
game = {
x = love.graphics.getWidth() / 2,
y = love.graphics.getHeight() / 2,
mov_x = 0,
mov_y = 0
}
end
function love.update(dt)
if game.mov_x == 0 and game.mov_y == 0 then
game.mov_x = 10
game.mov_y = -10
end
game.y = game.y + game.mov_y
game.x = game.x + game.mov_x
if game.y < 0 then
game.mov_y = 10
end
if game.y + 40 > love.graphics.getHeight() then
game.mov_y = -10
end
if game.x + 40 > love.graphics.getWidth() then
game.mov_x = -10
end
if game.x < 0 then
game.mov_x = 10
end
end
function love.draw()
love.graphics.rectangle("line", game.x, game.y, 40, 40)
love.graphics.print("X:"..game.x.."mov_x:"..game.mov_x)
love.graphics.print("Y:"..game.y.."mov_y:"..game.mov_y, 0, 10)
end