Skip to content

Commit

Permalink
v1.1.0: gamepad support & trimui ports release
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxzzk115 committed Dec 30, 2024
1 parent b663494 commit 210d241
Show file tree
Hide file tree
Showing 7 changed files with 1,831 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# love build files
*.zip
*.love
[Bb]uild/
[Bb]uild/

# vscode
.vscode/
105 changes: 100 additions & 5 deletions GameStates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end
function menu:keypressed(key)
if key == 'up' then self.arrowState = math.max(start, self.arrowState - 1)
elseif key == 'down' then self.arrowState = math.min(self.arrowState + 1, highScore)
elseif key == 'return' or key == 'enter' or key == 'k' then
elseif key == 'return' or key == 'enter' or key == 'j' or key == 'k' then
if self.arrowState == start then
-- Start game
Gamestate.switch(showNextGoal)
Expand All @@ -57,6 +57,22 @@ function menu:keypressed(key)
end
end

function menu.gamepadpressed(self, joystick, button)
if joystick == gamepad.joystick then
if button == 'dpup' then self.arrowState = math.max(start, self.arrowState - 1)
elseif button == 'dpdown' then self.arrowState = math.min(self.arrowState + 1, highScore)
elseif button == 'start' or button == 'a' or button == 'b' then
if self.arrowState == start then
-- Start game
Gamestate.switch(showNextGoal)
elseif self.arrowState == highScore then
-- Show high score
Gamestate.switch(showHighScore)
end
end
end
end

function menu:update()
-- Update arrow state
if self.arrowState == start then
Expand Down Expand Up @@ -88,6 +104,12 @@ function showHighScore:keypressed(key)
Gamestate.switch(menu)
end

function showHighScore.gamepadpressed(self, joystick, button)
if joystick == gamepad.joystick then
Gamestate.switch(menu)
end
end

function showHighScore:draw()
push:start()
-- Draw BG
Expand All @@ -109,6 +131,12 @@ function showNewHighScore:keypressed(key)
Gamestate.switch(menu)
end

function showNewHighScore.gamepadpressed(self, joystick, button)
if joystick == gamepad.joystick then
Gamestate.switch(menu)
end
end

function showNewHighScore:draw()
push:start()
-- Draw BG
Expand Down Expand Up @@ -262,7 +290,7 @@ function shop:keypressed(key)
if key == 'space' then
-- Finish shopping
self.isPlayerFinishShopping = true
elseif key == 'k' or key == 'return' or key == 'enter' then
elseif key == 'j' or key == 'k' or key == 'return' or key == 'enter' then
-- Buy prop
local prop = self.items[self.selectorIndex]
if prop ~= nil and not self.isPlayerFinishShopping then
Expand Down Expand Up @@ -292,6 +320,42 @@ function shop:keypressed(key)
end
end

