diff options
author | piernov <piernov@piernov.org> | 2014-04-04 22:31:56 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2014-04-04 22:31:56 +0200 |
commit | af5169331f4ceaee4d72fe12e87751c64b101293 (patch) | |
tree | 015892e3121baa4da829aac022e6c4f26b817970 | |
parent | d59e84baad53a4b2bd2fbd494931d6087d18cd4f (diff) | |
download | Mastermind-af5169331f4ceaee4d72fe12e87751c64b101293.tar.gz Mastermind-af5169331f4ceaee4d72fe12e87751c64b101293.tar.bz2 Mastermind-af5169331f4ceaee4d72fe12e87751c64b101293.tar.xz Mastermind-af5169331f4ceaee4d72fe12e87751c64b101293.zip |
Start working on new interface (showed in "Projet ISN PE-ARTHUR.png" by Choucka)
-rw-r--r-- | Projet ISN PE-ARTHUR.png | bin | 0 -> 15638 bytes | |||
-rw-r--r-- | conf.lua | 22 | ||||
-rw-r--r-- | main.lua | 142 |
3 files changed, 99 insertions, 65 deletions
diff --git a/Projet ISN PE-ARTHUR.png b/Projet ISN PE-ARTHUR.png Binary files differnew file mode 100644 index 0000000..840f447 --- /dev/null +++ b/Projet ISN PE-ARTHUR.png diff --git a/conf.lua b/conf.lua new file mode 100644 index 0000000..fa40609 --- /dev/null +++ b/conf.lua @@ -0,0 +1,22 @@ + +function love.conf(t) + t.identity = nil -- The name of the save directory (string) + t.version = "0.9.0" -- The LÖVE version this game was made for (string) + t.console = false -- Attach a console (boolean, Windows only) + + t.window.title = "Mastermind" -- The window title (string) + t.window.icon = nil -- Filepath to an image to use as the window's icon (string) + t.window.width = 640 -- The window width (number) + t.window.height = 640 -- The window height (number) + t.window.borderless = false -- Remove all border visuals from the window (boolean) + t.window.resizable = true -- Let the window be user-resizable (boolean) + t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) + t.window.minheight = 1 -- Minimum window height if the window is resizable (number) + t.window.fullscreen = false -- Enable fullscreen (boolean) + t.window.fullscreentype = "normal" -- Standard fullscreen or desktop fullscreen mode (string) + t.window.vsync = true -- Enable vertical sync (boolean) + t.window.fsaa = 4 -- The number of samples to use with multi-sampled antialiasing (number) + t.window.display = 1 -- Index of the monitor to show the window in (number) + t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean). Added in 0.9.1 + t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean). Added in 0.9.1 +end @@ -1,88 +1,100 @@ 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 Window = {} +local 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 Polygons = {} +local Keypressed = {} -local circle_s = love.graphics.circle +function love.load() + love.graphics.setBackgroundColor(0, 0, 0) -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 + -- Inner window border + table.insert(Polygons, { Type = "rectangle", DrawMode = "line", LineWidth = 0.005, Position = { x = 0.005, y = 0.005}, Dimension = {width = 0.99, height = 0.99}, Colors = {0, 0, 171, 255} }) -local rect_s = love.graphics.rectangle + -- Background + for i = 0, 5 do + table.insert(Polygons, { Type = "polygon", DrawMode = "fill", Position = { x1 = 0.01, y1 = 0.02+0.02*i, x2 = 0.02+0.02*i, y2 = 0.01, x3 = 0.03+0.02*i, y3 = 0.01, x4 = 0.01, y4 = 0.03+0.02*i}, Colors = {0, 0, 171, 255} }) + table.insert(Polygons, { Type = "polygon", DrawMode = "fill", Position = { x1 = 0.99, y1 = 0.98-0.02*i, x2 = 0.98-0.02*i, y2 = 0.99, x3 = 0.97-0.02*i, y3 = 0.99, x4 = 0.99, y4 = 0.97-0.02*i}, Colors = {0, 0, 171, 255} }) + end -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 + -- Left box + table.insert(Polygons, { Type = "rectangle", DrawMode = "fill", Position = { x = 0.05, y = 0.05}, Dimension = {width = 0.35, height = 0.90}, Colors = {0, 0, 0, 255} }) + table.insert(Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.05, y = 0.05}, Dimension = {width = 0.35, height = 0.90}, Colors = {0, 0, 171, 255} }) + table.insert(Polygons, { Type = "line", Position = { x1 = 0.05, y1 = 0.1, x2 = 0.4, y2 = 0.1}, Colors = {0, 0, 171, 255} }) -function love.load() - love.window.setMode(450, 600, {fullscreen = false, fsaa = 4}) - love.window.setTitle("Mastermind") - love.graphics.setBackgroundColor(255, 255, 255) + -- Left box buttons + table.insert(Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.075, y = 0.875}, Dimension = {width = 0.125, height = 0.05}, Colors = {0, 0, 171, 255} }) + table.insert(Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.25, y = 0.875}, Dimension = {width = 0.125, height = 0.05}, Colors = {0, 0, 171, 255} }) -canvas = love.graphics.newCanvas(400, 600) - love.graphics.setCanvas(canvas) - canvas:clear() - love.graphics.setBlendMode('alpha') + -- Left box content + table.insert(Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.375, y1 = 0.15, x2 = 0.375, y2 = 0.75}, Colors = {0, 0, 171, 255} }) + -- Right top box + table.insert(Polygons, { Type = "rectangle", LineWidth = 0.005, DrawMode = "line", Position = { x = 0.45, y = 0.05}, Dimension = {width = 0.50, height = 0.75}, Colors = {0, 0, 171, 255} }) + table.insert(Polygons, { Type = "line", Position = { x1 = 0.45, y1 = 0.1, x2 = 0.95, y2 = 0.1}, Colors = {0, 0, 171, 255} }) - 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) + -- Right top box content + table.insert(Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.375-0.005, y1 = 0.75, x2 = 0.52+5*0.075+0.005, y2 = 0.75}, Colors = {0, 0, 171, 255} }) + + -- Right bottom box + table.insert(Polygons, { Type = "rectangle", LineWidth = 0.005, DrawMode = "fill", Position = { x = 0.45, y = 0.85}, Dimension = {width = 0.50, height = 0.10}, Colors = {0, 0, 0, 255} }) + table.insert(Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.45, y = 0.85}, Dimension = {width = 0.50, height = 0.10}, Colors = {0, 0, 171, 255} }) + + -- Right bottom box buttons + for i = 0, 5 do + table.insert(Polygons, { Type = "rectangle", DrawMode = "fill", Position = { x = 0.50+i*0.075, y = 0.875}, Dimension = {width = 0.04, height = 0.04}, Colors = colors[i+1] }) + table.insert(Polygons, { Type = "rectangle", DrawMode = "line", LineWidth = 0.01, Position = { x = 0.50+i*0.075, y = 0.875}, Dimension = {width = 0.04, height = 0.04}, Colors = {0, 0, 171, 255} }) + table.insert(Polygons, { Type = "line", Position = { x1 = 0.52+i*0.075, y1 = 0.75, x2 = 0.52+i*0.075, y2 = 0.875}, Colors = {0, 0, 171, 255} }) + if i < 5 then table.insert(Polygons, { Type = "line", Position = { x1 = 0.5+i*0.075+0.04, y1 = 0.895, x2 = 0.52+(i+1)*0.075, y2 = 0.895}, Colors = {0, 0, 171, 255} }) end 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 + +local function drawPolygon(polygon) + if polygon.Colors then + love.graphics.setColor(unpack(polygon.Colors)) end - love.graphics.setCanvas() + if polygon.LineWidth then + love.graphics.setLineWidth(polygon.LineWidth*(Window.width+Window.height)/2) + end + + if polygon.Type == "rectangle" then + love.graphics.rectangle(polygon.DrawMode, polygon.Position.x*Window.width, polygon.Position.y*Window.height, + polygon.Dimension.width*Window.width, polygon.Dimension.height*Window.height) + + elseif polygon.Type == "polygon" then + love.graphics.polygon(polygon.DrawMode, polygon.Position.x1*Window.width, polygon.Position.y1*Window.height, + polygon.Position.x2*Window.width, polygon.Position.y2*Window.height, + polygon.Position.x3*Window.width, polygon.Position.y3*Window.height, + polygon.Position.x4*Window.width, polygon.Position.y4*Window.height) + elseif polygon.Type == "line" then + love.graphics.line(polygon.Position.x1*Window.width, polygon.Position.y1*Window.height, + polygon.Position.x2*Window.width, polygon.Position.y2*Window.height) + end 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 +function love.mousepressed(x, y, b) + x = x/Window.width + y = y/Window.height + if 0.875 < y and y < 0.915 then + for i = 0,5 do + if 0.50+i*0.075 < x and x < 0.50+i*0.075+0.04 then + table.insert(Keypressed, i) 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) + Window.width, Window.height = love.window.getDimensions() + + for id, polygon in ipairs(Polygons) do + drawPolygon(polygon) + end + + love.graphics.setColor(255, 255, 255, 255) + for id, num in ipairs(Keypressed) do + love.graphics.print(num, (0.1+(id%5)*0.05)*Window.width, (0.6+((id-(id%5))/5)*0.05)*Window.height) + end end |