sa marche pas mais merci a vous deux!
code:
snakestanddroite = Image.load("snake stand.png")
courirdroite = Image.load("courir droite.png")
courirdroite2= Image.load("courir droite 2.png")
courirdroite3= Image.load("courir droite 3.png")
courirdroite4= Image.load("courir droite 4.png")
courirdroite5= Image.load("courir droite 5.png")
courirdroite6= Image.load("courir droite 6.png")
courirdroite7= Image.load("courir droite 7.png")
courirdroite8= Image.load("courir droite 8.png")
snakestandbas = Image.load("snakestandbas.png")
courirbas= Image.load("courirbas.png")
courirbas2= Image.load("courirbas2.png")
courirbas3= Image.load("courirbas3.png")
courirbas4= Image.load("courirbas4.png")
courirbas5= Image.load("courirbas5.png")
courirbas6= Image.load("courirbas6.png")
courirbas7= Image.load("courirbas7.png")
courirbas8= Image.load("courirbas8.png")
snakestandhaut = Image.load("snakestandhaut.png")
courirhaut= Image.load("courirhaut.png")
courirhaut2= Image.load("courirhaut2.png")
courirhaut3= Image.load("courirhaut3.png")
courirhaut4= Image.load("courirhaut4.png")
courirhaut5= Image.load("courirhaut5.png")
courirhaut6= Image.load("courirhaut6.png")
courirhaut7= Image.load("courirhaut7.png")
courirhaut8= Image.load("courirhaut8.png")
snakestandgauche = Image.load("snakestandgauche.png")
courirgauche= Image.load("courirgauche.png")
courirgauche2= Image.load("courirgauche2.png")
courirgauche3= Image.load("courirgauche3.png")
courirgauche4= Image.load("courirgauche4.png")
courirgauche5= Image.load("courirgauche5.png")
courirgauche6= Image.load("courirgauche6.png")
courirgauche7= Image.load("courirgauche7.png")
courirgauche8= Image.load("courirgauche8.png")
joueur = {
x = 0; -- c'est la position en X de départ
y = 188; --c'est la position en Y de départ
marche = 0;
marchegauche=0;
marchehaut=0;
marchebas=0;
img = snakestanddroite; --c'est l'image de départ du joueur
}
System.usbDiskModeActivate()
while true do
screen:clear() -- on nettoie l'écran
pad = Controls.read() -- on déclare la pression sur les touches
if pad:right() then
joueur.x = joueur.x + 2.25
joueur.marche = joueur.marche + 1.1333
end
if pad:right() == false then
joueur.marche=0
joueur.img = snakestanddroite
end
if joueur.marche>0 and joueur.marche<=5 then joueur.img = courirdroite end
if joueur.marche>=5 and joueur.marche<=10 then joueur.img = courirdroite2 end
if joueur.marche>=10 and joueur.marche<=15 then joueur.img = courirdroite3 end
if joueur.marche>=15 and joueur.marche<=20 then joueur.img = courirdroite4 end
if joueur.marche>=20 and joueur.marche<=25 then joueur.img = courirdroite5 end
if joueur.marche>=25 and joueur.marche<=30 then joueur.img = courirdroite6 end
if joueur.marche>=30 and joueur.marche<=35 then joueur.img = courirdroite7 end
if joueur.marche>=35 and joueur.marche<=40 then joueur.img = courirdroite8 end
if joueur.marche>40 then joueur.marche= 0 end
if pad:left() then
joueur.x = joueur.x - 2.25
joueur.marchegauche = joueur.marchegauche + 1.3333
end
if pad:left() == false then
joueur.marchegauche=0
joueur.img = snakestandgauche
end
if joueur.marchegauche>0 and joueur.marchegauche<=5 then joueur.img = courirgauche end
if joueur.marchegauche>=5 and joueur.marchegauche<=10 then joueur.img = courirgauche2 end
if joueur.marchegauche>=10 and joueur.marchegauche<=15 then joueur.img = courirgauche3 end
if joueur.marchegauche>=15 and joueur.marchegauche<=20 then joueur.img = courirgauche4 end
if joueur.marchegauche>=20 and joueur.marchegauche<=25 then joueur.img = courirgauche5 end
if joueur.marchegauche>=25 and joueur.marchegauche<=30 then joueur.img = courirgauche6 end
if joueur.marchegauche>=30 and joueur.marchegauche<=35 then joueur.img = courirgauche7 end
if joueur.marchegauche>=35 and joueur.marchegauche<=40 then joueur.img = courirgauche8 end
if joueur.marchegauche>40 then joueur.marchegauche= 0 end
if pad:up() then
joueur.y = joueur.y - 2.25
joueur.marchehaut = joueur.marchehaut + 1.3333
end
if pad:up() == false then
joueur.marchehaut=0
joueur.img = snakestandhaut
end
if joueur.marchehaut>0 and joueur.marchehaut<=5 then joueur.img = courirhaut end
if joueur.marchehaut>=5 and joueur.marchehaut<=10 then joueur.img = courirhaut2 end
if joueur.marchehaut>=10 and joueur.marchehaut<=15 then joueur.img = courirhaut3 end
if joueur.marchehaut>=15 and joueur.marchehaut<=20 then joueur.img = courirhaut4 end
if joueur.marchehaut>=20 and joueur.marchehaut<=25 then joueur.img = courirhaut5 end
if joueur.marchehaut>=25 and joueur.marchehaut<=30 then joueur.img = courirhaut6 end
if joueur.marchehaut>=30 and joueur.marchehaut<=35 then joueur.img = courirhaut7 end
if joueur.marchehaut>=35 and joueur.marchehaut<=40 then joueur.img = courirhaut8 end
if joueur.marchehaut>40 then joueur.marchehaut= 0 end
if pad:down() then
joueur.y = joueur.y + 2.25
joueur.marchebas = joueur.marchebas + 1.3333
end
if pad:down() == false then
joueur.marchebas=0
joueur.img = snakestandbas
end
if joueur.marchebas>0 and joueur.marchebas<=5 then joueur.img = courirbas end
if joueur.marchebas>=5 and joueur.marchebas<=10 then joueur.img = courirbas2 end
if joueur.marchebas>=10 and joueur.marchebas<=15 then joueur.img = courirbas3 end
if joueur.marchebas>=15 and joueur.marchebas<=20 then joueur.img = courirbas4 end
if joueur.marchebas>=20 and joueur.marchebas<=25 then joueur.img = courirbas5 end
if joueur.marchebas>=25 and joueur.marchebas<=30 then joueur.img = courirbas6 end
if joueur.marchebas>=30 and joueur.marchebas<=35 then joueur.img = courirbas7 end
if joueur.marchebas>=35 and joueur.marchebas<=40 then joueur.img = courirbas8 end
if joueur.marchebas>40 then joueur.marchebas= 0 end
screen:blit(joueur.x, joueur.y,joueur.img)
screen.waitVblankStart()
screen.flip()
end
voila je vous ai donné mon code complet pour l'animation en fait je voudrais que mon perso se mette en snakestanddroite si la derniere touche pressée est droite qu'il se mette en snakestandhaut si la derniere touche pressé est haut...
le probleme c'est que quand je lance le jeu sur ma psp le personnage est tout le temps en snakestandbas ou en courirbas courirbas2...
je suis sur que c'est du au fait que quand je dis,par ex,:
if pad:right() == false then
joueur.marche=0
joueur.img = snakestanddroite
end
je dis que quand la touche droite n'est pas enfoncéé alors...
mais si la derniere touche appuyée est haut ,par ex, ma condition est quand meme vrai puisque je n'appuie pas sur droite c'est pour sa que je voudrais qqch qui vérifie la derniere touche appuyée.
voila j'espere avoir été clair
oh et dernier point je disais plus haut que quand je lancais le jeu la direction affiché était bas en fait c'est parceque c'est la derniere condition que j'ai rentrée et que le programme se dit que je n'appuie pas sur bas donc il charge la dir bas (pas clair ce dernier point mais ce n'est pas grave si vous ne comprenez pas).