Advertisement
Guest User

m,n,k-game

a guest
Dec 7th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.92 KB | None | 0 0
  1. love.window.setTitle("Tic-Tac-Toe")
  2.  
  3. local img = {}
  4. img.croix = love.graphics.newImage ("images/croix.png")
  5. img.rond = love.graphics.newImage ("images/ROND.png")
  6.  
  7. --Visible  : Vis. ~~~
  8. local Vis = {}
  9.  
  10. --case utilisé true = oui / false = non
  11.  
  12. local case = {}
  13. case.un = false
  14. case.deux = false
  15. case.trois = false
  16. case.quatre = false
  17. case.cinq = false
  18. case.six = false
  19. case.sept = false
  20. case.huit = false
  21. case.neuf = false
  22.  
  23. -- tour/équipe
  24. local turn
  25.  
  26. --cross
  27. Vis.crossUn = false
  28. Vis.crossDeux = false
  29. Vis.crossTrois = false
  30. Vis.crossQuatre = false
  31. Vis.crossCinq = false
  32. Vis.crossSix = false
  33. Vis.crossSept = false
  34. Vis.crossHuit = false
  35. Vis.crossNeuf = false
  36.  
  37. --circle
  38. Vis.circleUn = false
  39. Vis.circleDeux = false
  40. Vis.circleTrois = false
  41. Vis.circleQuatre = false
  42. Vis.circleCinq = false
  43. Vis.circleSix = false
  44. Vis.circleSept = false
  45. Vis.circleNeuf = false
  46.  
  47. distCoteDiv3 = 170.666666667
  48.  
  49. -- Score cercle
  50. local VCircle
  51. -- Score croix
  52. local VCross
  53.  
  54. function love.load()
  55.  
  56.   love.window.setMode(512,512)
  57.  
  58.   largeur = love.graphics.getWidth()
  59.   hauteur = love.graphics.getHeight()
  60.  
  61.   turn = true -- rond
  62.  
  63. end
  64.  
  65. function love.update(dt)
  66.  
  67.   if love.keyboard.isDown ("kp7") and case.un == false and turn == true then
  68.     Vis.circleUn = true
  69.     case.un = true
  70.     turn = false
  71.   end
  72.   if love.keyboard.isDown ("kp8") and case.deux == false and turn == true then
  73.     Vis.circleDeux = true
  74.     case.deux = true
  75.     turn = false
  76.   end
  77.   if love.keyboard.isDown ("kp9") and case.trois == false and turn == true then
  78.     Vis.circleTrois = true
  79.     case.trois = true
  80.     turn = false
  81.   end
  82.   if love.keyboard.isDown ("kp4") and case.quatre == false and turn == true then
  83.     Vis.circleQuatre = true
  84.     case.quatre = true
  85.     turn = false
  86.   end
  87.   if love.keyboard.isDown ("kp5") and case.cinq == false and turn == true then
  88.     Vis.circleCinq = true
  89.     case.cinq = true
  90.     turn = false
  91.   end
  92.   if love.keyboard.isDown ("kp6") and case.six == false and turn == true then
  93.     Vis.circleSix = true
  94.     case.six = true
  95.     turn = false
  96.   end
  97.   if love.keyboard.isDown ("kp1") and case.sept == false and turn == true then
  98.     Vis.circleSept = true
  99.     case.sept = true
  100.     turn = false
  101.   end
  102.   if love.keyboard.isDown ("kp2") and case.huit == false and turn == true then
  103.     Vis.circleHuit = true
  104.     case.huit = true
  105.     turn = false
  106.   end
  107.   if love.keyboard.isDown ("kp3") and case.neuf == false and turn == true then
  108.     Vis.circleNeuf = true
  109.     case.neuf = true
  110.     turn = false
  111.   end
  112.  
  113. -- cross
  114.   if love.keyboard.isDown ("a") and case.un == false and turn == false then
  115.     Vis.crossUn = true
  116.     case.un = true
  117.     turn = true
  118.   end
  119.   if love.keyboard.isDown ("z") and case.deux == false and turn == false then
  120.     Vis.crossDeux = true
  121.     case.deux = true
  122.     turn = true
  123.   end
  124.   if love.keyboard.isDown ("e") and case.trois == false and turn == false then
  125.     Vis.crossTrois = true
  126.     case.trois = true
  127.     turn = true
  128.   end
  129.   if love.keyboard.isDown ("q")  and case.quatre == false and turn == false then
  130.     Vis.crossQuatre = true
  131.     case.quatre = true
  132.     turn = true
  133.   end
  134.   if love.keyboard.isDown ("s") and case.cinq == false and turn == false then
  135.     Vis.crossCinq = true
  136.     case.cinq = true
  137.     turn = true
  138.   end
  139.   if love.keyboard.isDown ("d") and case.six == false and turn == false then
  140.     Vis.crossSix = true
  141.     case.six = true
  142.     turn = true
  143.   end
  144.   if love.keyboard.isDown ("w") and case.sept == false and turn == false then  
  145.     Vis.crossSept = true
  146.     case.sept = true
  147.     turn = true
  148.   end
  149.   if love.keyboard.isDown ("x") and case.huit == false and turn == false then
  150.     Vis.crossHuit = true
  151.     case.huit = true
  152.     turn = true
  153.   end
  154.   if love.keyboard.isDown ("c") and case.neuf == false and turn == false then
  155.     Vis.crossNeuf = true
  156.     case.neuf = true
  157.     turn = true
  158.   end
  159.  
  160.  
  161. end
  162.  
  163. function love.draw()
  164.  
  165.   -- tableau
  166.   love.graphics.line(0,170.666666667,largeur,170.666666667)
  167.   love.graphics.line(0,170.666666667*2,largeur,170.666666667*2)
  168.   love.graphics.line(170.666666667,0,170.666666667, hauteur)
  169.   love.graphics.line(170.666666667*2,0,170.666666667*2, hauteur)
  170.  
  171. --circles
  172.   if Vis.circleUn == true  then
  173.     love.graphics.draw (img.rond, 0,0)
  174.   end
  175.   if Vis.circleDeux == true then
  176.     love.graphics.draw (img.rond, distCoteDiv3,0)
  177.   end
  178.   if Vis.circleTrois == true then
  179.     love.graphics.draw (img.rond, distCoteDiv3*2,0)
  180.   end
  181.   if Vis.circleQuatre == true then
  182.     love.graphics.draw (img.rond, 0,distCoteDiv3)
  183.   end    
  184.   if Vis.circleCinq == true then
  185.     love.graphics.draw (img.rond, distCoteDiv3,distCoteDiv3)
  186.   end
  187.   if Vis.circleSix == true then
  188.     love.graphics.draw (img.rond, distCoteDiv3*2,distCoteDiv3)
  189.   end
  190.   if Vis.circleSept == true then
  191.     love.graphics.draw (img.rond, 0,distCoteDiv3*2)
  192.   end
  193.   if Vis.circleHuit == true then
  194.     love.graphics.draw (img.rond, distCoteDiv3,distCoteDiv3*2)
  195.   end
  196.   if Vis.circleNeuf == true then
  197.     love.graphics.draw (img.rond, distCoteDiv3*2,distCoteDiv3*2)
  198.   end
  199.  
  200. -- cross
  201.   if Vis.crossUn == true  then
  202.     love.graphics.draw (img.croix, 0,0)
  203.   end
  204.   if Vis.crossDeux == true then
  205.     love.graphics.draw (img.croix, distCoteDiv3,0)
  206.   end
  207.   if Vis.crossTrois == true then
  208.     love.graphics.draw (img.croix, distCoteDiv3*2,0)
  209.   end
  210.   if Vis.crossQuatre == true then
  211.     love.graphics.draw (img.croix, 0,distCoteDiv3)
  212.   end    
  213.   if Vis.crossCinq == true then
  214.     love.graphics.draw (img.croix, distCoteDiv3,distCoteDiv3)
  215.   end
  216.   if Vis.crossSix == true then
  217.     love.graphics.draw (img.croix, distCoteDiv3*2,distCoteDiv3)
  218.   end
  219.   if Vis.crossSept == true then
  220.     love.graphics.draw (img.croix, 0,distCoteDiv3*2)
  221.   end
  222.   if Vis.crossHuit == true then
  223.     love.graphics.draw (img.croix, distCoteDiv3,distCoteDiv3*2)
  224.   end
  225.   if Vis.crossNeuf == true then
  226.     love.graphics.draw (img.croix, distCoteDiv3*2,distCoteDiv3*2)
  227.   end
  228.  
  229. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement