Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- status_saut = "off"
- compteur_saut = 0
- --
- lvl = 1
- partie = "a1"
- --
- map = {}
- for i = 1,2 do
- map[i] = Image.load("lvl"..i..".png")
- end
- --
- function deplacement()
- -- partie saut
- if pad:cross() and status_saut == "off" then
- status_saut = "monte"
- end
- if status_saut == "monte" and compteur_saut <= 40 then
- compteur_saut = compteur_saut + 1
- y = y-1
- end
- if compteur_saut > 40 then status_saut = "descend" end
- if status_saut == "descend" and compteur_saut >= 0 then
- compteur_saut = compteur_saut-1
- y = y+1
- end
- if compteur_saut == 0 then status_saut = "off" end
- --partie deplacement
- if (partie == "a" or partie == "c") and x < 500 then x = x+1 end
- if partie == "b" then x = x-1 end
- end
- function collision_couleur(couleur,spawn)
- if map[lvl]:pixel(x+10,y) == couleur then
- x = spawn
- end
- end
- --
- while true do
- screen:clear()
- pad = Controls.read()
- deplacement()
- if partie == "a" or partie == "c" then collision_couleur(couleur1,0) end
- if partie == "b" then collision_couleur(couleur2,480) end
- if partie == "a1" then
- y = 70
- x = 0
- partie = "a"
- end
- if partie == "a" then
- if x >= 480 then partie = "b1" end
- end
- if partie == "b1" then
- y = 160
- x = 480
- partie = "b"
- end
- if partie == "c1" then
- y = 252
- x = 0
- partie = "c"
- end
- if partie == "c" then
- if x == 480 then
- partie = "a1"
- x = 0
- lvl = lvl+1
- end
- end
- if lvl == 1 then
- couleur1 = Color.new(255,102,0)
- couleur2 = Color.new(255,255,255)
- end
- if lvl == 2 then
- couleur1 = Color.new(153,204,255)
- couleur2 = Color.new(51,51,153)
- end
- screen:blit(0,0,map[lvl])
- carre = Image.createEmpty(20,20)
- carre:clear(couleur1)
- screen:blit(x,y,carre)
- screen.flip()
- screen.waitVblankStart()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement