How do i create a auto moving character without any user inputs
Posted: Fri Dec 01, 2017 7:14 am
Hi!!
Im have this idea of creating a endless runner but i cant seem to create a function for the player's character to move forward without any user inputs(much like how flappy bird moves forward)
please help me get some idea in how to do this and how it works so that i can implement it on future stuff...
Any help would be appreciated!
Im have this idea of creating a endless runner but i cant seem to create a function for the player's character to move forward without any user inputs(much like how flappy bird moves forward)
please help me get some idea in how to do this and how it works so that i can implement it on future stuff...
Any help would be appreciated!
Code: Select all
function love.load()
-- FullScreen
love.window.setFullscreen(true, "desktop")
end
--Player Stats
player ={x = 100, y = 375, speed = 5 }
function love.update(dt)
--Auto Forward Action
--Keyboard S and W or Up and Down
if love.keyboard. isDown("s") then
player.y = player.y + player.speed
end
if love.keyboard. isDown("w") then
player.y = player.y - player.speed
end
end
function love.draw()
--CharacterRectangleWhite
love.graphics.setColor(255, 255, 255)
love.graphics.rectangle("fill", player.x, player.y, 50 , 50)
end