Skip to content

Commit

Permalink
Merge pull request #2 from 133794m3r/dev
Browse files Browse the repository at this point in the history
Game's done.
  • Loading branch information
133794m3r authored Dec 19, 2020
2 parents b4eef83 + 281b451 commit d9b4ef6
Show file tree
Hide file tree
Showing 29 changed files with 1,027 additions and 264 deletions.
73 changes: 56 additions & 17 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
---
--- Created by macarthur.
--- DateTime: 11/20/20 8:46 PM
--[[
Falling Blocks game. The final project main code file
Copyright (C) 2020 Macarthur David Inbody <admin-contact@transcendental.us>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
]]

--[[
Version 1.0.0
]]

require 'src/init'

function love.load()
-- I can't let the keyboard repeat due to not being able to modify the delays.
-- The only way I could maybe do this is to manually ignore delay if some timer isn't filled yet.
-- SFX are broken because how fast the keys can repeat.
love.keyboard.setKeyRepeat(true)
-- should be done some other way but I don't know of a good way to do it other than this to make sure it'll work.
gTextString = '_________'
gTextStringLength = 0
Expand Down Expand Up @@ -35,30 +58,45 @@ function love.load()
['high_scores'] = function() return HighScoreMenu() end,
['check_scores'] = function() return CheckScores() end,
['add_score'] = function() return AddHighScore() end,
['help'] = function() return HelpScreen() end,
['help'] = function() return HelpMenu() end,
['main_menu'] = function() return MainMenu() end,
['start_marathon'] = function() return MarathonMode() end,
['start_endless'] = function() return EndlessMode() end,
['time_attack'] = function() return TimeAttack() end,
['settings'] = function() return SettingsMenu() end
}
gHighScores = HighScoreTable()


gCurrentSong = ''

--if love.filesystem.getInfo('high_score_table.dat') then
-- gHighScores = bitser.loadLoveFile('high_score_table.dat')
--else
-- gHighScores = HighScoreTable()
-- bitser.dumpLoveFile('high_score_table.dat',gHighScores)
--
--end
if love.filesystem.getInfo('savedata.dat') then
--gSaveData = SaveData()
gSaveData = SaveData(bitser.loadLoveFile('savedata.dat'))
else
gSaveData = SaveData()
end
love.keyboard.setTextInput(false)

gStateMachine:change('high_scores',{})
gStateMachine:change('title',{})
gMusicMuted = false
end

function love.keypressed(key)
gStateMachine:handleInput(key);
-- too avoid having it trigger when we're doing textual inputs.
-- If we're inputting text no reason to render the inputs.
if not love.keyboard.hasTextInput() then
-- m key is only ever used for muting across all game modes.
if key == 'm' then
gMusicMuted = not gMusicMuted
if gMusic[gCurrentSong]:isPlaying() then
gMusic[gCurrentSong]:pause()
else
gMusic[gCurrentSong]:play()
end
else
gStateMachine:handleInput(key)
end
elseif key == 'enter' or key == 'return' then
gStateMachine:handleInput(key)
end

end

function love.textinput(t)
Expand All @@ -80,6 +118,7 @@ function love.textinput(t)
end

end

function love.update(dt)
gStateMachine:update(dt)
Timer.update(dt)
Expand Down
88 changes: 61 additions & 27 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# Block Falling Game
Following Features(TO be implemented)
Following Features exist in the game. Also it has a save feature where it'll save your settings and also your high scores upon exiting and restarting the game. This data is serialized in a very effecient format. Plus I've added a version string to the savedata so that in the future if I add more options I can initialize the default properties with those items and then resave it in the new format to migrate the save data to a new version.

## Code overview
There are states, and menus. Each menu is a state, and each game mode is also a state.
## Game States
Each game "mode" inherits from the BaseGame State which inherits from the BaseState class. which they then modify for the specific game mode requirements. It also handles all of the basic stuff for them. The game modes then ineherit from this BaseGame state for their own state information.

## Menus
The game menus all inherit from the BaseState class.
Each menu is also interactive and modifies the screen contents depending on what's there.
### Help
This menu has 8 screens of text that can be navigated by either pressing the approriate number or using the left/right arrows. It also highlights which screen of text that you're on and explains the gameplay.
### Main
This is the main menu after pressing enter on the title screen. It lets you select the game mode and also highlights which option you're currently on. When you're on the game mode you can press left/right arrows to change the game mode. And this will select which game mode you'll play upon pressing enter.
### High Score
Same thing here the arrow keys shift between the game mode's high score tables. Also the difficulty that's currently active will show that difficulty level. Pressing left/right will shift through the different tables. It's also entered upon getting a high score or a game over.
### Title
This is the bootup screen. Took way too long to get the title image to look right.
### Settings
For now just does difficulty. In the future may add the option to do classic/dynamic for levels. Also the ability for blocks to drop due to gravity after clearing a line.
### Add Score
This is more of a state than a menu but it's still here. This lets the person enter their name(up to 10 characters) and it will then take them to the new high score table and also save their data.


## The 3 game modes
Also will have 2 types of gameplay "classic" and dynamic.
Also will have 2 difficulties.

### Marathon Mode
This game mode is a race till you get to level 15 and clear it. The goal here is to get the maximum possible score within the 15 levels.
Expand All @@ -13,26 +35,21 @@ The person will play until they fail trying to get as high of a score as possibl
### Time Attack
In this mode the person tries to get 50 lines as fast as possible.

## Classic Vs Dynamic
In classic you have to get 10 lines per level and the amount required to get to the next one. Dynamic is 5* the level you're at. Also the guideline's rules about bonus lines are in effect for dynamic.
## Difficulties
There is an easy and a hard mode. Easy mode has a slower acceleration curve for the drop rate and also gives the person more time before the piece locks into place. "hard" is the default curve and lock timing for pieces.

#Features Done
The features below are my simple way to track these items.

## Modes
- [x] Marathon Mode
- [ ] Endless Mode
- [ ] Time Attack

## Game Types
Classic = 10lines per level. Dynamic = 5*level lines to clear each level.
-[x] Classic
-[ ] Dynamic
- [x] Endless Mode
- [x] Time Attack

## Gameplay Features
-[x] Wall/Floor Kicks
-[x] Gravity Curve
-[ ] Piece Locking after timeout
-[x] Piece Locking after timeout
-[x] 7 Batch RNG
-[x] Held Piece
-[x] Next Piece
Expand All @@ -43,24 +60,24 @@ Classic = 10lines per level. Dynamic = 5*level lines to clear each level.
Basic items for the game itself.

## Menus
-[ ] Main Menu
-[ ] Help Menu
-[ ] Game type selector
-[ ] Difficulty Options
-[ ] Game Mode selector
-[x] Main Menu
-[x] Help Menu
-[x] Game type selector
-[x] Difficulty Options
-[x] Game Mode selector

### States
-[ ] Menu State
-[x] Menu State
-[x] High Score Menu
-[x] Add High Score
-[x] Main Menu
-[ ] Paused state
-[ ] Gameplay state
-[x] Paused state
-[x] Gameplay states
- [x] Marathon Mode
- [ ] Sprint/Time Attack Mode
- [ ] Endless Mode
-[ ] Game over state
-[ ] Countdown state
- [x] Sprint/Time Attack Mode
- [x] Endless Mode
-[x] Game over state
-[x] Countdown state

### Classes
-[x] Game Board
Expand All @@ -70,9 +87,9 @@ Classic = 10lines per level. Dynamic = 5*level lines to clear each level.
Held Piece and Next piece will be instances of said class.

### Music
-[ ] Basic game track
-[ ] Menu track
-[ ] Game over track
-[x] Basic game track
-[x] Menu track
-[x] Game over track


# Licenses
Expand All @@ -89,3 +106,20 @@ Bitser.lua is licensed under MIT license. Repo: https://github.com/gvx/bitser

All other code in this repo by myself is licensed under the GPLv3.


## Music
https://opengameart.org/content/chip-bit-danger by Sudocolon

https://opengameart.org/content/this-game-is-over by mccartneytm

https://opengameart.org/content/space-boss-battle-theme by Matthew Pablo

https://opengameart.org/content/twister-tetris by poinl

