aboutsummaryrefslogtreecommitdiffstats
path: root/main.lua
blob: 10d063389655bb17a1b03fae9f6ea3a01db60de7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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