Skip to content

Commit

Permalink
remove mouse support
Browse files Browse the repository at this point in the history
  • Loading branch information
D0NM committed Sep 1, 2020
1 parent e562883 commit 22e1756
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 296 deletions.
2 changes: 1 addition & 1 deletion conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function love.conf(t)
t.modules.joystick = true -- Enable the joystick module (boolean)
t.modules.keyboard = true -- Enable the keyboard module (boolean)
t.modules.math = true -- Enable the math module (boolean)
t.modules.mouse = true -- Enable the mouse module (boolean)
t.modules.mouse = false -- Enable the mouse module (boolean)
t.modules.physics = false -- Enable the physics module (boolean)
t.modules.sound = true -- Enable the sound module (boolean)
t.modules.system = true -- Enable the system module (boolean)
Expand Down
5 changes: 0 additions & 5 deletions lib/hump/camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ function camera:worldCoords(x,y, ox,oy,w,h)
return x+self.x, y+self.y
end

function camera:mousePosition(ox,oy,w,h)
local mx,my = love.mouse.getPosition()
return self:worldCoords(mx,my, ox,oy,w,h)
end

-- camera scrolling utilities
function camera:lockX(x, smoother, ...)
local dx, dy = (smoother or self.smoother)(x - self.x, self.y, ...)
Expand Down
14 changes: 0 additions & 14 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ end
shaders = require "src/def/misc/shaders"

function setupScreen()
configuration:set("MOUSE_ENABLED", not GLOBAL_SETTING.FULL_SCREEN)
love.mouse.setVisible( GLOBAL_SETTING.MOUSE_ENABLED )
if shaders then
if GLOBAL_SETTING.FILTER_N and shaders.screen[GLOBAL_SETTING.FILTER_N] then
local sh = shaders.screen[GLOBAL_SETTING.FILTER_N]
Expand Down Expand Up @@ -282,15 +280,3 @@ end

function love.keyreleased(key, unicode)
end

function love.mousepressed(x, y, button)
if GLOBAL_SETTING.PROFILER_ENABLED then
Prof:mousepressed(x, y, button)
end
end

function love.mousereleased(x, y, button)
end

