Log in

View Full Version : whats wrong with this code?



shiftybill
November 28th, 2005, 05:33
hiya all im new to this Lua thing and cant get my 1st program running

help me or i may give up :(
pls

System.usbDiskModeActivate()
GameHeart = true
screenWidth = 480
screenHeight = 272
Blue = Color.new(0,0,255)
Background = Image.load("Background.png")
function Game()
screen:blit(0,0, Background, false)
screen:print(screenWidth/2, screenHeight - 20, "Bouncing Demo!!!", Blue)
end
while GameHeart do
screen:flip()
if Controls.read():start() then
break
end
end

cancan
November 28th, 2005, 06:55
If you defined a function you have to call it to run it.
You don't have any Game() in your script.
It is also good to call the screen:waitVblankStart() before the screen:flip()
Also or you call the screen:blit function with 3 parameters (0,0, Background) or with all of them (0, 0, Background, Background:width(), Background:height(), false).

Instead of the break in the
if Controls.read():start() then
break
end
It would be nicer to set the GameHeart to false.

I'm also not a Lua master so....