im new to lua but ive got a lot of the basics done. im wondering what is making my code just stay at a black screen and then reset i think it is the timer and if functions i have used but am not sure if someone could help that would be great. heres my code:
red = Color.new(255,0,0)
background = Image.load("b.png")
player = Image.load("a.png")
jewel = Image.load("c.png")
screenwidth = 480 - player:width()
screenheight = 272 - player:width()
Player = {}
Player[1] = {x=10,y=10}
Background = {}
Background[1] = {x=0,y=0}
Jewel = {}
Jewel[1] = {x=50,y=50}
Jewel[2] = {x=10,y=10}
Jewel[3] = {x=70,y=35}
Jewel[4] = {x=75,y=120}
Jewel[5] = {x=100,y=25}
counter = Timer.new()
counter:start()
while true do
pad = Controls.read()
screen:clear()
end
currentTime = counter:time()
screen:blit(Background[1].x, Background[1].y, background)
screen:blit(Player[1].x,Player[1].y,player)
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 2
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 2
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 2
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 2
end
if currentTime > 100 then
screen:blit(Jewel[1].x,Jewel[1].y,jewel)
if currentTime > 250 then
screen:blit(Jewel[2].x,Jewel[2].y,jewel)
end
if currentTime > 400 then
screen:blit(Jewel[3].x,Jewel[3].y,jewel)
end
if currentTime > 550 then
screen:blit(Jewel[4].x,Jewel[4].y,jewel)
end
if currentTime > 700 then
screen:blit(Jewel[5].x,Jewel[5].y,jewel)
end
if currentTime > 1500 then
counter:reset(0)
counter:start()
end
screen.flip()
screen.waitVblankStart()
end
red = Color.new(255,0,0)
background = Image.load("b.png")
player = Image.load("a.png")
jewel = Image.load("c.png")
screenwidth = 480 - player:width()
screenheight = 272 - player:width()
Player = {}
Player[1] = {x=10,y=10}
Background = {}
Background[1] = {x=0,y=0}
Jewel = {}
Jewel[1] = {x=50,y=50}
Jewel[2] = {x=10,y=10}
Jewel[3] = {x=70,y=35}
Jewel[4] = {x=75,y=120}
Jewel[5] = {x=100,y=25}
counter = Timer.new()
counter:start()
while true do
pad = Controls.read()
screen:clear()
currentTime = counter:time()
screen:blit(Background[1].x, Background[1].y, background)
screen:blit(Player[1].x,Player[1].y,player)
if pad:left() then if Player[1].x > 0 then
Player[1].x = Player[1].x - 2
end end
if pad:right() then if Player[1].x < screenwidth then
Player[1].x = Player[1].x + 2
end end
if pad:up() then if Player[1].y > 0 then
Player[1].y = Player[1].y - 2
end end
if pad:down() then if Player[1].y < screenheight then
Player[1].y = Player[1].y + 2
end end
if currentTime > 100 then
screen:blit(Jewel[1].x,Jewel[1].y,jewel)
end
if currentTime > 250 then
screen:blit(Jewel[2].x,Jewel[2].y,jewel)
end
if currentTime > 400 then
screen:blit(Jewel[3].x,Jewel[3].y,jewel)
end
if currentTime > 550 then
screen:blit(Jewel[4].x,Jewel[4].y,jewel)
end
if currentTime > 700 then
screen:blit(Jewel[5].x,Jewel[5].y,jewel)
end
if currentTime > 1500 then
counter:reset(0)
counter:start()
end
screen.flip()
screen.waitVblankStart()
end
Well yeah ofcourse there should be an "end", but not in the place where you put it. The loop should close after all the other stuff you want it to do, so at the end of the code, like be2003 posted.