Skip to content

Commit

Permalink
Removed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
besnoi authored Jul 17, 2020
1 parent 8cb378a commit d817bb5
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 9 deletions.
Binary file modified assets/graphics/gui/restartBtn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Entities/ScoreBoard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function ScoreBoard:renderText()
end

function ScoreBoard:render()
if euler.pointInRect(self.x,self.y-130,gImages.hintWindow:getWidth(),gImages.hintWindow:getHeight(),love.mouse.getPosition()) then
if not self.disabled and euler.pointInRect(self.x,self.y-130,gImages.hintWindow:getWidth(),gImages.hintWindow:getHeight(),love.mouse.getPosition()) then
love.graphics.setColor(.8,.8,.8)
end
love.graphics.draw(gImages.hintWindow,self.x,self.y-130)
Expand Down
85 changes: 85 additions & 0 deletions src/Scenes/LoseState.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
LoseState=State()

function LoseState:enter(params)
self.guiSystem=params.guiSystem
self.psystem=params.psystem
self.board=params.board
self.board.disabled=true
self.scoreBoard=params.scoreBoard
self.scoreBoard.disabled=true

self.restartBtn=lavis.imageButton(gImages.restartBtn,180+50,350)
self.restartBtn:setSize(130,140)
self.restartBtn:setImageOrigin(70,70)
self.restartBtn.onClick=function()
gStateMachine:change('roundOver',{
level=1,
target=100,
time=60
})
end
self.restartBtn.onMouseEnter=function()
self.restartBtn:setSize(160,160)
end
self.restartBtn.onMouseExit=function()
self.restartBtn:setSize(140,140)
end

self.exitBtn=lavis.imageButton(gImages.exitBtn,500-50,350)
self.exitBtn:setSize(145,140)
self.exitBtn:setImageOrigin(70,70)

self.exitBtn.onClick=function()
gStateMachine:change('mainMenu')
end
self.exitBtn.onMouseEnter=function()
self.exitBtn:setSize(160,155)
end
self.exitBtn.onMouseExit=function()
self.exitBtn:setSize(145,140)
end
end

function LoseState:update(dt)
self.restartBtn:update(dt)
self.exitBtn:update(dt)
end

function LoseState:render()
love.graphics.setColor(1,1,1,.5)
love.graphics.draw(gImages.gameBackground)

love.graphics.setColor(.3,.3,.3)
love.graphics.draw(background,245,40,0,.765,.76)
self.scoreBoard:render()
-- self.board:draw()
love.graphics.setColor(1,1,1)

love.graphics.draw(gImages['lemonWindow'],400,300,0,.7,.7,581/2,584/2)
self.exitBtn:render()
self.restartBtn:render()

love.graphics.setFont(whiteFont)
love.graphics.push()
love.graphics.scale(1.4,1.4)
love.graphics.setColor(.9,.9,.9)
love.graphics.print("You Lose!!",177,133)
love.graphics.pop()
love.graphics.setColor(1,1,1)
love.graphics.setFont(defaultFont)
end

function LoseState:mousePressed(...)
self.restartBtn:mousepressed(...)
self.exitBtn:mousepressed(...)
end

function LoseState:mouseReleased(...)
self.restartBtn:mousereleased(...)
self.exitBtn:mousereleased(...)
end

function LoseState:mouseMoved(...)
self.restartBtn:mousemoved(...)
self.exitBtn:mousemoved(...)
end
7 changes: 3 additions & 4 deletions src/Scenes/MainMenuState.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
MainMenuState=State()

function MainMenuState:init()
self.y=100
self.y=100 self.r=100
self.rectOp=0
self.scale=.3
self.playBtn=lavis.imageButton(gImages.playBtn,330,100)
self.playBtn:setShape('circle',130)
self.playBtn:setImageOrigin(95,95)
self.playBtn:setPosition(398,470)
self.playBtn:setImagePosition(385,440)
self.playBtn:setPosition(388,470)
self.playBtn:setImagePosition(375,440)
self.playBtn.onClick=function()
self.playBtn:setImageSize(2*100)
end
Expand Down Expand Up @@ -45,7 +45,6 @@ function MainMenuState:tween()
scale=self.scale==.3 and .25 or .3
})
end)
self.r=100
end

function MainMenuState:update(dt)
Expand Down
9 changes: 5 additions & 4 deletions src/Scenes/PlayState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ function PlayState:lose()
flux.tween(board,2,{
op=0
}):oncomplete(function()
gStateMachine:switch('roundOver',{
level=self.scoreBoard.level,
target=self.scoreBoard.targetScore,
time=self.scoreBoard.initialScore
gStateMachine:switch('lose',{
board=self.board,
scoreBoard=self.scoreBoard,
psystem=self.psystem,
guiSystem=self.guiSystem
})
end)
end
1 change: 1 addition & 0 deletions src/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ gStateMachine=StateMachine{
['mainMenu']=function() return MainMenuState() end,
['pause']=function() return PauseState() end,
['roundOver']=function() return RoundOverState() end,
['lose']=function() return LoseState() end,
['play']=function() return PlayState() end
}

Expand Down

0 comments on commit d817bb5

Please sign in to comment.