https://opengameart.org/content/chiptune-techno by Nicole Marie T

https://opengameart.org/content/let-the-games-begin-0 by section31

## SFX

https://opengameart.org/content/rpg-sound-pack by artisticdude
Binary file modified res/sfx/drop.wav
Binary file not shown.
Binary file modified res/sfx/rotate.wav
Binary file not shown.
65 changes: 54 additions & 11 deletions src/assets.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,77 @@
--[[
Assets file
Copyright (C) 2020 Macarthur David Inbody <admin-contact@transcendental.us>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
]]

-- fonts
gFonts = {
['title'] = love.graphics.newFont(64),
['menu'] = love.graphics.newFont(48),
['sm'] = love.graphics.newFont(20),
['md'] = love.graphics.newFont(26),
['lg'] = love.graphics.newFont(36),
['mono_sm'] = love.graphics.newFont('res/source_code_pro.otf',16),
['mono_md'] = love.graphics.newFont('res/source_code_pro.otf',24),
['mono_lg'] = love.graphics.newFont('res/source_code_pro.otf',36),
['mono_xl'] = love.graphics.newFont('res/source_code_pro.otf',52)
}


-- music
--[[
Sudocolon OGA. Chip Bit Danger will be used for level 14+ on Endless mode/final level of marathon aka level 14.
https://opengameart.org/content/chip-bit-danger
https://opengameart.org/content/this-game-is-over for game over music.
Music is what it's used for, then next line is link to OGA page, and the submitter's name
Chip Bit Danger will be used for level 14+ on Endless mode/final level of marathon aka level 14.
https://opengameart.org/content/chip-bit-danger Sudocolon
for game over music.
https://opengameart.org/content/this-game-is-over mccartneytm
Oribital Colossus will be Time Attack
https://opengameart.org/content/space-boss-battle-theme Matthew Pablo
Title screen/menu music/high score screen music.
https://opengameart.org/content/twister-tetris poinl
https://opengameart.org/content/twister-tetris Title screen/menu music/high score screen music.
https://opengameart.org/content/chiptune-techno Marathon Mode maybe
https://opengameart.org/content/let-the-games-begin-0 Endless Mode
Marathon Mode maybe
https://opengameart.org/content/chiptune-techno Nicole Marie T
Endless Mode
https://opengameart.org/content/let-the-games-begin-0 section31
]]

gMusic ={
['title_music'] = love.audio.newSource('res/music/Twister Tetris.mp3','stream'),
['sprint_theme'] = love.audio.newSource('res/music/Orbital Colossus.mp3','stream'),
['normal_theme'] = love.audio.newSource('S31-Let the Games Begin.ogg','stream'),
['final_countdown'] = love.audio.newSource('Chip Bit Danger.mp3','stream'),
['game_over'] = love.audio.newSource('ThisGameIsOver.ogg','stream'),
['normal_theme'] = love.audio.newSource('res/music/S31-Let the Games Begin.ogg','stream'),
['final_countdown'] = love.audio.newSource('res/music/Chip Bit Danger.mp3','stream'),
['game_over'] = love.audio.newSource('res/music/ThisGameIsOver.ogg','stream'),
}

for k,v in pairs(gMusic) do
-- the default volume for some of them is a bit too much. The db range needs to be normalized.
gMusic[k]:setVolume(0.75)
-- make sure they all are set to loop.
gMusic[k]:setLooping(true)
end

--[[
https://opengameart.org/content/rpg-sound-pack
Sound effects came from this pack but renamed
https://opengameart.org/content/rpg-sound-pack artisticdude
rotate and the block drop sounds.
]]
gSFX = {
Expand Down
25 changes: 25 additions & 0 deletions src/base_state.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--[[
The Base State, may make this be part of the state_machine but I'm unsure atm
Copyright (C) 2020 Macarthur David Inbody <admin-contact@transcendental.us>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
]]

BaseState = Class{}
function BaseState:init() end
function BaseState:enter() end
function BaseState:exit() end
function BaseState:handleInput(key) end
function BaseState:update(dt) end
function BaseState:render() end
Loading

0 comments on commit d9b4ef6

Please sign in to comment.