Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- love.window.setTitle("Tic-Tac-Toe")
- local img = {}
- img.croix = love.graphics.newImage ("images/croix.png")
- img.rond = love.graphics.newImage ("images/ROND.png")
- --Visible : Vis. ~~~
- local Vis = {}
- --case utilisé true = oui / false = non
- local case = {}
- case.un = false
- case.deux = false
- case.trois = false
- case.quatre = false
- case.cinq = false
- case.six = false
- case.sept = false
- case.huit = false
- case.neuf = false
- -- tour/équipe
- local turn
- --cross
- Vis.crossUn = false
- Vis.crossDeux = false
- Vis.crossTrois = false
- Vis.crossQuatre = false
- Vis.crossCinq = false
- Vis.crossSix = false
- Vis.crossSept = false
- Vis.crossHuit = false
- Vis.crossNeuf = false
- --circle
- Vis.circleUn = false
- Vis.circleDeux = false
- Vis.circleTrois = false
- Vis.circleQuatre = false
- Vis.circleCinq = false
- Vis.circleSix = false
- Vis.circleSept = false
- Vis.circleNeuf = false
- distCoteDiv3 = 170.666666667
- -- Score cercle
- local VCircle
- -- Score croix
- local VCross
- function love.load()
- love.window.setMode(512,512)
- largeur = love.graphics.getWidth()
- hauteur = love.graphics.getHeight()
- turn = true -- rond
- end
- function love.update(dt)
- if love.keyboard.isDown ("kp7") and case.un == false and turn == true then
- Vis.circleUn = true
- case.un = true
- turn = false
- end
- if love.keyboard.isDown ("kp8") and case.deux == false and turn == true then
- Vis.circleDeux = true
- case.deux = true
- turn = false
- end
- if love.keyboard.isDown ("kp9") and case.trois == false and turn == true then
- Vis.circleTrois = true
- case.trois = true
- turn = false
- end
- if love.keyboard.isDown ("kp4") and case.quatre == false and turn == true then
- Vis.circleQuatre = true
- case.quatre = true
- turn = false
- end
- if love.keyboard.isDown ("kp5") and case.cinq == false and turn == true then
- Vis.circleCinq = true
- case.cinq = true
- turn = false
- end
- if love.keyboard.isDown ("kp6") and case.six == false and turn == true then
- Vis.circleSix = true
- case.six = true
- turn = false
- end
- if love.keyboard.isDown ("kp1") and case.sept == false and turn == true then
- Vis.circleSept = true
- case.sept = true
- turn = false
- end
- if love.keyboard.isDown ("kp2") and case.huit == false and turn == true then
- Vis.circleHuit = true
- case.huit = true
- turn = false
- end
- if love.keyboard.isDown ("kp3") and case.neuf == false and turn == true then
- Vis.circleNeuf = true
- case.neuf = true
- turn = false
- end
- -- cross
- if love.keyboard.isDown ("a") and case.un == false and turn == false then
- Vis.crossUn = true
- case.un = true
- turn = true
- end
- if love.keyboard.isDown ("z") and case.deux == false and turn == false then
- Vis.crossDeux = true
- case.deux = true
- turn = true
- end
- if love.keyboard.isDown ("e") and case.trois == false and turn == false then
- Vis.crossTrois = true
- case.trois = true
- turn = true
- end
- if love.keyboard.isDown ("q") and case.quatre == false and turn == false then
- Vis.crossQuatre = true
- case.quatre = true
- turn = true
- end
- if love.keyboard.isDown ("s") and case.cinq == false and turn == false then
- Vis.crossCinq = true
- case.cinq = true
- turn = true
- end
- if love.keyboard.isDown ("d") and case.six == false and turn == false then
- Vis.crossSix = true
- case.six = true
- turn = true
- end
- if love.keyboard.isDown ("w") and case.sept == false and turn == false then
- Vis.crossSept = true
- case.sept = true
- turn = true
- end
- if love.keyboard.isDown ("x") and case.huit == false and turn == false then
- Vis.crossHuit = true
- case.huit = true
- turn = true
- end
- if love.keyboard.isDown ("c") and case.neuf == false and turn == false then
- Vis.crossNeuf = true
- case.neuf = true
- turn = true
- end
- end
- function love.draw()
- -- tableau
- love.graphics.line(0,170.666666667,largeur,170.666666667)
- love.graphics.line(0,170.666666667*2,largeur,170.666666667*2)
- love.graphics.line(170.666666667,0,170.666666667, hauteur)
- love.graphics.line(170.666666667*2,0,170.666666667*2, hauteur)
- --circles
- if Vis.circleUn == true then
- love.graphics.draw (img.rond, 0,0)
- end
- if Vis.circleDeux == true then
- love.graphics.draw (img.rond, distCoteDiv3,0)
- end
- if Vis.circleTrois == true then
- love.graphics.draw (img.rond, distCoteDiv3*2,0)
- end
- if Vis.circleQuatre == true then
- love.graphics.draw (img.rond, 0,distCoteDiv3)
- end
- if Vis.circleCinq == true then
- love.graphics.draw (img.rond, distCoteDiv3,distCoteDiv3)
- end
- if Vis.circleSix == true then
- love.graphics.draw (img.rond, distCoteDiv3*2,distCoteDiv3)
- end
- if Vis.circleSept == true then
- love.graphics.draw (img.rond, 0,distCoteDiv3*2)
- end
- if Vis.circleHuit == true then
- love.graphics.draw (img.rond, distCoteDiv3,distCoteDiv3*2)
- end
- if Vis.circleNeuf == true then
- love.graphics.draw (img.rond, distCoteDiv3*2,distCoteDiv3*2)
- end
- -- cross
- if Vis.crossUn == true then
- love.graphics.draw (img.croix, 0,0)
- end
- if Vis.crossDeux == true then
- love.graphics.draw (img.croix, distCoteDiv3,0)
- end
- if Vis.crossTrois == true then
- love.graphics.draw (img.croix, distCoteDiv3*2,0)
- end
- if Vis.crossQuatre == true then
- love.graphics.draw (img.croix, 0,distCoteDiv3)
- end
- if Vis.crossCinq == true then
- love.graphics.draw (img.croix, distCoteDiv3,distCoteDiv3)
- end
- if Vis.crossSix == true then
- love.graphics.draw (img.croix, distCoteDiv3*2,distCoteDiv3)
- end
- if Vis.crossSept == true then
- love.graphics.draw (img.croix, 0,distCoteDiv3*2)
- end
- if Vis.crossHuit == true then
- love.graphics.draw (img.croix, distCoteDiv3,distCoteDiv3*2)
- end
- if Vis.crossNeuf == true then
- love.graphics.draw (img.croix, distCoteDiv3*2,distCoteDiv3*2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement