Programme psp LUA

Fermé
115 Messages postés 7 Date d'inscription vendredi 18 avril 2008 Statut Membre Dernière intervention 2 avril 2009 - 21 févr. 2009 à 17:42
maxi30 Messages postés 22 Date d'inscription vendredi 27 mars 2009 Statut Membre Dernière intervention 12 juillet 2009 - 12 juil. 2009 à 20:01
Bonjour
Je viens de me lancer dans un jeux en lua.
Un problème ce pose .
Je souhaiterais faire sauter mon personnage alors j'ai regarder comment faire mais je n'arrive qu'a faire sauter un carré .alors je voudrais savoir comment faut-il faire pour remplacer ce carré de couleur par une image
voici le code que je met
Code:
vert =Color.new(0,255,0)
blanc = Color.new(255,255,255)

player1 = Image.createEmpty(32,32)
player1:clear(blanc)

sol = Image.createEmpty(480,10)
sol:clear(vert)

player = {}
player.gravity = 230
player.y = 230
player.x = 50
player.jumpspeed = 10
player.jumpstate = "sol"

-----------------------
---Boucle principale---
-----------------------

while true do
pad = Controls.read()
screen:clear()

if pad:left() then
player.x = player.x - 2
end
if pad:right() then
player.x = player.x + 2
end

if pad:cross() and player.jumpstate == "sol" then player.jumpstate = "en saut" end

if player.jumpstate == "en saut" then
player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end

if player.gravity < 0 then
player.jumpstate = "retombe"
end

if player.gravity < 230 and player.jumpstate == "retombe" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end

if player.gravity == 230 then
player.jumpspeed = 10
player.jumpstate = "sol"
end

if player.gravity > 230 then player.gravity = 230 end

player.y = player.gravity

screen:blit(player.x,player.y,player1)
screen:blit(0,262,sol)

screen:print(10,10,"X: "..player.x.." Y: "..player.y,vert)
screen:print(10,20,"Jumpstate: "..player.jumpstate,vert)

screen.waitVblankStart()
screen.flip()
end


Merci

1 réponse

maxi30 Messages postés 22 Date d'inscription vendredi 27 mars 2009 Statut Membre Dernière intervention 12 juillet 2009 1
12 juil. 2009 à 20:01
Bon je c'est que sa date mais je vais te résoudre ton problème ^^

vert =Color.new(0,255,0)
blanc = Color.new(255,255,255)

player1 = Image.load("lenomdetonimage.png")-- note:ton image doit être au format .png sinon il y a un autre format mais je ne m'en souvient plus ^^

sol = Image.createEmpty(480,10)
sol:clear(vert)

player = {}
player.gravity = 230- la hauteur du perso
player.y = 230- la hauteur du perso
player.x = 50
player.jumpspeed = 10
player.jumpstate = "sol"

-----------------------
---Boucle principale---
-----------------------

while true do
pad = Controls.read()
screen:clear()

if pad:left() then
player.x = player.x - 2
end
if pad:right() then
player.x = player.x + 2
end

if pad:cross() and player.jumpstate == "sol" then player.jumpstate = "en saut" end

if player.jumpstate == "en saut" then
player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end

if player.gravity < 0 then
player.jumpstate = "retombe"
end

if player.gravity < 230 and player.jumpstate == "retombe" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end

if player.gravity == 230 then
player.jumpspeed = 10
player.jumpstate = "sol"
end

if player.gravity > 230 then player.gravity = 230 end

player.y = player.gravity

screen:blit(player.x,player.y,player1)
screen:blit(0,262,sol)

screen:print(10,10,"X: "..player.x.." Y: "..player.y,vert)
screen:print(10,20,"Jumpstate: "..player.jumpstate,vert)

screen.waitVblankStart()
screen.flip()
end
1