26.02.2011, 19:49
Leute hier ist mein script,könnt ihr mir sagen was falsch ist???
Es wird nur das Bild angezeigt:
standright = Image.load("s.png")
Wie mach ich das das auch die anderen funktionieren???
Außerdem kommt wenn ich eine Richtungstaste drücke dieser Fehler :
error: spiel.lua:62: attempt to compare number with table
Hier mein Sript:
Es wird nur das Bild angezeigt:
standright = Image.load("s.png")
Wie mach ich das das auch die anderen funktionieren???
Außerdem kommt wenn ich eine Richtungstaste drücke dieser Fehler :
error: spiel.lua:62: attempt to compare number with table
Hier mein Sript:
Code:
left = Image.load("i1.png")
left2 = Image.load("i2.png")
left3 = Image.load("i3.png")
left4 = Image.load("i4.png")
right = Image.load("d1.png")
right2 = Image.load("d2.png")
right3 = Image.load("d3.png")
right4 = Image.load("d4.png")
standright = Image.load("s.png")
player = {}
player.x = 20
player.y = 200
player.img = standright
function moveleft()
if Timer>= 21 or Timer<=0 then
Timer = 0
end
if Timer==5 then
screen:blit(20,200,left)
end
if Timer==10 then
screen:blit(20,200,left2)
end
if Timer==15 then
screen:blit(20,200,left3)
end
if Timer==20 then
screen:blit(20,200,left4)
end
end
function moveright()
if Timer>= 21 or Timer<=0 then
Timer = 0
end
if Timer==5 then
screen:blit(20,200,right)
end
if Timer==10 then
screen:blit(20,200,right2)
end
if Timer==15 then
screen:blit(20,200,right3)
end
if Timer==20 then
screen:blit(20,200,right4)
end
end
while true do ----MAIN LOOP----
oldx = player.x
oldy = player.y
screen:clear()
pad = Controls.read()
if pad:left() and player.x > 0 then
moveleft()
player.x = player.x - 4
end
if pad:right() and player.x < 480 then
moveright()
player.x = player.x + 4
end
screen:blit(player.x, player.y, player.img)
screen.flip()
oldpad = pad
screen.waitVblankStart()
end
EDIT:
mit diesem Code kann ich mich zwar nach rechts und links bewegen,doch es wird nur standright = Image.load("s.png") angezeigt....
Code:
left = Image.load("i1.png")
left2 = Image.load("i2.png")
left3 = Image.load("i3.png")
left4 = Image.load("i4.png")
right = Image.load("d1.png")
right2 = Image.load("d2.png")
right3 = Image.load("d3.png")
right4 = Image.load("d4.png")
standright = Image.load("s.png")
player = {}
player.x = 20
player.y = 200
player.img = standright
function moveleft()
Timer = 1
if Timer>= 21 or Timer<=0 then
Timer = 0
end
if Timer == 5 then
player.img = left
screen:blit(20,200,left)
end
if Timer == 10 then
player.img = left2
screen:blit(20,200,left2)
end
if Timer == 15 then
player.img = left3
screen:blit(20,200,left3)
end
if Timer == 20 then
player.img = left4
screen:blit(20,200,left4)
end
end
function moveright()
Timer = 1
if Timer>= 21 or Timer<=0 then
Timer = 0
end
if Timer == 5 then
player.img = right
screen:blit(20,200,right)
end
if Timer == 10 then
player.img = right2
screen:blit(20,200,right2)
end
if Timer == 15 then
player.img = right3
screen:blit(20,200,right3)
end
if Timer == 20 then
player.img = right4
screen:blit(20,200,right4)
end
end
while true do ----MAIN LOOP----
oldx = player.x
oldy = player.y
screen:clear()
pad = Controls.read()
if pad:left() and player.x > 0 then
moveleft()
player.x = player.x - 4
end
if pad:right() and player.x < 480 then
moveright()
player.x = player.x + 4
end
screen:blit(player.x, player.y, player.img)
screen.flip()
oldpad = pad
screen.waitVblankStart()
end