Code: Select all
--Created by dragonxtamer596
--On the 10/25/12
Room_width = 480
Room_height = 272
player1x =240
player1y =136
---Load Sprites ---
background =Image.load ("images/Background.PNG")
player1=Image.load("images/Player1.PNG")
------functions
function checkcontrols()
pad = Controls.read()
if pad:start() then
return false
end
if pad:right() then
player1x = player1x +2
end
if pad:left() then
player1x = player1x -2
end
if pad:up() then
player1y = player1y -2
end
if pad:down() then
player1y = player1y +2
end
end
function drawall()
screen:blit (0,0,background)
screen:blit(player1x,player1y,player1)
screen.waitVblankStart()
screen.flip()
end
-- MAIN LOOP
while true do
end
Here is your code that I revised.
Code: Select all
CODE: SELECT ALL
--Created by dragonxtamer596
--On the 10/25/12
Room_width = 480
Room_height = 272
player1x =240
player1y =136
---Load Sprites ---
background =Image.load ("images/Background.PNG")
player1=Image.load("images/Player1.PNG")
------functions
function checkcontrols()
pad = Controls.read()
if pad:start() then
break
end
if pad:right() then
player1x = player1x +2
end
if pad:left() then
player1x = player1x -2
end
if pad:up() then
player1y = player1y -2
end
if pad:down() then
player1y = player1y +2
end
end
function drawall()
screen:blit (0,0,background)
screen:blit(player1x,player1y,player1)
screen.waitVblankStart()
screen.flip()
end
-- MAIN LOOP
while true do
checkcontrols()
drawall()
end
You can see that I added your functions to the while true do loop.
The only time you use "function" is when you are creating one, you do not use it when running it.
You are doing very good, all you had to do was place your functions in the loop.