PDA

View Full Version : Lua Help



splodger15
October 29th, 2006, 16:30
Here is my code what i would like is cars that you will have to dodge out the way but i dont know what the bit of code would be can someone help please.


----------------------------------------------------------------

-- Created by splodger15

Room_width = 480
Room_height = 272
player1x = 15
player1y = 136
background =Image.load ("images/road.jpg")
player1=Image.load("images/car.JPG")

------functions
function checkcontrols()
pad = Controls.read()
if pad:start() then
exit = true
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
if exit == true then
break
end
checkcontrols()
drawall()

end

yaustar
October 29th, 2006, 16:43
I would like to see your try at the code before 'correcting' the code otherwise we be just doing it for you.

Your first task would be to get cars moving on thier own from right to left or whatever direction.

splodger15
October 29th, 2006, 17:03
I only know very basic Lua

yaustar
October 29th, 2006, 17:18
Getting a car to move from right to left doesn't take any more knowledge then what you already know from the code you posted.

Cloudhunter
October 29th, 2006, 17:35
One word. Timer, random. That should be all you need.

Cloudy

splodger15
October 29th, 2006, 18:52
I am not sure what the code would be

yaustar
October 29th, 2006, 19:16
Lets put it this way, if you wanted to move the player left every frame without the player needing to press the D-pad, what would you do?