function shop.gamepadpressed(self, joystick, button)
if joystick == gamepad.joystick then
if button == 'back' then
-- Finish shopping
self.isPlayerFinishShopping = true
elseif button == 'start' or button == 'a' or button == 'b' then
-- Buy prop
local prop = self.items[self.selectorIndex]
if prop ~= nil and not self.isPlayerFinishShopping then
if player.money >= propsConfig[prop].price then
self.isPlayerBought = true
if sounds['Money']:isPlaying() then
sounds['Money']:stop()
end
sounds['Money']:play()
-- Decrease player's money
player.money = player.money - propsConfig[prop].price
player.money4View = player.money4View - propsConfig[prop].price
-- Take effect
propsConfig[prop].effect(player)
-- Remove
table.remove(self.items, self.selectorIndex)
table.remove(self.selectorInfo, self.selectorIndex)
self.selectorIndex = 1
else
self.dialogueTextContent = "You don't seem to have any money\n:("
end
end
elseif button == 'dpleft' then
self.selectorIndex = math.max(1, self.selectorIndex -1)
elseif button == 'dpright' then
self.selectorIndex = math.min(self.selectorIndex + 1, #self.items)
end
end
end

function shop:update(dt)
self.shopkeeperAnimation:update(dt)

Expand Down Expand Up @@ -383,12 +447,12 @@ function game:leave()
end

function game:keypressed(key)
if key == 'down' or key == 'k' then
if key == 'down' or key == 'j' or key == 'k' then
if not hook.isShowBonus and not hook.isGrabing then
hook.isGrabing = true
sounds['GrabStart']:play()
end
elseif key == 'up' or key == 'u' then
elseif key == 'up' or key == 'u' or key == 'i' then
player:tryUseDynamite()
elseif key == 'space' then
if player:reachGoal() then
Expand Down Expand Up @@ -419,6 +483,23 @@ function game:keypressed(key)
end
end

function game.gamepadpressed(self, joystick, button)
if joystick == gamepad.joystick then
if button == 'dpdown' or button == 'a' or button == 'b' then
if not hook.isShowBonus and not hook.isGrabing then
hook.isGrabing = true
sounds['GrabStart']:play()
end
elseif button == 'dpup' or button == 'x' or button == 'y' then
player:tryUseDynamite()
elseif button == 'back' then
if player:reachGoal() then
Gamestate.switch(showMadeGoal)
end
end
end
end

function game:update(dt)
-- Update player
player:update(dt)
Expand Down Expand Up @@ -479,7 +560,7 @@ function game:draw()
local levelText = love.graphics.newText(gameFont, {COLOR_DEEP_ORANGE, 'Level: ', COLOR_ORANGE, player.level})
love.graphics.draw(levelText, 250, 25)
if player:reachGoal() then
local reachGoalTipText = love.graphics.newText(gameFont, {COLOR_ORANGE, 'Press Select to Exit'})
local reachGoalTipText = love.graphics.newText(gameFont, {COLOR_ORANGE, 'Press Select to Skip'})
love.graphics.draw(reachGoalTipText, 200, 5)
end
if self.isShowBonus then
Expand Down Expand Up @@ -526,6 +607,20 @@ function gameOver:keypressed(key)
end
end

function gameOver.gamepadpressed(self, joystick, button)
if joystick == gamepad.joystick then
if player.money > persistentData.highScore then
persistentData.highScore = player.money
persistentData.highLevel = player.level
serialized = lume.serialize(persistentData)
love.filesystem.write("savedata.txt", serialized)
Gamestate.switch(showNewHighScore)
else
Gamestate.switch(menu)
end
end
end

function gameOver:draw()
push:start()
-- Draw BG
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# GoldMiner-GameShell
# GoldMiner-Rebirth

The classic game remake. Build for GameShell. Made with [LÖVE](https://love2d.org/)(11.1).
The classic game remake. Build for GameShell, Trimui (Smart Pro and Brick) and other LOVE2D compatible gaming handheld devices. Made with [LÖVE](https://love2d.org/)(11.1).

Download the latest Release [here](https://github.com/zzxzzk115/GoldMiner-GameShell/releases/latest).
Download the latest Release [here](https://github.com/zzxzzk115/GoldMiner-Rebirth/releases/latest).

## How to play

| Action | GameShell | PC |
| ---------------------------------------------------------- | ------------------------ | -------------- |
| Exit | Menu button | Escape |
| Menu Confirm or Buy | A button or Start button | Enter |
| Use dynamite | Y button or Up | Up |
| Grab | A button or Down | Down |
| Exit current level when you reach goal or Confirm shopping | Select button | Space |
| Select the shop item you wanna buy | Left and Right | Left and Right |
| Action | GameShell, Trimui & others | PC |
| ------------------------------------------------------------ | -------------------------- | -------------- |
| Exit the game | Menu button | Escape |
| Menu Confirm or Buy items | A/B button or Start button | Enter |
| Throw a dynamite | X/Y button or D-pad Up | Up |
| Release the hook | A/B button or D-pad Down | Down |
| Exit the current level when you reach the goal or Confirm shopping | Select button | Space |
| Select the shop item | D-pad Left and Right | Left and Right |

## Screenshots

Expand Down
5 changes: 5 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes

2024/12/30 v1.0.0:

- Added support for game controllers.
- Added Trimui release.

2022/6/2 v1.0.0-rc:

- Updated README.md
Expand Down
1 change: 1 addition & 0 deletions conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ function love.conf(t)
t.window.borderless = true -- Remove all border visuals from the window (boolean)
t.window.resizable = false -- Let the window be user-resizable (boolean)
t.window.fullscreen = true -- Enable fullscreen (boolean)
-- t.console = true -- Debug only
end
Loading

0 comments on commit 210d241

Please sign in to comment.