function love.wheelmoved( dx, dy )
end
1 change: 0 additions & 1 deletion src/configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ GLOBAL_SETTING = {
MAX_CREDITS = 3,
MAX_LIVES = 3,
TIMER = 99, -- seconds to pass a stage
MOUSE_ENABLED = true,
SHADERS_ENABLED = true,
PROFILER_ENABLED = false,
FPSRATE_ENABLED = false,
Expand Down
4 changes: 2 additions & 2 deletions src/movie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ end

function Movie:update(dt)
self.time = self.time + dt
if self.b.attack:isDown() or love.mouse.isDown(1) then
if self.b.attack:isDown() then
self.time = self.time + dt * 3 -- Speed Up
end
if self.b.back:pressed() or self.b.jump:pressed() or love.mouse.isDown(2) then
if self.b.back:pressed() or self.b.jump:pressed() then
return true -- Interrupt
end
if not self.frames or not self.frames[self.frame] then
Expand Down
39 changes: 3 additions & 36 deletions src/state/optionsState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ local menuItems = {difficulty = 1, video = 2, sound = 3, defaults = 4, spriteVie
local menu = fillMenu(txtItems)

local menuState, oldMenuState = 1, 1
local mouse_x, mouse_y, oldMouse_y = 0, 0, 0

function optionsState:enter()
mouse_x, mouse_y = 0,0
-- Prevent double press at start (e.g. auto confirmation)
Controls[1].attack:update()
Controls[1].jump:update()
Controls[1].start:update()
Controls[1].back:update()
love.graphics.setLineWidth( 2 )
self:wheelmoved(0, 0) --pick 1st sprite to draw
end

function optionsState:resume()
mouse_x, mouse_y = 0,0
end

--Only P1 can use menu / options
Expand All @@ -43,7 +39,7 @@ function optionsState:playerInput(controls)
sfx.play("sfx","menuCancel")
return Gamestate.pop()
elseif controls.attack:pressed() or controls.start:pressed() then
return self:confirm( mouse_x, mouse_y, 1)
return self:confirm(1)
end
if controls.horizontal:pressed(-1)then
self:wheelmoved(0, -1)
Expand Down Expand Up @@ -95,13 +91,6 @@ function optionsState:draw()
end
colors:set("white")
love.graphics.print(m.item, m.x, m.y )

if GLOBAL_SETTING.MOUSE_ENABLED and mouse_y ~= oldMouse_y and
CheckPointCollision(mouse_x, mouse_y, m.rect_x - leftItemOffset, m.y - topItemOffset, m.w + itemWidthMargin, m.h + itemHeightMargin )
then
oldMouse_y = mouse_y
menuState = i
end
end
--header
colors:set("white")
Expand All @@ -110,9 +99,8 @@ function optionsState:draw()
push:finish()
end

function optionsState:confirm( x, y, button, istouch )
function optionsState:confirm(button)
if button == 1 then
mouse_x, mouse_y = x, y
if menuState == menuItems.difficulty then
sfx.play("sfx","menuSelect")
if GLOBAL_SETTING.DIFFICULTY == 1 then
Expand Down Expand Up @@ -159,31 +147,10 @@ function optionsState:confirm( x, y, button, istouch )
end
end

function optionsState:mousepressed( x, y, button, istouch )
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
self:confirm( x, y, button, istouch )
end

function optionsState:mousemoved( x, y, dx, dy)
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
mouse_x, mouse_y = x, y
end

function optionsState:wheelmoved(x, y)
local i = 0
if y > 0 then
i = 1
elseif y < 0 then
i = -1
else
return
end
menu[menuState].n = menu[menuState].n + i
if menuState == menuItems.difficulty then
return self:confirm( mouse_x, mouse_y, 1)
return self:confirm( 1)
end
end
28 changes: 2 additions & 26 deletions src/state/pauseState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ local menuItems = {continue = 1, quickSave = 2, quit = 3}
local menu = fillMenu(txtItems)

local menuState, oldMenuState = 1, 1
local mouse_x, mouse_y, oldMouse_y = 0, 0, 0

function pauseState:enter()
menuState = menuItems.continue
mouse_x, mouse_y = 0,0
bgm.setVolume(GLOBAL_SETTING.BGM_VOLUME * 0.75)
sfx.play("sfx","menuCancel")

Expand All @@ -43,7 +41,7 @@ function pauseState:playerInput(controls)
sfx.play("sfx","menuSelect")
return Gamestate.pop()
elseif controls.attack:pressed() or controls.start:pressed() then
return pauseState:confirm( mouse_x, mouse_y, 1)
return pauseState:confirm(1)
end
if controls.horizontal:pressed(-1) or controls.vertical:pressed(-1) then
menuState = menuState - 1
Expand Down Expand Up @@ -111,13 +109,6 @@ function pauseState:draw()
end
colors:set("white")
love.graphics.print(m.item, m.x, m.y )

if GLOBAL_SETTING.MOUSE_ENABLED and mouse_y ~= oldMouse_y and
CheckPointCollision(mouse_x, mouse_y, m.rect_x - leftItemOffset, m.y - topItemOffset, m.w + itemWidthMargin, m.h + itemHeightMargin )
then
oldMouse_y = mouse_y
menuState = i
end
end
--header
colors:set("darkGray")
Expand All @@ -132,9 +123,8 @@ function pauseState:draw()
push:finish()
end

function pauseState:confirm( x, y, button, istouch )
function pauseState:confirm(button)
if button == 1 then
mouse_x, mouse_y = x, y
if menuState == menuItems.continue then
sfx.play("sfx","menuSelect")
return Gamestate.pop()
Expand All @@ -146,19 +136,5 @@ function pauseState:confirm( x, y, button, istouch )
end
end

function pauseState:mousepressed( x, y, button, istouch )
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
self:confirm( x, y, button, istouch )
end

function pauseState:mousemoved( x, y, dx, dy)
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
mouse_x, mouse_y = x, y
end

function pauseState:keypressed(key, unicode)
end
65 changes: 0 additions & 65 deletions src/state/playerSelectState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ local portraitMargin = 0
local portraitOffset_x = 110
local availableHeroes = 4

local oldMousePos = 0
local mousePos = 0
local playerSelectText = love.graphics.newText( gfx.font.kimberley, "PLAYER SELECT" )

local heroes = {
Expand Down Expand Up @@ -255,7 +253,6 @@ local function selected_heroes()
elseif s3[1] == s1[1] and players[3].visible and players[1].visible then
s3[2] = s1[2] + 1
end

--x shift to center P indicator
if players[1].visible then
xshift[players[1].pos] = xshift[players[1].pos] + 1
Expand Down Expand Up @@ -304,8 +301,6 @@ local function drawPID(x, y_, i, confirmed)
end

function playerSelectState:enter()
oldMousePos = 0
mousePos = 0
self:initDefaultPlayersSelectionOrder()
for i = 1, availableHeroes do
setSpriteAnimation(heroes[i].sprite_portrait, heroes[i].sprite_portraitAnim)
Expand Down Expand Up @@ -490,66 +485,6 @@ function playerSelectState:draw()
push:finish()
end

function playerSelectState:confirm( x, y, button, istouch )
-- P1 mouse control only
if button == 1 then
mousePos = clamp(math.round(x /(screenWidth / 4) + 0.5), 1, 4)
if not players[1].visible then
players[1].visible = true
sfx.play("sfx","menuSelect")
setSpriteAnimation(players[1].sprite,heroes[players[1].pos].defaultAnim)
elseif not players[1].confirmed then
if players[1].pos ~= mousePos then
oldMousePos = players[1].pos
players[1].pos = mousePos
players[1].sprite = getSpriteInstance(heroes[players[1].pos].spriteInstance)
players[1].sprite.sizeScale = 2
end
players[1].confirmed = true
sfx.play("sfx","menuSelect")
setSpriteAnimation(players[1].sprite,heroes[players[1].pos].confirmAnim)
elseif mousePos == players[1].pos and allConfirmed() then
self:GameStart()
return
end
elseif button == 2 then
sfx.play("sfx","menuCancel")
if players[1].visible and not players[1].confirmed then
players[1].visible = false
elseif players[1].confirmed then
players[1].confirmed = false
setSpriteAnimation(players[1].sprite,heroes[players[1].pos].cancelAnim)
else
return Gamestate.pop()
end
end
end

function playerSelectState:mousepressed( x, y, button, istouch )
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
self:confirm( x, y, button, istouch )
end

function playerSelectState:mousemoved( x, y, dx, dy)
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
mousePos = clamp(math.round(x /(screenWidth / 4) + 0.5), 1, 4)
if mousePos ~= oldMousePos and players[1].visible and not players[1].confirmed then
oldMousePos = mousePos
players[1].pos = mousePos
sfx.play("sfx","menuMove")
players[1].sprite = getSpriteInstance(heroes[players[1].pos].spriteInstance)
players[1].sprite.sizeScale = 2
setSpriteAnimation(players[1].sprite,heroes[players[1].pos].defaultAnim)
end
end

function playerSelectState:keypressed(key, unicode)
end

function playerSelectState:confirmAllPlayers()
--visible players confirmed their choice
for i = 1,#players do
Expand Down
29 changes: 3 additions & 26 deletions src/state/soundState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ local volumeStep = 0.10
local menu = fillMenu(txtItems)

local menuState, oldMenuState = 1, 1
local mouse_x, mouse_y, oldMouse_y = 0, 0, 0

function soundState:enter()
mouse_x, mouse_y = 0,0
-- Prevent double press at start (e.g. auto confirmation)
Controls[1].attack:update()
Controls[1].jump:update()
Expand All @@ -39,9 +37,9 @@ end
--Only P1 can use menu / options
function soundState:playerInput(controls)
if controls.jump:pressed() or controls.back:pressed() then
return self:confirm( mouse_x, mouse_y, 2)
return self:confirm( 2)
elseif controls.attack:pressed() or controls.start:pressed() then
return self:confirm( mouse_x, mouse_y, 1)
return self:confirm(1)
end
if controls.horizontal:pressed(-1)then
self:wheelmoved(0, -1)
Expand Down Expand Up @@ -106,13 +104,6 @@ function soundState:draw()
end
colors:set("white")
love.graphics.print(m.item, m.x, m.y )

if GLOBAL_SETTING.MOUSE_ENABLED and mouse_y ~= oldMouse_y and
CheckPointCollision(mouse_x, mouse_y, m.rect_x - leftItemOffset, m.y - topItemOffset, m.w + itemWidthMargin, m.h + itemHeightMargin )
then
oldMouse_y = mouse_y
menuState = i
end
end
--header
colors:set("white")
Expand All @@ -121,7 +112,7 @@ function soundState:draw()
push:finish()
end

function soundState:confirm( x, y, button, istouch )
function soundState:confirm(button)
if (button == 1 and menuState == #menu) or button == 2 then
sfx.play("sfx","menuCancel")
bgm.play(bgm.title)
Expand Down Expand Up @@ -167,20 +158,6 @@ function soundState:confirm( x, y, button, istouch )
end
end

function soundState:mousepressed( x, y, button, istouch )
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
self:confirm( x, y, button, istouch )
end

function soundState:mousemoved( x, y, dx, dy)
if not GLOBAL_SETTING.MOUSE_ENABLED then
return
end
mouse_x, mouse_y = x, y
end

function soundState:wheelmoved(x, y)
local i = 0
if y > 0 then
Expand Down
Loading

0 comments on commit 22e1756

Please sign in to comment.