diff options
Diffstat (limited to 'gamemode')
| -rw-r--r-- | gamemode/hud/games/connectthedots.lua | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gamemode/hud/games/connectthedots.lua b/gamemode/hud/games/connectthedots.lua index 9b89d70..e0d496d 100644 --- a/gamemode/hud/games/connectthedots.lua +++ b/gamemode/hud/games/connectthedots.lua @@ -1,9 +1,22 @@ --The connet the dots spell game print("Hi from connectthedots.lua") +--Minigame is held in self.dots, each dot is a table, +--dot[num] = {dot x, dot y, {{armor_start_angle,armor_end_angle},{armor_start_angle,armor_end_angle}}} + Game.Cast = function(self,difficulty) print("Cast with dificulty: " .. difficulty) self.Score = nil + + --Create a dummy panel so that the mouse is trapped, untrap it when it right clicks + scoreboard = vgui.Create("MBFrame") + if(!scoreboard) then return end + scoreboard:SetPos(0,0) + scoreboard:SetSize(0,0) + scoreboard:MakePopup() + self.scoreboard = scoreboard + + --Create the minigame end Game.Draw = function(self) @@ -11,10 +24,49 @@ Game.Draw = function(self) input.StartKeyTrapping() end draw.DrawText( "You're casting a spell!", "TargetID", ScrW() * 0.5, ScrH() * 0.25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER ) + print("X:" .. gui.MouseX() .. " Y:" .. gui.MouseY()) if(input.IsMouseDown(MOUSE_RIGHT)) then self.Score = 100 + self.scoreboard:Remove() + end +end + +--A basic dot, can be accessed from anywhere. +Game.AddRegDot = function(self) + + --Find the most recently added dot + local fd = table.GetFirstValue(self.dots) + local armors = {} + for k,v in pairs(fd[2]) do + armors[k] = v end + --Since armor can have multiple segments, pick all open segments, and find the surface area they occupy. + local totalsurface = 360 + for k,v in pairs(armors) do + print("Found armor between " .. v[1] .. " and " .. v[2]) + totalsurface = totalsurface - (v[1]-v[2]) + end + print("Looks like there's " .. totalsurface .. " of avaliable angle!") + --Pick a number between 0 and totalsurface that represents how much un-armored space is before us + local position = math.random(totalsurface) + + --Find the angles that we will add outselves between + for k,v in pairs(fd[2]) do + if(position > v[1]) then + position += v[2]-v[1] + end + end + print("Adding new dot at an angle of " .. position) + + --Pick a random distance from this dot to the screen edge, and put a dot there + local rand = 0 + + --If we're in the first quadrent + if(math.cos(position) > 0) then + rand = math.random(fd[0],ScrW()) + + end Game.AddDots = function(self) |
