aboutsummaryrefslogtreecommitdiff
path: root/gamemode
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-02-27 20:11:33 -0500
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-02-27 20:11:33 -0500
commit8d1447d13b2ec82588f52467be56b90c8ffe9e80 (patch)
tree97d264d1792dd6ca7ad05912e3b333f6ce6af0c5 /gamemode
parent21fca07b8e449daf8446ff67b0169d0fd39bec9c (diff)
downloadwintersurvival2-8d1447d13b2ec82588f52467be56b90c8ffe9e80.tar.gz
wintersurvival2-8d1447d13b2ec82588f52467be56b90c8ffe9e80.tar.bz2
wintersurvival2-8d1447d13b2ec82588f52467be56b90c8ffe9e80.zip
Finished rubicks circle minigame
Diffstat (limited to 'gamemode')
-rw-r--r--gamemode/hud/draw_spell.lua1
-rw-r--r--gamemode/hud/games/rubickscircle.lua101
2 files changed, 78 insertions, 24 deletions
diff --git a/gamemode/hud/draw_spell.lua b/gamemode/hud/draw_spell.lua
index 32c1bc6..97c702b 100644
--- a/gamemode/hud/draw_spell.lua
+++ b/gamemode/hud/draw_spell.lua
@@ -138,7 +138,6 @@ end
function DrawSpellOverlay()
if(CASTING_SPELL) then
- print("Calling casting_spell's draw...")
CASTING_SPELL["draw"](CASTING_SPELL)
if(CASTING_SPELL.Score != nil) then
finishedcasting(CASTING_SPELL.Score)
diff --git a/gamemode/hud/games/rubickscircle.lua b/gamemode/hud/games/rubickscircle.lua
index 56e4a44..cd50bf2 100644
--- a/gamemode/hud/games/rubickscircle.lua
+++ b/gamemode/hud/games/rubickscircle.lua
@@ -18,6 +18,8 @@ Game.Cast = function(spelltab,difficulty)
--Initalization stuff
--[[The cirlces for this spelltab, each cirlce has dots, represtented as a number, 0 is empty]]--
spelltab.Circles = {}
+ --The win conditions stored in the same way as Circles
+ spelltab.Goal = {}
--The currently selected circle number, 0 is the inner most
spelltab.SelectedCircle = 0
--The Points that need to be filled, represtented as circle, then a number 0-7 on which direction needs to be filled
@@ -51,6 +53,7 @@ Game.Cast = function(spelltab,difficulty)
spelltab.ANIMATE_REMOVE_DURATION = 0.5
spelltab.MaxColor = 3
+ spelltab.GoalNum = 5
@@ -69,10 +72,12 @@ Game.Cast = function(spelltab,difficulty)
for i=0, spelltab.numcircle-1 do
spelltab.AnimateRemoveingPoints[i] = {}
spelltab.Circles[i] = {}
+ spelltab.Goal[i] = {}
for j = 0, 7 do
spelltab.AnimateRemoveingPoints[i][j] = false
--spelltab.Circles[i][j] = math.Round(math.random(0,3))
spelltab.Circles[i][j] = 0
+ spelltab.Goal[i][j] = 0
end
end
for i=0, 7 do
@@ -82,11 +87,23 @@ Game.Cast = function(spelltab,difficulty)
spelltab.NextInputDirection = math.Round(math.random(0,7))
spelltab.NextInputColor = math.Round(math.random(1,spelltab.MaxColor))
+ --Generate 5 random spots and colors that need to be filled
+ local i = 0
+ while(i < spelltab.GoalNum) do
+ local randLvl = math.Round(math.random(0,spelltab.numcircle-2))
+ local randang = math.Round(math.random(0,7))
+ local randcolor = math.Round(math.random(1,spelltab.MaxColor))
+ if(spelltab.Goal[randLvl][randang] != 0) then continue
+ else
+ spelltab.Goal[randLvl][randang] = randcolor
+ i = i+1
+ end
+ end
+
end
--Called continuously while the player is casting
Game.Draw = function(self)
- print("Draw function being called")
if not input.IsKeyTrapping() then
input.StartKeyTrapping()
end
@@ -125,6 +142,19 @@ Game.Draw = function(self)
surface.DrawCircle(x,y,radius,self.ColorFor(self.Circles[i][j]))
end
+ if(self.Goal[i][j] != 0) then
+ local angle = (-j*45)+90
+ local mul = (i+1)*100
+ local x = (math.cos(math.rad(angle))*mul) + (ScrW()/2)
+ local y = (math.sin(math.rad(angle))*mul) + (ScrH()/2)
+ local color = self.ColorFor(self.Goal[i][j])
+ surface.SetDrawColor(color)
+ if(self.Goal[i][j] == self.Circles[i][j]) then
+ surface.DrawRect(x-20,y-20,40,40)
+ else
+ surface.DrawOutlinedRect(x-20,y-20,40,40)
+ end
+ end
end
end
--Draw the next-to-add circle
@@ -146,6 +176,16 @@ Game.Draw = function(self)
self.Circles[self.SelectedCircle][0] = tmp
self.Animateingringnum = -1
self.Animateingdirection = 0
+ --Add the new dot in, or fail if we can't
+ if(self.Circles[self.numcircle-1][self.NextInputDirection] != 0) then
+ print("self fail :(")
+ self.Score = 0
+ self.scoreboard:Remove()
+ else
+ self.Circles[self.numcircle-1][self.NextInputDirection] = self.NextInputColor
+ self.NextInputDirection = math.Round(math.random(0,7))
+ self.NextInputColor = math.Round(math.random(1,self.MaxColor))
+ end
self.ProcessMoved(self)
elseif(self.Animateingdirection == -1) then
local tmp = self.Circles[self.SelectedCircle][0]
@@ -155,6 +195,16 @@ Game.Draw = function(self)
self.Circles[self.SelectedCircle][7] = tmp
self.Animateingringnum = -1
self.Animateingdirection = 0
+ --Add the new dot in, or fail if we can't
+ if(self.Circles[self.numcircle-1][self.NextInputDirection] != 0) then
+ print("self fail :(")
+ self.Score = 0
+ self.scoreboard:Remove()
+ else
+ self.Circles[self.numcircle-1][self.NextInputDirection] = self.NextInputColor
+ self.NextInputDirection = math.Round(math.random(0,7))
+ self.NextInputColor = math.Round(math.random(1,self.MaxColor))
+ end
self.ProcessMoved(self)
end
end
@@ -189,16 +239,6 @@ Game.Draw = function(self)
elseif(input.IsKeyDown(KEY_Q)) then
--If anything is animateing, don't allow the player input
if(self.Animateingringnum != -1 or self.AnimateFalling) then return end
- --Add the new dot in, or fail if we can't
- if(self.Circles[self.numcircle-1][self.NextInputDirection] != 0) then
- print("self fail :(")
- self.Score = 0
- self.scoreboard:Remove()
- else
- self.Circles[self.numcircle-1][self.NextInputDirection] = self.NextInputColor
- self.NextInputDirection = math.Round(math.random(0,7))
- self.NextInputColor = math.Round(math.random(1,self.MaxColor))
- end
--Rotate stuff counter-clockwise
self.Animateingringnum = self.SelectedCircle
self.Animateingdirection = 1
@@ -206,16 +246,6 @@ Game.Draw = function(self)
elseif(input.IsKeyDown(KEY_E)) then
--Don't move if animations are happeneing
if(self.Animateingringnum != -1 or self.AnimateFalling) then return end
- --Add the new dot in, or fail if we can't
- if(self.Circles[self.numcircle-1][self.NextInputDirection] != 0) then
- print("self fail :(")
- self.Score = 0
- self.scoreboard:Remove()
- else
- self.Circles[self.numcircle-1][self.NextInputDirection] = self.NextInputColor
- self.NextInputDirection = math.Round(math.random(0,7))
- self.NextInputColor = math.Round(math.random(1,self.MaxColor))
- end
--Rotate stuff clockwise
self.Animateingringnum = self.SelectedCircle
self.Animateingdirection = -1
@@ -238,13 +268,37 @@ Game.Draw = function(self)
end
end
+Game.CheckCompleted = function(self)
+ local numcompleted = 0
+ for i=0,self.numcircle-1 do
+ for j=0, 7 do
+ if(self.Goal[i][j] != 0 and self.Circles[i][j] == self.Goal[i][j]) then
+ numcompleted = numcompleted + 1
+ end
+ end
+ end
+ if(numcompleted == self.GoalNum) then
+ self.Score = 100
+ self.scoreboard:Remove()
+ end
+end
+
--What to do when anything moved
Game.ProcessMoved = function(self)
- print("Processing:")
- PrintTable(self)
+ PrintTable(self.Circles)
+ if(self.Circles == nil) then
+ print("OH NO, CIRCLES WAS NIL!")
+ return
+ end
--First, check to see if anything is 3 in a column
for i = 0, 7 do
for j = 0, self.numcircle-3 do
+ if(self.Circles[j] == nil) then
+ print("J table:")
+ PrintTable(j)
+ --print("OH NO, CIRCLE " .. j .. " WAS NIL!")
+ return
+ end
local tomatch = self.Circles[j][i]
if(tomatch == 0) then continue end
local ismatching = true
@@ -309,6 +363,7 @@ Game.ProcessMoved = function(self)
end
end
end
+ self.CheckCompleted(self)
end
Game.ColorFor = function(num)