KINGx - Das inoffizielle PlayStation Forum & News Portal

Normale Version: Lua frage
Sie sehen gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
So leute ..Big Grin
ICh geh euch bestimmt mit meinen Lua fragen auf die NervenBig Grin
aber ich komm manchmal einfach nicht weiter Sad
Hierist ein Tut wie man ein Viereck programmiert was man bewegen kann.
Aber ich möchte statt den Viereck ein Bild haben.
Das is doch bestimmt möglich
Hier ist mein Code:

Code:
bild = Image.load("spielfeld.png")
ball = Image.load("ball.png")

x = 100
y = 100

while true do --Mainloop

taste = Controls.read()

screen:blit(0,0,bild,false)

Und weiter weiß ich nicht das ein Bild dann erscheint was ich dann bewegen kann.
(Mit den tasten kenne ich mich aus, also zum bewegen des vierecks etc.) Ich will nur wissen wie man dann das Bild einfügt statt den viereck

Das hab ich ja auch schon ausprobiert.
Das bild kommt zwar aber ich kann dann den Ball nicht bewegenSad
ja
aber ich kann ihn dann nicht bewegen
(die befehle fürs bewegen ab ich angeben ,nur ich hab sie hier nicht gepostet.)
So hier ist er
und ich möchte statt den Viereck (befehl :
screen:fillRect(x,y,25,25,blue) )
mein bild was sich bewegt und was ich bewegen kann
Achja ich hab an den Seite ( links und Rechts ) eine Kollision programmiert wisst ihr noch zufällig wie ich die auch nach oben bekomme?
hier der code

Code:
blue = Color.new(0,0,255)
bild = Image.load("spielfeld.png")


x = 100
y = 100
modus = 0



while true do --Mainloop

if modus == 0 then
x = x+1
end

if x>480 then
modus = 1
end

if modus == 1 then
x = x-1
end

if x <0 then
modus = 0
end


taste = Controls.read()


if taste:left() then
x=x-1
end

if taste:right() then
x=x+1
end

if taste:up() then
y=y-1
end

if taste:down() then
y=y+1
end


screen:blit(0,0,bild,false)
screen:fillRect(x,y,25,25,blue)


screen.flip()
screen.waitVblankStart()
end

Sorry für den doppel post aber kann mir keiner helfen ? Sad
Ich denk mal Martuzki hat Ahnung davon, frag ihn doch mal via PN.
Werd ich machen Wink
Ok dein fehler ist der image.=Bild (0,255,0)
image.=beweglich curser.
Echt mist ich dachte der gehtSad
Sorry Leute Wink
das wa noch mein alter codeSadalso mit den fehlern)
Das hier ist der gleiche Wink
Nur halt das die y achse jetz auch kollision hat ( unsichbare mauer) ^^

Jetz fehlt mir halt nur noch das ich ein bild für das viereck einsetzen kann Wink


Code:
blue = Color.new(0,0,255)
bild = Image.load("spielfeld.png")

x = 100
y = 100
modus = 0

while true do --Mainloop

if modus == 0 then
x = x+1
end

if x>480 then
modus = 1
end

if modus == 1 then
x = x-1
end

if x <0 then
modus = 0
end

if modus == 2 then
y = y+1
end

if y>272 then
modus = 3
end

if modus == 3 then
y = y-1
end

if y <0 then
modus = 2
end

taste = Controls.read()

if taste:left() then
x=x-1
end

if taste:right() then
x=x+1
end

if taste:up() then
y=y-1
end

if taste:down() then
y=y+1
end

screen:blit(0,0,bild,false)
screen:fillRect(x,y,25,25,blue)

screen.flip()
screen.waitVblankStart()
end

ok danke Wink
Kein Problem habs jetz gelöst Smile
Trotzdem danke Wink

Hier ist dann nochmal der codeWink
Achja ich hab jetz nicht mehr das Steuerkreuz verwendet sondern das Analog

Hier der Code der ihn wissen möchte Wink

Code:
blue = Color.new(0,0,255)
bild = Image.load("spielfeld.png")
ball = Image.load("ball.png")

ball_x = 100
ball_y = 100

x = 100
y = 100
modus = 0



while true do --Mainloop

if modus == 0 then
x = x+1
end

if x>480 then
modus = 1
end

if modus == 1 then
x = x-1
end

if x <0 then
modus = 0
end

if modus == 2 then
y = y+1
end

if y>272 then
modus = 3
end

if modus == 3 then
y = y-1
end

if y <0 then
modus = 2
end

taste = Controls.read()

dx = taste:analogX()
dy = taste:analogY()

if dx > 30 then
ball_x = ball_x + (math.abs(taste:analogX())/64)
end

if dx < -30 then
ball_x = ball_x - (math.abs(taste:analogX())/64)
end

if dy > 30 then
ball_y = ball_y + (math.abs(taste:analogY())/64)
end
if dy < -30 then
ball_y = ball_y - (math.abs(taste:analogY())/64)
end --DPad-Code ENDE

screen:blit(0,0,bild,false)
screen:blit(ball_x,ball_y,ball,true)

screen.flip()
screen.waitVblankStart()
end

Klar gerne Wink
Seiten: 1 2
Referenz-URLs