Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. status_saut = "off"
  2. compteur_saut = 0
  3. --
  4. lvl = 1
  5. partie = "a1"
  6. --
  7.  
  8. map = {}
  9. for i = 1,2 do
  10.     map[i] = Image.load("lvl"..i..".png")
  11. end
  12. --
  13. function deplacement()
  14.  
  15.     -- partie saut
  16.     if pad:cross() and status_saut == "off" then
  17.         status_saut = "monte"
  18.     end
  19.    
  20.     if status_saut == "monte" and compteur_saut <= 40 then
  21.         compteur_saut = compteur_saut + 1
  22.         y = y-1
  23.     end
  24.    
  25.     if compteur_saut > 40 then status_saut = "descend" end
  26.    
  27.     if status_saut == "descend"  and compteur_saut >= 0 then
  28.         compteur_saut = compteur_saut-1
  29.         y = y+1
  30.     end
  31.    
  32.     if compteur_saut == 0 then status_saut = "off" end
  33.     --partie deplacement
  34.    
  35.     if  (partie == "a" or partie == "c") and x < 500  then x = x+1 end
  36.     if partie == "b"  then x = x-1 end
  37.  
  38. end
  39. function collision_couleur(couleur,spawn)
  40.  
  41.     if map[lvl]:pixel(x+10,y) == couleur then
  42.         x = spawn
  43.     end
  44.  
  45. end
  46. --
  47. while true do
  48.     screen:clear()
  49.    
  50.     pad = Controls.read()
  51.    
  52.     deplacement()
  53.    
  54.     if partie == "a" or partie == "c" then collision_couleur(couleur1,0) end
  55.     if partie == "b" then collision_couleur(couleur2,480) end
  56.    
  57.    
  58.     if partie == "a1" then
  59.         y = 70
  60.         x = 0
  61.         partie = "a"
  62.     end
  63.    
  64.     if partie == "a" then
  65.         if x >= 480 then partie = "b1" end
  66.     end
  67.    
  68.     if partie == "b1" then
  69.         y = 160
  70.         x = 480
  71.         partie = "b"
  72.     end
  73.  
  74.    
  75.     if partie == "c1" then
  76.         y = 252
  77.         x = 0
  78.         partie = "c"
  79.     end
  80.     if partie == "c" then
  81.         if x == 480 then
  82.             partie = "a1"
  83.             x = 0
  84.             lvl = lvl+1
  85.         end
  86.     end
  87.    
  88.     if lvl == 1 then
  89.         couleur1 = Color.new(255,102,0)
  90.         couleur2 = Color.new(255,255,255)
  91.     end
  92.     if lvl == 2 then
  93.         couleur1 = Color.new(153,204,255)
  94.         couleur2 = Color.new(51,51,153)
  95.     end
  96.    
  97.     screen:blit(0,0,map[lvl])
  98.     carre = Image.createEmpty(20,20)
  99.     carre:clear(couleur1)
  100.     screen:blit(x,y,carre)
  101.  
  102.     screen.flip()
  103.     screen.waitVblankStart()
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement