Hi, yesterday I started developing in LovePotion for the 3DS. In about 20 hours I've already got the basics down... except for a few things. This glitch is one of them.
The problem is this:
I managed to make a top down game with a moving character and a scrolling background. When the dpad is pressed, the character moves up, and the BG moves down. This gives a scrolling BG effect. However, sometimes, my character moves past the screen, so you can't see him anymore. How do I fix this?
Source code:
If it's really necessary I could provide a short video of it pretty soon, just tell me.
Thanks for reading this!
The problem is this:
I managed to make a top down game with a moving character and a scrolling background. When the dpad is pressed, the character moves up, and the BG moves down. This gives a scrolling BG effect. However, sometimes, my character moves past the screen, so you can't see him anymore. How do I fix this?
Source code:
function love.load()
background = love.graphics.newImage('background.png')
youngBoy = love.graphics.newImage('youngboy.png')
youngboyx = 0
youngboyy = 0
backgroundx = 0
backgroundy = 0
end
function love.draw()
love.graphics.draw(background, backgroundx, backgroundy)
love.graphics.draw(youngBoy, youngboyx, youngboyy)
end
function love.update(dt)
if love.keyboard.isDown("right") then
youngboyx = youngboyx + 1.1
end
if love.keyboard.isDown("left") then
youngboyx = youngboyx - 1.1
end
if love.keyboard.isDown("up") then
youngboyy = youngboyy -1.1
end
if love.keyboard.isDown("down") then
youngboyy = youngboyy + 1.1
end
if love.keyboard.isDown("down") then
backgroundy = backgroundy - 3.1
end
if love.keyboard.isDown("up") then
backgroundy = backgroundy + 3.1
end
function love.keypressed(key)
if key == 'start' then
love.event.quit()
end
end
background = love.graphics.newImage('background.png')
youngBoy = love.graphics.newImage('youngboy.png')
youngboyx = 0
youngboyy = 0
backgroundx = 0
backgroundy = 0
end
function love.draw()
love.graphics.draw(background, backgroundx, backgroundy)
love.graphics.draw(youngBoy, youngboyx, youngboyy)
end
function love.update(dt)
if love.keyboard.isDown("right") then
youngboyx = youngboyx + 1.1
end
if love.keyboard.isDown("left") then
youngboyx = youngboyx - 1.1
end
if love.keyboard.isDown("up") then
youngboyy = youngboyy -1.1
end
if love.keyboard.isDown("down") then
youngboyy = youngboyy + 1.1
end
if love.keyboard.isDown("down") then
backgroundy = backgroundy - 3.1
end
if love.keyboard.isDown("up") then
backgroundy = backgroundy + 3.1
end
function love.keypressed(key)
if key == 'start' then
love.event.quit()
end
end
If it's really necessary I could provide a short video of it pretty soon, just tell me.
Thanks for reading this!