diff options
Diffstat (limited to 'GUI')
-rw-r--r-- | GUI/Common.lua | 30 | ||||
-rw-r--r-- | GUI/InGame.lua | 134 | ||||
-rw-r--r-- | GUI/Menu.lua | 8 |
3 files changed, 90 insertions, 82 deletions
diff --git a/GUI/Common.lua b/GUI/Common.lua deleted file mode 100644 index 5b62ed1..0000000 --- a/GUI/Common.lua +++ /dev/null @@ -1,30 +0,0 @@ -local GUI = {} - -function GUI.drawPolygon(polygon) - if polygon.Colors then - love.graphics.setColor(unpack(polygon.Colors)) - end - - 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) - elseif polygon.Type == "print" then - love.graphics.print(polygon.Text, polygon.Position.x*Window.width, polygon.Position.y*Window.height) - end -end - -return GUI diff --git a/GUI/InGame.lua b/GUI/InGame.lua index 17b1ffd..0f63cb3 100644 --- a/GUI/InGame.lua +++ b/GUI/InGame.lua @@ -1,10 +1,16 @@ +--[[ + GUI/InGame.lua + Game interface + by Roildan & piernov +]]-- + local InGame = {} -InGame.Polygons = {} +InGame.Polygons = {} -- Tableau utilisé pour la fonction InGame.drawPolygon(polygon) -InGame.Colors = { {255, 0, 0, 255}, {255, 128, 0, 255}, {255, 255, 0, 255}, {0, 255, 0, 255}, {128, 128, 128, 255}, {255, 255, 255, 255} } +InGame.Colors = { {255, 0, 0, 255}, {255, 128, 0, 255}, {255, 255, 0, 255}, {0, 255, 0, 255}, {128, 128, 128, 255}, {255, 255, 255, 255} } -- Tableau de 6 couleurs. -function InGame.drawPolygon(polygon) +function InGame.drawPolygon(polygon) -- Fonction pour dessiner. if polygon.Colors then love.graphics.setColor(unpack(polygon.Colors)) end @@ -31,7 +37,15 @@ function InGame.drawPolygon(polygon) end end -function InGame.loadInterface() +function InGame.displayPopup(text) -- Display a popup on the center of the screen + love.graphics.setFont(Fonts[4]) + InGame.drawPolygon({ Type = "rectangle", LineWidth = 0.01, DrawMode = "line", Position = { x = 0.30, y = 0.40}, Dimension = {width = 0.40, height = 0.20}, Colors = {0, 0, 255, 255}}) + InGame.drawPolygon({ Type = "rectangle", DrawMode = "fill", Position = { x = 0.30, y = 0.40}, Dimension = {width = 0.40, height = 0.20}, Colors = {0, 0, 0, 255}}) + InGame.drawPolygon({ Type = "print", Text = text, Position = {x = 0.45, y = 0.48}, Colors = {255, 255, 255, 255}}) + love.graphics.setFont(Fonts[3]) +end + +function InGame.loadInterface() -- Interface used in both Solo and Multiplayer mode love.graphics.setBackgroundColor(0, 0, 0) -- Inner window border @@ -47,16 +61,76 @@ function InGame.loadInterface() table.insert(InGame.Polygons, { Type = "rectangle", DrawMode = "fill", Position = { x = 0.05, y = 0.05}, Dimension = {width = 0.35, height = 0.90}, Colors = {0, 0, 0, 255} }) -- Rectangle plein (noir) permettant de cacher les barres diagonales. table.insert(InGame.Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.05, y = 0.05}, Dimension = {width = 0.35, height = 0.90}, Colors = {0, 0, 171, 255} }) -- Rectangle de la partie gauche. table.insert(InGame.Polygons, { Type = "line", Position = { x1 = 0.05, y1 = 0.1, x2 = 0.4, y2 = 0.1}, Colors = {0, 0, 171, 255} }) -- Ligne séparant le rectangle précédent en 2 partie. - + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.05, y1 = 0.85, x2 = 0.4, y2 = 0.85}, Colors = {0, 0, 171, 255} })-- Ligne séparant le rectangle précédent en 2 partie. + -- Left box buttons table.insert(InGame.Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.075, y = 0.875}, Dimension = {width = 0.125, height = 0.05}, Colors = {0, 0, 171, 255} }) -- Rectangle du boutton "Reset". - table.insert(InGame.Polygons, { Type = "print", Text = "Reset", Position = { x = 0.075+0.035, y = 0.875+0.01 }, Colors = { 255, 255, 255, 255}}) + table.insert(InGame.Polygons, { Type = "print", Text = "Reset", Position = { x = 0.075+0.025, y = 0.875+0.01 }, Colors = { 255, 255, 255, 255}}) table.insert(InGame.Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.25, y = 0.875}, Dimension = {width = 0.125, height = 0.05}, Colors = {0, 0, 171, 255} }) -- Rectangle du boutton "Valider" - table.insert(InGame.Polygons, { Type = "print", Text = "Valider", Position = { x = 0.25+0.035, y = 0.875+0.01 }, Colors = { 255, 255, 255, 255}}) + table.insert(InGame.Polygons, { Type = "print", Text = "Ok", Position = { x = 0.25+0.04, y = 0.875+0.01 }, Colors = { 255, 255, 255, 255}}) + + -- Right top box + table.insert(InGame.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} }) -- Rectangle supérieur de la partie droite. + table.insert(InGame.Polygons, { Type = "line", Position = { x1 = 0.45, y1 = 0.1, x2 = 0.95, y2 = 0.1}, Colors = {0, 0, 171, 255} }) -- Ligne séparant le rectangle précédent en 2 partie. + + -- Right top box content + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.475-0.0025, y1 = 0.75, x2 = 0.52+5*0.075+0.0025, y2 = 0.75}, Colors = {0, 0, 171, 255} }) -- Barre horizontale en bas. + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.475, y1 = 0.75, x2 = 0.475, y2 = 0.15-0.0025}, Colors = {0, 0, 171, 255} }) -- Grande barre verticale à gauche. + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.9, y1 = 0.15-0.0025, x2 = 0.9, y2 = 0.7}, Colors = {0, 0, 171, 255} }) -- Grande barre verticale à droite. + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.03, Position = { x1 = 0.795, y1 = 0.7-0.01, x2 = 0.9+0.005, y2 = 0.7-0.01}, Colors = {0, 0, 171, 255} }) -- Barre reliant la barre précédente et le rectangle "sécurité". + table.insert(InGame.Polygons, { Type = "rectangle", LineWidth = 0.01, DrawMode = "line", Position = { x = 0.52, y = 0.66}, Dimension = {width = 0.275, height = 0.05}, Colors = {0, 0, 171, 255} }) -- Rectangle de la "vie" du joueur. + + for o = 0, 8 do + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.5475+0.0275*o, y1 = 0.66, x2 = 0.5475+0.0275*o, y2 = 0.71}, Colors = {0, 0, 171, 255} }) -- Petites séparant le rectangle de la "vie" du joueur. + end + + for j = 0, 6 do + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.77, y1 = 0.15+j*0.075, x2 = 0.785, y2 = 0.15+j*0.075}, Colors = {0, 0, 171, 255} }) -- 7 petites barres reliant les derniers grands carrés et les petits groupes de 4 petits carrés. + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.86, y1 = 0.15+j*0.075, x2 = 0.9, y2 = 0.15+j*0.075}, Colors = {0, 0, 171, 255} }) -- 7 barres reiant les groupes de 4 petits carrés avec la grande barrre verticale. + + for i = 0, 3 do + table.insert(InGame.Polygons, { Type = "rectangle", LineWidth = 0.01, DrawMode = "line", Position = { x = 0.497+i*0.075, y = 0.12+j*0.075}, Dimension = {width = 0.045, height = 0.05}, Colors = {0, 0, 171, 255} }) -- 4 grands rectangles. + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.471+i*0.075, y1 = 0.15+j*0.075, x2 = 0.497+i*0.075, y2 = 0.15+j*0.075}, Colors = {0, 0, 171, 255} }) -- 4 petites barres reliant entre eux les 4 rectangles précédents. + end + + for k = 0, 1 do + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.785+k*0.075, y1 = 0.1275+j*0.075-0.0005, x2 = 0.785+k*0.075, y2 = 0.1725+j*0.075+0.0005}, Colors = {0, 0, 171, 255} }) -- 14 barres verticales encadrant les 7 groupes de 4 petits carrés. + for l = 0, 1 do + table.insert(InGame.Polygons, { Type = "rectangle", LineWidth = 0.0025, DrawMode = "line", Position = { x = 0.795+k*0.0325, y = 0.12+l*0.0325+j*0.075}, Dimension = {width = 0.0225, height = 0.025}, Colors = {0, 0, 171, 255} }) -- 7 groupes de 4 petits rectangles. + end + + for m = 0, 2 do + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.0025, Position = { x1 = 0.785+m*0.0325, y1 = 0.1275+k*0.045+j*0.075, x2 = 0.795+m*0.0325, y2 = 0.1275+k*0.045+j*0.075}, Colors = {0, 0, 171, 255} }) -- 42 petites barres horizontales reliant entre eux les groupes de 4 petits carrés. + end + end + end + -- Right bottom box + table.insert(InGame.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} }) -- Rectangle plein (noir) permettant de cacher les barres diagonales. + table.insert(InGame.Polygons, { Type = "rectangle", DrawMode = "line", Position = { x = 0.45, y = 0.85}, Dimension = {width = 0.50, height = 0.10}, Colors = {0, 0, 171, 255} }) -- Rectangle de la parie droite en bas. + + -- Right bottom box buttons + for i = 0, 5 do + table.insert(InGame.Polygons, { Type = "rectangle", DrawMode = "fill", Position = { x = 0.50+i*0.075, y = 0.875}, Dimension = {width = 0.04, height = 0.04}, Colors = InGame.Colors[i+1] }) -- Remplissage des 6 carrés par les couleurs du tableau "InGame.Colors". + table.insert(InGame.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} }) -- 6 carrés. + table.insert(InGame.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} }) -- 6 barres verticales reliant les 6 carrés avec la barre horizontale plus haut. + if i < 5 then + table.insert(InGame.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} }) -- 5 barres horizontales reliant les 6 carrées précédents entre eux. + end + end +end + +function InGame.loadMultiplayerInterface() -- Addition elements for Multiplayer -- Left box content table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.375, y1 = 0.15-0.005, x2 = 0.375, y2 = 0.75+0.005}, Colors = {0, 0, 171, 255} }) -- Grande barre verticale à droite. table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.06+0.0025, y1 = 0.15, x2 = 0.08, y2 = 0.15}, Colors = {0, 0, 171, 255} }) -- Petite barre horizontale à gauche du dernier grand carré du haut (plus petite que les autres sinon elle dépassait de la case). + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.15+0.0025, y1 = 0.55, x2 = 0.19, y2 = 0.55}, Colors = {0, 0, 171, 255} }) -- Petite barre horizontale + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.02, Position = { x1 = 0.16, y1 = 0.55, x2 = 0.16, y2 = 0.6}, Colors = {0, 0, 171, 255} }) -- Barre verticale reliant au rectangle suivant. + table.insert(InGame.Polygons, { Type = "rectangle",LineWidth = 0.01, DrawMode = "line", Position = { x = 0.135, y = 0.6}, Dimension = {width = 0.05, height = 0.2}, Colors = {0, 0, 171, 255} }) -- Rectangle de la "vie" du joueur. + + for o = 0, 8 do + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.135, y1 = 0.62+0.02*o, x2 = 0.185, y2 = 0.62+0.02*o}, Colors = {0, 0, 171, 255} }) -- Petites séparant le rectangle de la "vie" du joueur. + end for i = 0, 3 do table.insert(InGame.Polygons, { Type = "rectangle", LineWidth = 0.01, DrawMode = "line", Position = { x = 0.08+i*0.075, y = 0.12}, Dimension = {width = 0.045, height = 0.05}, Colors = {0, 0, 171, 255} }) -- 4 grands carrés du haut. @@ -84,53 +158,9 @@ function InGame.loadInterface() end end end - - -- Right top box - table.insert(InGame.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} }) -- Rectangle supérieur de la partie droite. - table.insert(InGame.Polygons, { Type = "line", Position = { x1 = 0.45, y1 = 0.1, x2 = 0.95, y2 = 0.1}, Colors = {0, 0, 171, 255} }) -- Ligne séparant le rectangle précédent en 2 partie. -- Right top box content - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.375-0.0025, y1 = 0.75, x2 = 0.52+5*0.075+0.0025, y2 = 0.75}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.475, y1 = 0.75, x2 = 0.475, y2 = 0.15-0.0025}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.9, y1 = 0.15-0.0025, x2 = 0.9, y2 = 0.7}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.03, Position = { x1 = 0.795, y1 = 0.7-0.01, x2 = 0.9+0.005, y2 = 0.7-0.01}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "rectangle", LineWidth = 0.01, DrawMode = "line", Position = { x = 0.52, y = 0.66}, Dimension = {width = 0.275, height = 0.05}, Colors = {0, 0, 171, 255} }) - - for j = 0, 6 do - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.77, y1 = 0.15+j*0.075, x2 = 0.785, y2 = 0.15+j*0.075}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.785, y1 = 0.1275+j*0.075-0.0005, x2 = 0.785, y2 = 0.1725+j*0.075+0.0005}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.86, y1 = 0.1275+j*0.075, x2 = 0.86, y2 = 0.1725+j*0.075}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.005, Position = { x1 = 0.86, y1 = 0.15+j*0.075, x2 = 0.9, y2 = 0.15+j*0.075}, Colors = {0, 0, 171, 255} }) - - for i = 0, 3 do - table.insert(InGame.Polygons, { Type = "rectangle", LineWidth = 0.01, DrawMode = "line", Position = { x = 0.497+i*0.075, y = 0.12+j*0.075}, Dimension = {width = 0.045, height = 0.05}, Colors = {0, 0, 171, 255} }) - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.471+i*0.075, y1 = 0.15+j*0.075, x2 = 0.497+i*0.075, y2 = 0.15+j*0.075}, Colors = {0, 0, 171, 255} }) - end - - for k = 0, 1 do - for l = 0, 1 do - table.insert(InGame.Polygons, { Type = "rectangle", LineWidth = 0.0025, DrawMode = "line", Position = { x = 0.795+k*0.0325, y = 0.12+l*0.0325+j*0.075}, Dimension = {width = 0.0225, height = 0.025}, Colors = {0, 0, 171, 255} }) - end - - for m = 0, 2 do - table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.0025, Position = { x1 = 0.785+m*0.0325, y1 = 0.1275+k*0.045+j*0.075, x2 = 0.795+m*0.0325, y2 = 0.1275+k*0.045+j*0.075}, Colors = {0, 0, 171, 255} }) - end - end - end - - -- Right bottom box - table.insert(InGame.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(InGame.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(InGame.Polygons, { Type = "rectangle", DrawMode = "fill", Position = { x = 0.50+i*0.075, y = 0.875}, Dimension = {width = 0.04, height = 0.04}, Colors = InGame.Colors[i+1] }) - table.insert(InGame.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(InGame.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(InGame.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 + table.insert(InGame.Polygons, { Type = "line", LineWidth = 0.01, Position = { x1 = 0.375-0.0025, y1 = 0.75, x2 = 0.52+5*0.075+0.0025, y2 = 0.75}, Colors = {0, 0, 171, 255} }) -- Barre horizontale en bas. end return InGame diff --git a/GUI/Menu.lua b/GUI/Menu.lua index 29f3386..d5bb455 100644 --- a/GUI/Menu.lua +++ b/GUI/Menu.lua @@ -1,3 +1,11 @@ +--[[ + GUI/Menu.lua + Main menu button list + by piernov + + Comment: seems useless too… +]]-- + return { Buttons = { "Solo", |