aboutsummaryrefslogtreecommitdiffstats
path: root/main.lua
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2014-04-03 19:10:20 +0200
committerpiernov <piernov@piernov.org>2014-04-03 19:10:20 +0200
commit3afefa76afe106f549a616583612413015c48aa0 (patch)
tree3d35c59f5831de37928144287d1f925be69c85e9 /main.lua
downloadMastermind-3afefa76afe106f549a616583612413015c48aa0.tar.gz
Mastermind-3afefa76afe106f549a616583612413015c48aa0.tar.bz2
Mastermind-3afefa76afe106f549a616583612413015c48aa0.tar.xz
Mastermind-3afefa76afe106f549a616583612413015c48aa0.zip
Importation initiale du projet
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua88
1 files changed, 88 insertions, 0 deletions
diff --git a/main.lua b/main.lua
new file mode 100644
index 0000000..10d0633
--- /dev/null
+++ b/main.lua
@@ -0,0 +1,88 @@
+require 'love2d-fakecanvas/fakecanvas'
+
+colors = { { 0, 0, 255, 255}, {0, 255, 0, 255}, {0, 255, 255, 255}, {255, 0, 0, 255}, {255, 0, 255, 255}, {255, 255, 0, 255} }
+
+local circle_s = love.graphics.circle
+
+function love.graphics.circle(t, x, y, r, d)
+ local color = {love.graphics.getColor()}
+ love.graphics.setColor(0, 0, 0, 255)
+ circle_s("line",x,y,r+0.5,d)
+ love.graphics.setColor(unpack(color))
+ circle_s(t,x,y,r,d)
+end
+
+local rect_s = love.graphics.rectangle
+
+function love.graphics.rectangle(t, x, y, r, d)
+ local color = {love.graphics.getColor()}
+ love.graphics.setColor(0, 0, 0, 255)
+ rect_s("line",x,y,r,d)
+ love.graphics.setColor(unpack(color))
+ rect_s(t,x,y,r,d)
+end
+
+function love.load()
+ love.window.setMode(450, 600, {fullscreen = false, fsaa = 4})
+ love.window.setTitle("Mastermind")
+ love.graphics.setBackgroundColor(255, 255, 255)
+
+canvas = love.graphics.newCanvas(400, 600)
+ love.graphics.setCanvas(canvas)
+ canvas:clear()
+ love.graphics.setBlendMode('alpha')
+
+
+ love.graphics.setColor(255, 0, 127, 255)
+ love.graphics.rectangle("fill", 0, 525, 400, 75)
+ for j=1,6 do
+ love.graphics.setColor(unpack(colors[j]))
+ love.graphics.circle("fill", 57*j, 562, 25, 100)
+ end
+ for g=0,6 do
+ love.graphics.setColor(125, 41-5*g, 0+25*g, 255)
+ love.graphics.rectangle("fill", 0, 75*g, 100, 75)
+ love.graphics.setColor(42*g, 255, 15*g, 255)
+ love.graphics.rectangle("fill", 100, 75*g, 300, 75)
+ love.graphics.setColor(255, 255, 255, 255)
+ for i=1,4 do
+ love.graphics.circle("fill", 100+(60*i), 38+(75*g), 25, 100)
+ end
+ for h=0,1 do
+ for k=1,2 do
+ love.graphics.circle("fill", (40*k)-10, 22+(75*g)+(30*h), 13, 100)
+ end
+ end
+ end
+
+ love.graphics.setCanvas()
+
+end
+
+x1 = 0
+y1 = 0
+p1 = 0
+clicked = 0
+
+function love.mousepressed(x, y, p)
+ x1 = x
+ y1 = y
+ p1 = p
+ x = x - 50
+ if y > 525 then
+ for j=1,6 do
+ if math.sqrt(math.pow(57*j - x, 2) + math.pow(562 - y, 2)) < 25 then
+ clicked = j
+ end
+ end
+ end
+end
+
+function love.draw()
+ love.graphics.setColor(0, 0, 0, 255)
+ love.graphics.print(x1 .. " " .. y1 .. " " .. p1, 0, 0)
+ love.graphics.print(clicked, 0, 30)
+ love.graphics.setColor(255, 255, 255, 255)
+ love.graphics.setBlendMode('premultiplied')
+ love.graphics.draw(canvas, 50, 0)
+end