Skip to content

Commit e564bc3

Browse files
author
Joash Chee
committed
Implemented blinking cursor for Visualizer
1 parent 1d5c57b commit e564bc3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

game/main.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ require("lib.Music")
3636
require("lib.WriteAiff")
3737

3838
local oneSecTimer = 0 -- used for the one second timer in update(dt)
39+
local currentFrame = 0 -- init currentFrame
3940

4041
local game = {}
4142

@@ -1734,6 +1735,8 @@ function love.draw()
17341735
love.graphics.print(visualizerTop,FONT_WIDTH*0,FONT_HEIGHT*30) -- divider : Visualizer top
17351736
love.graphics.print(visualizerBottom,FONT_WIDTH*0,FONT_HEIGHT*43) -- divider : Visualizer bottom
17361737

1738+
1739+
love.graphics.setColor(color.white)
17371740
love.graphics.print(dividerMML,FONT_WIDTH*80,FONT_HEIGHT*30) -- divider : MML
17381741
love.graphics.print(textWindowBlank,FONT_WIDTH*80,FONT_HEIGHT*31) -- text window right : blank
17391742
-- draw meta data
@@ -2015,6 +2018,13 @@ function love.draw()
20152018
love.graphics.print(SML.screen[game.selected["pattern"]][game.selected["vizPage"]],FONT_WIDTH*0,FONT_HEIGHT*31)
20162019
end
20172020

2021+
-- show visualizer cursor
2022+
if VIZ.mouseX > 0 and VIZ.mouseY > 0 then
2023+
-- show blinking cursor
2024+
love.graphics.setColor(oneSecTimer/1,oneSecTimer/1,oneSecTimer/1,oneSecTimer/1)
2025+
love.graphics.print("",FONT_WIDTH*(VIZ.mouseX-1),FONT_HEIGHT*(VIZ.mouseY+30))
2026+
2027+
end
20182028

20192029

20202030

@@ -2076,7 +2086,7 @@ elseif game.selected["section"] == "sequence" then
20762086
else
20772087
game.debug3 = ""
20782088
end
2079-
game.debug4 = ""
2089+
game.debug4 = "currentFrame: "..currentFrame.." | ".."timer: "..oneSecTimer
20802090
-- draw debug info
20812091
love.graphics.setColor(color.yellow)
20822092
love.graphics.print(game.debug1,FONT_WIDTH*0,FONT_HEIGHT*46)
@@ -2090,11 +2100,10 @@ function love.update(dt)
20902100
-- Your game update here
20912101

20922102
-- oneSecTimer code for simple frame animation
2093-
local currentFrame = 0 -- init currentFrame
2103+
oneSecTimer = oneSecTimer + dt
20942104
if oneSecTimer < 1/4 then
20952105
currentFrame = 1
20962106
end
2097-
oneSecTimer = oneSecTimer + dt
20982107
if oneSecTimer > 1/4 and currentFrame == 1 then
20992108
currentFrame = 2
21002109
end

0 commit comments

Comments
 (0)