Compare commits
127 Commits
Author | SHA1 | Date |
---|---|---|
Ishaan Bhardwaj | d0fdaf30ab | |
Aymir Dmitrievich Danilov | 8062f6e3fa | |
Ishaan Bhardwaj | 7c3cf0b1bd | |
aur9ra | 52ddbbc174 | |
Ishaan Bhardwaj | 5f81c35677 | |
Tetro48 | 635ef6270f | |
Tetro48 | 649dd5f31d | |
Ishaan Bhardwaj | 34fcc3f659 | |
Kirby703 | 4caa268adc | |
Ishaan Bhardwaj | a79552a6f3 | |
Ishaan Bhardwaj | cd90405865 | |
Ishaan Bhardwaj | e69659b2ad | |
Ishaan Bhardwaj | d90e382037 | |
infinifen | ba6f5bb837 | |
Ishaan Bhardwaj | 39e9dc3303 | |
Ishaan Bhardwaj | a1f0dfd9f2 | |
Ishaan Bhardwaj | 2a21484137 | |
Ishaan Bhardwaj | 50410958f0 | |
Ishaan Bhardwaj | 6fb583e463 | |
Ishaan Bhardwaj | 91c8dc3dcc | |
Ishaan Bhardwaj | 2166a3c6d8 | |
Ishaan Bhardwaj | 1556b247fe | |
Ishaan Bhardwaj | 23d9feb357 | |
Ishaan Bhardwaj | c693871621 | |
aur9ra | 2ba3611c56 | |
aur9ra | 602e7105ab | |
Ishaan Bhardwaj | 7199aa7ef6 | |
Ishaan Bhardwaj | a972c31d9a | |
aur9ra | 02f314997d | |
aur9ra | 4769daedf4 | |
aur9ra | 4478c07acf | |
Ishaan Bhardwaj | 52d4aeb3d0 | |
Ishaan Bhardwaj | 91279c9f38 | |
Ishaan Bhardwaj | 0572803627 | |
Tetro48 | 1fef7b4880 | |
Ishaan Bhardwaj | e09b044de4 | |
Kirby703 | 7d6f783c40 | |
Ishaan Bhardwaj | 9d365f61a7 | |
Kirby703 | 082697c3cd | |
Ishaan Bhardwaj | 788aa11470 | |
Ishaan Bhardwaj | a303e82b90 | |
Ishaan Bhardwaj | b06d03c4e6 | |
Ishaan Bhardwaj | a6b8abff6d | |
Kirby703 | bdc317c3c5 | |
Ishaan Bhardwaj | 71c9147a2c | |
Kirby703 | 79d706a415 | |
Ishaan Bhardwaj | 5fa144f146 | |
Ishaan Bhardwaj | 244e67074d | |
Ishaan Bhardwaj | 4b456cf49c | |
Ishaan Bhardwaj | 9a67a6ce03 | |
Ishaan Bhardwaj | df19129228 | |
--global | 80de771d2a | |
--global | 7c32273971 | |
--global | 9d5dbb4674 | |
Ishaan Bhardwaj | 8d7ccae2bc | |
Ishaan Bhardwaj | 1e06a1ce8a | |
Ishaan Bhardwaj | d24fff5bdc | |
Ishaan Bhardwaj | e34005093c | |
Ishaan Bhardwaj | 3dc8b1214b | |
Ishaan Bhardwaj | 5d2da1b4fb | |
Ishaan Bhardwaj | f786bda9dd | |
Ishaan Bhardwaj | 3f789210a6 | |
Ishaan Bhardwaj | a7e7ac43a6 | |
Ishaan Bhardwaj | 5dc72037ec | |
Oshisaure | e5cb69df43 | |
Oshisaure | 3e68af6a5b | |
Oshisaure | 8e6a760fe7 | |
Joe Zeng | a4b7a41a15 | |
nightmareci | aa9e03506b | |
hebo-MAI | 40ac08c7e5 | |
Joe Zeng | 323c457809 | |
Joe Zeng | decc1f563f | |
Kirby703 | 63823ed4b1 | |
Tetro48 | d7c83b0bc7 | |
nightmareci | e5892c0fae | |
--global | 23a8c400ba | |
--global | bfbba75f17 | |
--global | 27e699841e | |
--global | fac8c6584e | |
Tetro48 | d868e8b803 | |
Oshisaure | 9e447d51a7 | |
JDV | 4dfa234bc3 | |
Kirby703 | 47863175a3 | |
Kirby703 | 8730261a78 | |
Kirby703 | 703ce66c42 | |
Ishaan Bhardwaj | 92d67968f5 | |
Ishaan Bhardwaj | d68bd13d2a | |
Ishaan Bhardwaj | a84335646d | |
Ishaan Bhardwaj | d46973f12d | |
Ishaan Bhardwaj | d4360b3662 | |
Ishaan Bhardwaj | 06225bd35a | |
Ishaan Bhardwaj | e68238cbce | |
Ishaan Bhardwaj | 83e197b5d6 | |
Ishaan Bhardwaj | 1c0b73987d | |
Ishaan Bhardwaj | afe6a43dab | |
Ishaan Bhardwaj | 47a5a53e23 | |
Ishaan Bhardwaj | b9ae08051a | |
Ishaan Bhardwaj | d7f4aa2007 | |
Ishaan Bhardwaj | ca85107063 | |
Ishaan Bhardwaj | fdcec19d56 | |
Ishaan Bhardwaj | 89c7205347 | |
Ishaan Bhardwaj | 9b41e56135 | |
Ishaan Bhardwaj | 710f658540 | |
BoatsandJoes | 332e3869de | |
BoatsandJoes | febd1de0ef | |
BoatsandJoes | 81ab7cd4de | |
BoatsandJoes | a5750e4959 | |
BoatsandJoes | 59c7834c9a | |
BoatsandJoes | 71ada76a00 | |
BoatsandJoes | 6c4551ebef | |
Ishaan Bhardwaj | 9fc7e4b1eb | |
BoatsandJoes | 9e59c158b2 | |
BoatsandJoes | e464307625 | |
BoatsandJoes | 888312c578 | |
Ishaan Bhardwaj | a838294435 | |
BoatsandJoes | 049806d9e2 | |
Ishaan Bhardwaj | c1693524d7 | |
Ishaan Bhardwaj | a063f10d33 | |
Ishaan Bhardwaj | 6e0b5e27c1 | |
Joe Zeng | 18e0e02c76 | |
Ishaan Bhardwaj | 9381091110 | |
Ishaan Bhardwaj | deb69fe28d | |
Kirby703 | 3085b765e5 | |
hailey | 412405c1a1 | |
Ishaan Bhardwaj | 7495c4ad04 | |
Ishaan Bhardwaj | 0fce4b632f | |
Ishaan Bhardwaj | aa56248e34 |
|
@ -57,13 +57,13 @@ Coding conventions
|
|||
Use tabs to indent, spaces to align.
|
||||
|
||||
* Specifically, spaces should not appear at the beginning of a line, and tabs should not appear _except_ at the beginning of a line.
|
||||
* The sole exception is in a multiline `if` statement; the initial `if` should have four spaces before it to align it with an `elseif` on the next line. For example:
|
||||
* If you're aligning multiline if-statements, the initial "if", "elseif" or "else" should be flush left with the indentation level, with spaces padding the gap to the next word as necessary. For example:
|
||||
|
||||
```lua
|
||||
---- 4 spaces
|
||||
if self.level < 900 then return 12
|
||||
elseif self.level < 1200 then return 8
|
||||
else return 6 end
|
||||
if self.level < 900 then return 12
|
||||
elseif self.level < 1200 then return 8
|
||||
else return 6
|
||||
end
|
||||
```
|
||||
|
||||
Comments at the end of lines of code must be one line long. Multi-line comments must appear in their own block.
|
||||
|
|
17
README.md
17
README.md
|
@ -5,7 +5,7 @@ Cambridge
|
|||
|
||||
Welcome to Cambridge, the next open-source falling-block game engine!
|
||||
|
||||
The project is written and maintained exclusively by [Milla](https://github.com/MillaBasset), [joezeng](https://github.com/joezeng) and [Oshisaure](https://github.com/oshisaure)!
|
||||
The project is written and maintained exclusively by [Milla](https://github.com/MillaBasset), [joezeng](https://github.com/joezeng) and [Oshisaure](https://github.com/oshisaure)!
|
||||
|
||||
The Discord server has been reopened! https://discord.gg/AADZUmgsph
|
||||
|
||||
|
@ -16,23 +16,23 @@ Playing the game
|
|||
|
||||
### Windows
|
||||
|
||||
You do not need LÖVE on Windows, as it comes bundled with the program.
|
||||
You do not need LÖVE on Windows, as it comes bundled with the program.
|
||||
|
||||
#### Stable release
|
||||
|
||||
To get the stable release, simply download either `cambridge-win32.zip` (32-bit) or `cambridge-windows.zip` (64-bit) in the [latest release](https://github.com/MillaBasset/cambridge/releases/latest).
|
||||
To get the stable release, simply download either `cambridge-win32.zip` (32-bit) or `cambridge-windows.zip` (64-bit) in the [latest release](https://github.com/MillaBasset/cambridge/releases/latest).
|
||||
|
||||
All assets needed are bundled with the executable.
|
||||
|
||||
#### Bleeding edge
|
||||
|
||||
If you want the bleeding edge version, download [this](https://github.com/MillaBasset/cambridge/archive/master.zip).
|
||||
If you want the bleeding edge version, download [this](https://github.com/MillaBasset/cambridge/archive/master.zip). Extract the ZIP to a folder of your choosing.
|
||||
|
||||
Extract the ZIP, open a Command Prompt at the folder you extracted Cambridge to, then run this command:
|
||||
If you're on Windows, you can double-click `start.bat` to run the game. If that doesn't work, open a Command Prompt where you extracted Cambridge and run:
|
||||
|
||||
dist\windows\love.exe .
|
||||
|
||||
Alternatively, if you're on a 32-bit system, run this instead:
|
||||
If that doesn't work, run this instead, still using Command Prompt where you extracted Cambridge:
|
||||
|
||||
dist\win32\love.exe .
|
||||
|
||||
|
@ -42,7 +42,7 @@ Then, check the mod pack section at the bottom of this page.
|
|||
|
||||
### macOS, Linux
|
||||
|
||||
If you haven't already, install `love` with your favourite package manager (Homebrew on macOS, your system's default on Linux). **Make sure you're using LÖVE 11, because it won't work with earlier versions!**
|
||||
If you haven't already, install `love` with your favourite package manager (Homebrew on macOS, your system's default on Linux). **Make sure you're using LÖVE 11.3, because it won't work with earlier or later versions!**
|
||||
|
||||
#### Downloading a release
|
||||
|
||||
|
@ -102,10 +102,9 @@ Other Notable Games
|
|||
- [Tetra Online](https://github.com/Juan-Cartes/Tetra-Offline) by Mine
|
||||
- [Techmino](https://discord.gg/6Yuww44tq8) by MrZ
|
||||
- [Example Block Game](https://github.com/oshisaure/example-block-game) by Oshisaure
|
||||
- [TETR.IO](https://tetr.io) by osk
|
||||
- [Master of Blocks](https://discord.gg/72FZ49mjWh) by Phoenix Flare
|
||||
- [Spirit Drop](https://rayblastgames.com/spiritdrop.php) by RayRay26
|
||||
- [Puzzle Trial](https://kagamine-rin.itch.io/puzzle-trial) by Rin
|
||||
- [stackfuse](https://github.com/sinefuse/stackfuse) by sinefuse
|
||||
|
||||
![Cambridge Logo](https://cdn.discordapp.com/attachments/625496179433668635/763363717730664458/Icon_2.png)
|
||||
![Cambridge Logo](https://cdn.discordapp.com/attachments/827186653772644452/1077674343544393820/Icon_2.png)
|
||||
|
|
|
@ -60,6 +60,9 @@ function formatTime(frames)
|
|||
min = math.floor(frames/3600)
|
||||
sec = math.floor(frames/60) % 60
|
||||
hund = math.floor(frames/.6) % 100
|
||||
if frames == 15641 then
|
||||
hund = math.ceil(frames/.6) % 100
|
||||
end
|
||||
str = string.format("%02d:%02d.%02d", min, sec, hund)
|
||||
return str
|
||||
end
|
||||
|
|
30
load/bgm.lua
30
load/bgm.lua
|
@ -6,14 +6,17 @@ bgm = {
|
|||
}
|
||||
|
||||
local current_bgm = nil
|
||||
local pitch = 1
|
||||
local bgm_locked = false
|
||||
local unfocused = false
|
||||
|
||||
function switchBGM(sound, subsound)
|
||||
if bgm_locked then
|
||||
return
|
||||
end
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:stop()
|
||||
end
|
||||
if bgm_locked or config.bgm_volume <= 0 then
|
||||
if config.bgm_volume <= 0 then
|
||||
current_bgm = nil
|
||||
elseif sound ~= nil then
|
||||
if subsound ~= nil then
|
||||
|
@ -67,25 +70,28 @@ function processBGMFadeout(dt)
|
|||
fadeout_time = 0
|
||||
fading_bgm = false
|
||||
end
|
||||
current_bgm:setVolume(fadeout_time * config.bgm_volume / total_fadeout_time)
|
||||
current_bgm:setVolume(
|
||||
fadeout_time * config.bgm_volume / total_fadeout_time
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function pauseBGM(f)
|
||||
if f then
|
||||
unfocused = true
|
||||
end
|
||||
function pauseBGM()
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:pause()
|
||||
end
|
||||
end
|
||||
|
||||
function resumeBGM(f)
|
||||
if f and scene.paused and unfocused then
|
||||
unfocused = false
|
||||
return
|
||||
end
|
||||
function resumeBGM()
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:play()
|
||||
current_bgm:setPitch(pitch)
|
||||
end
|
||||
end
|
||||
|
||||
function pitchBGM(new_pitch)
|
||||
pitch = new_pitch
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:setPitch(pitch)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,8 +26,18 @@ font_3x5_4 = love.graphics.newImageFont(
|
|||
-4
|
||||
)
|
||||
|
||||
font_8x11 = love.graphics.newImageFont(
|
||||
"res/fonts/8x11_medium.png",
|
||||
"0123456789:.",
|
||||
-- this would be font_8x11 with the other one as 8x11_2
|
||||
-- but that would break compatibility :(
|
||||
font_8x11_small = love.graphics.newImageFont(
|
||||
"res/fonts/8x11.png",
|
||||
" 0123456789:;.,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ..
|
||||
"?!/\\^@$%<=>()*-+[]_&",
|
||||
1
|
||||
)
|
||||
|
||||
font_8x11 = love.graphics.newImageFont(
|
||||
"res/fonts/8x11_medium.png",
|
||||
" 0123456789:;.,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ..
|
||||
"?!/\\^@$%<=>()*-+[]_&",
|
||||
1
|
||||
)
|
||||
|
|
|
@ -1,30 +1,106 @@
|
|||
backgrounds = {
|
||||
[0] = love.graphics.newImage("res/backgrounds/0.png"),
|
||||
love.graphics.newImage("res/backgrounds/100.png"),
|
||||
love.graphics.newImage("res/backgrounds/200.png"),
|
||||
love.graphics.newImage("res/backgrounds/300.png"),
|
||||
love.graphics.newImage("res/backgrounds/400.png"),
|
||||
love.graphics.newImage("res/backgrounds/500.png"),
|
||||
love.graphics.newImage("res/backgrounds/600.png"),
|
||||
love.graphics.newImage("res/backgrounds/700.png"),
|
||||
love.graphics.newImage("res/backgrounds/800.png"),
|
||||
love.graphics.newImage("res/backgrounds/900.png"),
|
||||
love.graphics.newImage("res/backgrounds/1000.png"),
|
||||
love.graphics.newImage("res/backgrounds/1100.png"),
|
||||
love.graphics.newImage("res/backgrounds/1200.png"),
|
||||
love.graphics.newImage("res/backgrounds/1300.png"),
|
||||
love.graphics.newImage("res/backgrounds/1400.png"),
|
||||
love.graphics.newImage("res/backgrounds/1500.png"),
|
||||
love.graphics.newImage("res/backgrounds/1600.png"),
|
||||
love.graphics.newImage("res/backgrounds/1700.png"),
|
||||
love.graphics.newImage("res/backgrounds/1800.png"),
|
||||
love.graphics.newImage("res/backgrounds/1900.png"),
|
||||
title = love.graphics.newImage("res/backgrounds/title.png"),
|
||||
title_night = love.graphics.newImage("res/backgrounds/title-night.jpg"),
|
||||
snow = love.graphics.newImage("res/backgrounds/snow.png"),
|
||||
input_config = love.graphics.newImage("res/backgrounds/options-input.png"),
|
||||
game_config = love.graphics.newImage("res/backgrounds/options-game.png"),
|
||||
named_backgrounds = {
|
||||
"title", "title_no_icon", "title_night",
|
||||
"snow", "options_input", "options_game"
|
||||
}
|
||||
current_playing_bgs = {}
|
||||
extended_bgs = {}
|
||||
image_formats = {".jpg", ".png"}
|
||||
bgpath = "res/backgrounds/"
|
||||
dir = love.filesystem.getDirectoryItems(bgpath)
|
||||
|
||||
backgrounds = {}
|
||||
|
||||
local function loadExtendedBgs()
|
||||
extended_bgs = require("res.backgrounds.extend_section_bg")
|
||||
end
|
||||
|
||||
-- error handling for if there is no extend_section_bg
|
||||
if pcall(loadExtendedBgs) then end
|
||||
|
||||
-- helper method to populate backgrounds
|
||||
local function createBackgroundIfExists(name, file_name)
|
||||
local format_index = 1
|
||||
|
||||
-- see if background is an extension of another background
|
||||
if extended_bgs[file_name] ~= nil then
|
||||
copy_bg = extended_bgs[file_name]
|
||||
copy_bg = copy_bg / 100
|
||||
backgrounds[name] = backgrounds[copy_bg]
|
||||
return true
|
||||
end
|
||||
|
||||
-- try creating image backgrounds
|
||||
while format_index <= #image_formats do
|
||||
for num, existing_file in pairs(dir) do
|
||||
if existing_file == (file_name..image_formats[format_index]) then
|
||||
local tempBgPath = bgpath .. file_name .. image_formats[format_index]
|
||||
backgrounds[name] = love.graphics.newImage(tempBgPath)
|
||||
return true
|
||||
end
|
||||
end
|
||||
format_index = format_index + 1
|
||||
end
|
||||
|
||||
-- try creating video background
|
||||
if love.filesystem.getInfo(bgpath .. file_name .. ".ogv") then
|
||||
for num, existing_file in pairs(dir) do
|
||||
if existing_file == (file_name..".ogv") then
|
||||
local tempBgPath = bgpath .. file_name .. ".ogv"
|
||||
backgrounds[name] = love.graphics.newVideo(
|
||||
tempBgPath, {["audio"] = false}
|
||||
)
|
||||
-- you can set audio to true, but the video will not loop
|
||||
-- properly if audio extends beyond video frames
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function stopOtherBgs(bg)
|
||||
if #current_playing_bgs == 0 and bg:typeOf("Video") then
|
||||
current_playing_bgs[#current_playing_bgs+1] = bg
|
||||
end
|
||||
|
||||
if #current_playing_bgs >= 1 then
|
||||
while current_playing_bgs[1] ~= bg and #current_playing_bgs >= 1 do
|
||||
current_playing_bgs[1]:pause()
|
||||
current_playing_bgs[1]:rewind()
|
||||
table.remove(current_playing_bgs, 1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function fetchBackgroundAndLoop(id)
|
||||
bg = backgrounds[id]
|
||||
|
||||
if bg:typeOf("Video") and not bg:isPlaying() then
|
||||
bg:rewind()
|
||||
bg:play()
|
||||
end
|
||||
|
||||
stopOtherBgs(bg)
|
||||
|
||||
return bg
|
||||
end
|
||||
|
||||
-- create section backgrounds
|
||||
local section = 0
|
||||
while (createBackgroundIfExists(section, section*100)) do
|
||||
section = section + 1
|
||||
end
|
||||
|
||||
-- create named backgrounds
|
||||
local nbgIndex = 1
|
||||
while nbgIndex <= #named_backgrounds do
|
||||
createBackgroundIfExists(
|
||||
named_backgrounds[nbgIndex],
|
||||
string.gsub(named_backgrounds[nbgIndex], "_", "-")
|
||||
)
|
||||
nbgIndex = nbgIndex + 1
|
||||
end
|
||||
|
||||
-- in order, the colors are:
|
||||
-- red, orange, yellow, green, cyan, blue
|
||||
|
@ -121,4 +197,17 @@ misc_graphics = {
|
|||
strike = love.graphics.newImage("res/img/strike.png"),
|
||||
santa = love.graphics.newImage("res/img/santa.png"),
|
||||
icon = love.graphics.newImage("res/img/cambridge_transparent.png")
|
||||
}
|
||||
}
|
||||
|
||||
-- utility function to allow any size background to be used
|
||||
-- this will stretch the background to 4:3 aspect ratio
|
||||
function drawBackground(id)
|
||||
local bg_object = fetchBackgroundAndLoop(id)
|
||||
local width = bg_object:getWidth()
|
||||
local height = bg_object:getHeight()
|
||||
love.graphics.draw(
|
||||
bg_object,
|
||||
0, 0, 0,
|
||||
640 / width, 480 / height
|
||||
)
|
||||
end
|
|
@ -1 +1 @@
|
|||
version = "v0.3"
|
||||
version = "v0.3.4"
|
74
main.lua
74
main.lua
|
@ -1,5 +1,4 @@
|
|||
function love.load()
|
||||
math.randomseed(os.time())
|
||||
highscores = {}
|
||||
love.graphics.setDefaultFilter("linear", "nearest")
|
||||
require "load.rpc"
|
||||
|
@ -24,6 +23,11 @@ function love.load()
|
|||
-- used for screenshots
|
||||
GLOBAL_CANVAS = love.graphics.newCanvas()
|
||||
|
||||
-- aliasing to prevent people using math.random by accident
|
||||
math.random = love.math.random
|
||||
math.randomseed = love.math.setRandomSeed
|
||||
math.randomseed(os.time())
|
||||
|
||||
-- init config
|
||||
initConfig()
|
||||
|
||||
|
@ -35,6 +39,8 @@ function love.load()
|
|||
end
|
||||
|
||||
function initModules()
|
||||
-- replays are not loaded here, but they are cleared
|
||||
replays = {}
|
||||
game_modes = {}
|
||||
mode_list = love.filesystem.getDirectoryItems("tetris/modes")
|
||||
for i=1,#mode_list do
|
||||
|
@ -78,7 +84,10 @@ function love.draw()
|
|||
if config.gamesettings.display_gamemode == 1 or scene.title == "Title" then
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.printf(version, 0, 460, 635, "right")
|
||||
love.graphics.printf(
|
||||
string.format("%.2f", 1.0 / love.timer.getAverageDelta()) ..
|
||||
"fps - " .. version, 0, 460, 635, "right"
|
||||
)
|
||||
end
|
||||
|
||||
love.graphics.pop()
|
||||
|
@ -104,8 +113,8 @@ function love.keypressed(key, scancode)
|
|||
saveConfig()
|
||||
scene.restart_message = true
|
||||
if config.secret then playSE("mode_decide")
|
||||
else playSE("erase") end
|
||||
-- f12 is reserved for saving screenshots
|
||||
else playSE("erase", "single") end
|
||||
-- f12 is reserved for saving screenshots
|
||||
elseif scancode == "f12" then
|
||||
local ss_name = os.date("ss/%Y-%m-%d_%H-%M-%S.png")
|
||||
local info = love.filesystem.getInfo("ss", "directory")
|
||||
|
@ -113,7 +122,7 @@ function love.keypressed(key, scancode)
|
|||
love.filesystem.remove("ss")
|
||||
love.filesystem.createDirectory("ss")
|
||||
end
|
||||
print("Saving screenshot as "..ss_name)
|
||||
print("Saving screenshot as "..love.filesystem.getSaveDirectory().."/"..ss_name)
|
||||
GLOBAL_CANVAS:newImageData():encode("png", ss_name)
|
||||
-- function keys are reserved
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
||||
|
@ -271,21 +280,17 @@ function love.wheelmoved(x, y)
|
|||
scene:onInputPress({input=nil, type="wheel", x=x, y=y})
|
||||
end
|
||||
|
||||
function love.focus(f)
|
||||
if f then
|
||||
resumeBGM(true)
|
||||
else
|
||||
pauseBGM(true)
|
||||
end
|
||||
end
|
||||
|
||||
function love.resize(w, h)
|
||||
GLOBAL_CANVAS:release()
|
||||
GLOBAL_CANVAS = love.graphics.newCanvas(w, h)
|
||||
GLOBAL_CANVAS:release()
|
||||
GLOBAL_CANVAS = love.graphics.newCanvas(w, h)
|
||||
end
|
||||
|
||||
-- higher values of TARGET_FPS will make the game run "faster"
|
||||
-- since the game is mostly designed for 60 FPS
|
||||
local TARGET_FPS = 60
|
||||
local FRAME_DURATION = 1.0 / TARGET_FPS
|
||||
|
||||
-- custom run function; optimizes game by syncing draw/update calls
|
||||
function love.run()
|
||||
if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
|
||||
|
||||
|
@ -294,7 +299,7 @@ function love.run()
|
|||
local dt = 0
|
||||
|
||||
local last_time = love.timer.getTime()
|
||||
local time_accumulator = 0
|
||||
local time_accumulator = 0.0
|
||||
return function()
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
|
@ -314,25 +319,40 @@ function love.run()
|
|||
|
||||
if scene and scene.update and love.timer then
|
||||
scene:update()
|
||||
|
||||
local frame_duration = 1.0 / TARGET_FPS
|
||||
if time_accumulator < frame_duration then
|
||||
|
||||
if time_accumulator < FRAME_DURATION then
|
||||
if love.graphics and love.graphics.isActive() and love.draw then
|
||||
love.graphics.origin()
|
||||
love.graphics.clear(love.graphics.getBackgroundColor())
|
||||
love.draw()
|
||||
love.graphics.present()
|
||||
end
|
||||
local end_time = last_time + frame_duration
|
||||
local time = love.timer.getTime()
|
||||
while time < end_time do
|
||||
love.timer.sleep(0.001)
|
||||
time = love.timer.getTime()
|
||||
|
||||
-- request 1ms delays first but stop short of overshooting, then do "0ms" delays without overshooting (0ms requests generally do a delay of some nonzero amount of time, but maybe less than 1ms)
|
||||
for milliseconds=0.001,0.000,-0.001 do
|
||||
local max_delay = 0.0
|
||||
while max_delay < FRAME_DURATION do
|
||||
local delay_start_time = love.timer.getTime()
|
||||
if delay_start_time - last_time < FRAME_DURATION - max_delay then
|
||||
love.timer.sleep(milliseconds)
|
||||
local last_delay = love.timer.getTime() - delay_start_time
|
||||
if last_delay > max_delay then
|
||||
max_delay = last_delay
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
while love.timer.getTime() - last_time < FRAME_DURATION do
|
||||
-- busy loop, do nothing here until delay is finished; delays above stop short of finishing, so this part can finish it off precisely
|
||||
end
|
||||
time_accumulator = time_accumulator + time - last_time
|
||||
end
|
||||
time_accumulator = time_accumulator - frame_duration
|
||||
|
||||
local finish_delay_time = love.timer.getTime()
|
||||
local real_frame_duration = finish_delay_time - last_time
|
||||
time_accumulator = time_accumulator + real_frame_duration - FRAME_DURATION
|
||||
last_time = finish_delay_time
|
||||
end
|
||||
last_time = love.timer.getTime()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
zip -r cambridge.love libs load res scene tetris conf.lua main.lua scene.lua funcs.lua
|
|
@ -1,4 +1,6 @@
|
|||
./package
|
||||
#!/bin/sh
|
||||
|
||||
./package-love.sh
|
||||
mkdir dist
|
||||
mkdir dist/windows
|
||||
mkdir dist/win32
|
||||
|
@ -8,4 +10,4 @@ zip dist/cambridge-windows.zip dist/windows/* SOURCES.md LICENSE.md
|
|||
cat dist/win32/love.exe cambridge.love > dist/win32/cambridge.exe
|
||||
zip dist/cambridge-win32.zip dist/win32/* SOURCES.md LICENSE.md
|
||||
cp cambridge.love dist/other/
|
||||
zip dist/cambridge-other.zip cambridge.love libs/discord-rpc.* SOURCES.md LICENSE.md
|
||||
zip dist/cambridge-other.zip cambridge.love libs/discord-rpc.* SOURCES.md LICENSE.md
|
|
@ -0,0 +1,14 @@
|
|||
-- ex: extend_section_bg[100] = 0
|
||||
-- extend_section_bg[200] = 0
|
||||
-- the video background associated with section 0 will continue playing into 100 and 200 without restarting.
|
||||
-- will also cause any existing level 100, 200 backgrounds specified to NOT render.
|
||||
|
||||
-- please also note that you cannot currently extend any "named" backgrounds, such as "title" and "options-input"
|
||||
|
||||
extend_section_bg = {}
|
||||
|
||||
-- extend_section_bg[100] = 0
|
||||
-- extend_section_bg[200] = 0
|
||||
-- remove the dashes
|
||||
|
||||
return extend_section_bg
|
Binary file not shown.
After Width: | Height: | Size: 343 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 734 B After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 156 KiB |
|
@ -10,7 +10,9 @@ function Scene:onInputRelease() end
|
|||
|
||||
ExitScene = require "scene.exit"
|
||||
GameScene = require "scene.game"
|
||||
ReplayScene = require "scene.replay"
|
||||
ModeSelectScene = require "scene.mode_select"
|
||||
ReplaySelectScene = require "scene.replay_select"
|
||||
KeyConfigScene = require "scene.key_config"
|
||||
StickConfigScene = require "scene.stick_config"
|
||||
InputConfigScene = require "scene.input_config"
|
||||
|
|
|
@ -5,7 +5,7 @@ CreditsScene.title = "Credits"
|
|||
function CreditsScene:new()
|
||||
self.frames = 0
|
||||
-- higher = slower
|
||||
self.scroll_speed = 1.85
|
||||
self.scroll_speed = 1.8
|
||||
switchBGM("credit_roll", "gm3")
|
||||
|
||||
DiscordRPC:update({
|
||||
|
@ -16,9 +16,7 @@ function CreditsScene:new()
|
|||
end
|
||||
|
||||
function CreditsScene:update()
|
||||
if love.window.hasFocus() then
|
||||
self.frames = self.frames + 1
|
||||
end
|
||||
self.frames = self.frames + 1
|
||||
if self.frames >= 2100 * self.scroll_speed then
|
||||
playSE("mode_decide")
|
||||
scene = TitleScene()
|
||||
|
@ -32,11 +30,7 @@ function CreditsScene:render()
|
|||
local offset = self.frames / self.scroll_speed
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds[19],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground(19)
|
||||
|
||||
love.graphics.setFont(font_3x5_4)
|
||||
love.graphics.print("Cambridge Credits", 320, 500 - offset)
|
||||
|
@ -46,7 +40,7 @@ function CreditsScene:render()
|
|||
love.graphics.print("Game Developers", 320, 550 - offset)
|
||||
love.graphics.print("Project Heads", 320, 640 - offset)
|
||||
love.graphics.print("Notable Game Developers", 320, 750 - offset)
|
||||
love.graphics.print("Special Thanks", 320, 1020 - offset)
|
||||
love.graphics.print("Special Thanks", 320, 1000 - offset)
|
||||
love.graphics.print("- Milla", 320, math.max(2130 - offset, 320))
|
||||
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
|
@ -55,7 +49,7 @@ function CreditsScene:render()
|
|||
love.graphics.print(
|
||||
"2Tie - TGMsim\nAxel Fox - Multimino\nDr Ocelot - Tetra Legends\n" ..
|
||||
"Electra - ZTrix\nFelicity/nightmareci/kdex - Shiromino\n" ..
|
||||
"Mine - Tetra Online\nMrZ - Techmino\nosk - TETR.IO\n" ..
|
||||
"Mine - Tetra Online\nMrZ - Techmino\n" ..
|
||||
"Phoenix Flare - Master of Blocks\nRayRay26 - Spirit Drop\n" ..
|
||||
"Rin - Puzzle Trial\nsinefuse - stackfuse",
|
||||
320, 790 - offset
|
||||
|
@ -66,7 +60,7 @@ function CreditsScene:render()
|
|||
"CylinderKnot\neightsixfivezero\nEricICX\nGesomaru\n" ..
|
||||
"gizmo4487\nJBroms\nKirby703\nKitaru\n" ..
|
||||
"M1ssing0\nMattMayuga\nMyPasswordIsWeak\n" ..
|
||||
"Nikki Karissa\noffwo\nOliver\nPineapple\npokemonfan1937\n" ..
|
||||
"Nikki Karissa\nnim\noffwo\nOliver\nPineapple\npokemonfan1937\n" ..
|
||||
"Pyra Neoxi\nRDST64\nRocketLanterns\nRustyFoxxo\n" ..
|
||||
"saphie\nShelleloch\nSimon\nstratus\nSuper302\n" ..
|
||||
"switchpalacecorner\nterpyderp\nTetrian22\nTetro48\nThatCookie\n" ..
|
||||
|
@ -75,7 +69,7 @@ function CreditsScene:render()
|
|||
"Tetra Legends Discord\nTetra Online Discord\nMultimino Discord\n" ..
|
||||
"Hard Drop Discord\nRusty's Systemspace\nCambridge Discord\n" ..
|
||||
"And to you, the player!",
|
||||
320, 1060 - offset
|
||||
320, 1040 - offset
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ function GameScene:new(game_mode, ruleset, inputs)
|
|||
self.retry_ruleset = ruleset
|
||||
self.secret_inputs = inputs
|
||||
self.game = game_mode(self.secret_inputs)
|
||||
self.game.secret_inputs = inputs
|
||||
self.ruleset = ruleset(self.game)
|
||||
self.game:initialize(self.ruleset)
|
||||
self.inputs = {
|
||||
|
@ -24,6 +25,8 @@ function GameScene:new(game_mode, ruleset, inputs)
|
|||
hold=false,
|
||||
}
|
||||
self.paused = false
|
||||
self.game.pause_count = 0
|
||||
self.game.pause_time = 0
|
||||
DiscordRPC:update({
|
||||
details = self.game.rpc_details,
|
||||
state = self.game.name,
|
||||
|
@ -32,7 +35,9 @@ function GameScene:new(game_mode, ruleset, inputs)
|
|||
end
|
||||
|
||||
function GameScene:update()
|
||||
if love.window.hasFocus() and not self.paused then
|
||||
if self.paused then
|
||||
self.game.pause_time = self.game.pause_time + 1
|
||||
else
|
||||
local inputs = {}
|
||||
for input, value in pairs(self.inputs) do
|
||||
inputs[input] = value
|
||||
|
@ -40,6 +45,8 @@ function GameScene:update()
|
|||
self.game:update(inputs, self.ruleset)
|
||||
self.game.grid:update()
|
||||
DiscordRPC:update({
|
||||
details = self.game.rpc_details,
|
||||
state = self.game.name,
|
||||
largeImageKey = "ingame-"..self.game:getBackground().."00"
|
||||
})
|
||||
end
|
||||
|
@ -47,6 +54,16 @@ end
|
|||
|
||||
function GameScene:render()
|
||||
self.game:draw(self.paused)
|
||||
if self.game.pause_time > 0 or self.game.pause_count > 0 then
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
love.graphics.printf(string.format(
|
||||
"%d PAUSE%s (%s)",
|
||||
self.game.pause_count,
|
||||
self.game.pause_count == 1 and "" or "S",
|
||||
formatTime(self.game.pause_time)
|
||||
), 0, 0, 635, "right")
|
||||
end
|
||||
end
|
||||
|
||||
function GameScene:onInputPress(e)
|
||||
|
@ -64,12 +81,17 @@ function GameScene:onInputPress(e)
|
|||
scene = e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs) or ModeSelectScene()
|
||||
elseif e.input == "retry" then
|
||||
switchBGM(nil)
|
||||
pitchBGM(1)
|
||||
self.game:onExit()
|
||||
scene = GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs)
|
||||
elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then
|
||||
self.paused = not self.paused
|
||||
if self.paused then pauseBGM()
|
||||
else resumeBGM() end
|
||||
if self.paused then
|
||||
pauseBGM()
|
||||
self.game.pause_count = self.game.pause_count + 1
|
||||
else
|
||||
resumeBGM()
|
||||
end
|
||||
elseif e.input == "menu_back" then
|
||||
self.game:onExit()
|
||||
scene = ModeSelectScene()
|
||||
|
|
|
@ -13,11 +13,12 @@ ConfigScene.options = {
|
|||
{"world_reverse", "A Button Rotation", false, {"Left", "Auto", "Right"}},
|
||||
{"spawn_positions", "Spawn Positions", false, {"Per ruleset", "In field", "Out of field"}},
|
||||
{"display_gamemode", "Debug Info", false, {"On", "Off"}},
|
||||
{"das_last_key", "DAS Last Key", false, {"Off", "On"}},
|
||||
{"save_replay", "Save Replays", false, {"On", "Off"}},
|
||||
{"smooth_movement", "Smooth Piece Drop", false, {"On", "Off"}},
|
||||
{"synchroes_allowed", "Synchroes", false, {"Per ruleset", "On", "Off"}},
|
||||
{"diagonal_input", "Diagonal Input", false, {"On", "Off"}},
|
||||
{"das_last_key", "DAS Last Key", false, {"Off", "On"}},
|
||||
{"buffer_lock", "Buffer Drop Type", false, {"Off", "Hold", "Tap"}},
|
||||
{"synchroes_allowed", "Synchroes", false, {"Per ruleset", "On", "Off"}},
|
||||
{"sfx_volume", "SFX", true, "sfxSlider"},
|
||||
{"bgm_volume", "BGM", true, "bgmSlider"},
|
||||
}
|
||||
|
@ -33,8 +34,8 @@ function ConfigScene:new()
|
|||
state = "Changing game settings",
|
||||
})
|
||||
|
||||
self.sfxSlider = newSlider(165, 400, 225, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20, knob="circle", track="roundrect"})
|
||||
self.bgmSlider = newSlider(465, 400, 225, config.bgm_volume * 100, 0, 100, function(v) config.bgm_volume = v / 100 end, {width=20, knob="circle", track="roundrect"})
|
||||
self.sfxSlider = newSlider(165, 420, 225, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20, knob="circle", track="roundrect"})
|
||||
self.bgmSlider = newSlider(465, 420, 225, config.bgm_volume * 100, 0, 100, function(v) config.bgm_volume = v / 100 end, {width=20, knob="circle", track="roundrect"})
|
||||
end
|
||||
|
||||
function ConfigScene:update()
|
||||
|
@ -44,11 +45,7 @@ end
|
|||
|
||||
function ConfigScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds["game_config"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground("options_game")
|
||||
|
||||
love.graphics.setFont(font_3x5_4)
|
||||
love.graphics.print("GAME SETTINGS", 80, 40)
|
||||
|
@ -58,7 +55,7 @@ function ConfigScene:render()
|
|||
if not ConfigScene.options[self.highlight][3] then
|
||||
love.graphics.rectangle("fill", 25, 98 + self.highlight * 20, 170, 22)
|
||||
else
|
||||
love.graphics.rectangle("fill", 65 + (1+self.highlight-#self.options) * 300, 342, 215, 33)
|
||||
love.graphics.rectangle("fill", 65 + (1+self.highlight-#self.options) * 300, 362, 215, 33)
|
||||
end
|
||||
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
|
@ -75,8 +72,8 @@ function ConfigScene:render()
|
|||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.print("SFX Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 75, 345)
|
||||
love.graphics.print("BGM Volume: " .. math.floor(self.bgmSlider:getValue()) .. "%", 375, 345)
|
||||
love.graphics.print("SFX Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 75, 365)
|
||||
love.graphics.print("BGM Volume: " .. math.floor(self.bgmSlider:getValue()) .. "%", 375, 365)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.75)
|
||||
self.sfxSlider:draw()
|
||||
|
|
|
@ -20,11 +20,7 @@ function ConfigScene:update() end
|
|||
|
||||
function ConfigScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds["input_config"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground("options_input")
|
||||
|
||||
love.graphics.setFont(font_3x5_4)
|
||||
love.graphics.print("INPUT CONFIG", 80, 40)
|
||||
|
|
|
@ -45,11 +45,7 @@ end
|
|||
|
||||
function KeyConfigScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds["input_config"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground("options_input")
|
||||
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
for i, input in ipairs(configurable_inputs) do
|
||||
|
|
|
@ -58,11 +58,7 @@ function ModeSelectScene:update()
|
|||
end
|
||||
|
||||
function ModeSelectScene:render()
|
||||
love.graphics.draw(
|
||||
backgrounds[0],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground(0)
|
||||
|
||||
love.graphics.draw(misc_graphics["select_mode"], 20, 40)
|
||||
|
||||
|
@ -187,4 +183,4 @@ function ModeSelectScene:changeRuleset(rel)
|
|||
self.menu_state.ruleset = Mod1(self.menu_state.ruleset + rel, len)
|
||||
end
|
||||
|
||||
return ModeSelectScene
|
||||
return ModeSelectScene
|
|
@ -0,0 +1,150 @@
|
|||
local Sequence = require 'tetris.randomizers.fixed_sequence'
|
||||
|
||||
local ReplayScene = Scene:extend()
|
||||
|
||||
ReplayScene.title = "Replay"
|
||||
|
||||
function ReplayScene:new(replay, game_mode, ruleset)
|
||||
config.gamesettings = replay["gamesettings"]
|
||||
if replay["delayed_auto_shift"] then config.das = replay["delayed_auto_shift"] end
|
||||
if replay["auto_repeat_rate"] then config.arr = replay["auto_repeat_rate"] end
|
||||
if replay["das_cut_delay"] then config.dcd = replay["das_cut_delay"] end
|
||||
love.math.setRandomSeed(replay["random_low"], replay["random_high"])
|
||||
love.math.setRandomState(replay["random_state"])
|
||||
self.retry_replay = replay
|
||||
self.retry_mode = game_mode
|
||||
self.retry_ruleset = ruleset
|
||||
self.secret_inputs = replay["secret_inputs"]
|
||||
self.game = game_mode(self.secret_inputs)
|
||||
self.game.save_replay = false
|
||||
self.ruleset = ruleset(self.game)
|
||||
self.game:initialize(self.ruleset)
|
||||
self.inputs = {
|
||||
left=false,
|
||||
right=false,
|
||||
up=false,
|
||||
down=false,
|
||||
rotate_left=false,
|
||||
rotate_left2=false,
|
||||
rotate_right=false,
|
||||
rotate_right2=false,
|
||||
rotate_180=false,
|
||||
hold=false,
|
||||
}
|
||||
self.paused = false
|
||||
self.game.pause_count = replay["pause_count"]
|
||||
self.game.pause_time = replay["pause_time"]
|
||||
self.replay = deepcopy(replay)
|
||||
self.replay_index = 1
|
||||
self.replay_speed = 1
|
||||
self.show_invisible = false
|
||||
self.frame_steps = 0
|
||||
DiscordRPC:update({
|
||||
details = "Viewing a replay",
|
||||
state = self.game.name,
|
||||
largeImageKey = "ingame-"..self.game:getBackground().."00"
|
||||
})
|
||||
end
|
||||
|
||||
function ReplayScene:update()
|
||||
local frames_left = self.replay_speed
|
||||
if not self.paused or self.frame_steps > 0 then
|
||||
if self.frame_steps > 0 then
|
||||
self.frame_steps = self.frame_steps - 1
|
||||
end
|
||||
while frames_left > 0 do
|
||||
frames_left = frames_left - 1
|
||||
self.inputs = self.replay["inputs"][self.replay_index]["inputs"]
|
||||
self.replay["inputs"][self.replay_index]["frames"] = self.replay["inputs"][self.replay_index]["frames"] - 1
|
||||
if self.replay["inputs"][self.replay_index]["frames"] == 0 and self.replay_index < table.getn(self.replay["inputs"]) then
|
||||
self.replay_index = self.replay_index + 1
|
||||
end
|
||||
local input_copy = {}
|
||||
for input, value in pairs(self.inputs) do
|
||||
input_copy[input] = value
|
||||
end
|
||||
self.game:update(input_copy, self.ruleset)
|
||||
self.game.grid:update()
|
||||
end
|
||||
DiscordRPC:update({
|
||||
details = "Viewing a replay",
|
||||
state = self.game.name,
|
||||
largeImageKey = "ingame-"..self.game:getBackground().."00"
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function ReplayScene:render()
|
||||
self.game:draw(self.paused)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf("REPLAY", 0, 0, 635, "right")
|
||||
local pauses_y_coordinate = 23
|
||||
if self.replay_speed > 1 then
|
||||
pauses_y_coordinate = pauses_y_coordinate + 20
|
||||
love.graphics.printf(self.replay_speed.."X", 0, 20, 635, "right")
|
||||
end
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
if self.game.pause_time and self.game.pause_count then
|
||||
if self.game.pause_time > 0 or self.game.pause_count > 0 then
|
||||
love.graphics.printf(string.format(
|
||||
"%d PAUSE%s (%s)",
|
||||
self.game.pause_count,
|
||||
self.game.pause_count == 1 and "" or "S",
|
||||
formatTime(self.game.pause_time)
|
||||
), 0, pauses_y_coordinate, 635, "right")
|
||||
end
|
||||
else
|
||||
love.graphics.printf("?? PAUSES (--:--.--)", 0, pauses_y_coordinate, 635, "right")
|
||||
end
|
||||
if self.show_invisible then
|
||||
self.game.grid:draw()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf("SHOW INVIS", 64, 60, 160, "center")
|
||||
end
|
||||
end
|
||||
|
||||
function ReplayScene:onInputPress(e)
|
||||
if (
|
||||
e.input == "menu_back" or
|
||||
e.input == "menu_decide" or
|
||||
e.input == "retry"
|
||||
) then
|
||||
switchBGM(nil)
|
||||
pitchBGM(1)
|
||||
self.game:onExit()
|
||||
loadSave()
|
||||
love.math.setRandomSeed(os.time())
|
||||
scene = (
|
||||
(e.input == "retry") and
|
||||
ReplayScene(
|
||||
self.retry_replay, self.retry_mode,
|
||||
self.retry_ruleset, self.secret_inputs
|
||||
) or ReplaySelectScene()
|
||||
)
|
||||
elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then
|
||||
self.paused = not self.paused
|
||||
if self.paused then pauseBGM()
|
||||
else resumeBGM() end
|
||||
--frame step
|
||||
elseif e.input == "rotate_left" then
|
||||
self.frame_steps = self.frame_steps + 1
|
||||
elseif e.input == "left" then
|
||||
self.replay_speed = self.replay_speed - 1
|
||||
if self.replay_speed < 1 then
|
||||
self.replay_speed = 1
|
||||
end
|
||||
pitchBGM(self.replay_speed)
|
||||
elseif e.input == "right" then
|
||||
self.replay_speed = self.replay_speed + 1
|
||||
if self.replay_speed > 99 then
|
||||
self.replay_speed = 99
|
||||
end
|
||||
pitchBGM(self.replay_speed)
|
||||
elseif e.input == "hold" then
|
||||
self.show_invisible = not self.show_invisible
|
||||
end
|
||||
end
|
||||
|
||||
return ReplayScene
|
|
@ -0,0 +1,220 @@
|
|||
local ReplaySelectScene = Scene:extend()
|
||||
|
||||
ReplaySelectScene.title = "Replays"
|
||||
|
||||
local binser = require 'libs.binser'
|
||||
|
||||
current_replay = 1
|
||||
|
||||
function ReplaySelectScene:new()
|
||||
-- reload custom modules
|
||||
initModules()
|
||||
-- load replays
|
||||
replays = {}
|
||||
replay_file_list = love.filesystem.getDirectoryItems("replays")
|
||||
for i=1,#replay_file_list do
|
||||
local data = love.filesystem.read("replays/"..replay_file_list[i])
|
||||
local success, new_replay = pcall(
|
||||
function() return binser.deserialize(data)[1] end
|
||||
)
|
||||
if success then
|
||||
replays[#replays + 1] = new_replay
|
||||
end
|
||||
end
|
||||
table.sort(replays, function(a, b)
|
||||
return a["timestamp"] > b["timestamp"]
|
||||
end)
|
||||
self.display_error = false
|
||||
if table.getn(replays) == 0 then
|
||||
self.display_warning = true
|
||||
current_replay = 1
|
||||
else
|
||||
self.display_warning = false
|
||||
if current_replay > table.getn(replays) then
|
||||
current_replay = 1
|
||||
end
|
||||
end
|
||||
|
||||
self.menu_state = {
|
||||
replay = current_replay,
|
||||
}
|
||||
self.das = 0
|
||||
DiscordRPC:update({
|
||||
details = "In menus",
|
||||
state = "Choosing a replay",
|
||||
largeImageKey = "ingame-000"
|
||||
})
|
||||
end
|
||||
|
||||
function ReplaySelectScene:update()
|
||||
if self.das_up or self.das_down or self.das_left or self.das_right then
|
||||
self.das = self.das + 1
|
||||
else
|
||||
self.das = 0
|
||||
end
|
||||
|
||||
if self.das >= 15 then
|
||||
local change = 0
|
||||
if self.das_up then
|
||||
change = -1
|
||||
elseif self.das_down then
|
||||
change = 1
|
||||
elseif self.das_left then
|
||||
change = -9
|
||||
elseif self.das_right then
|
||||
change = 9
|
||||
end
|
||||
self:changeOption(change)
|
||||
self.das = self.das - 4
|
||||
end
|
||||
|
||||
DiscordRPC:update({
|
||||
details = "In menus",
|
||||
state = "Choosing a replay",
|
||||
largeImageKey = "ingame-000"
|
||||
})
|
||||
end
|
||||
|
||||
function ReplaySelectScene:render()
|
||||
drawBackground(0)
|
||||
|
||||
-- Same graphic as mode select
|
||||
--love.graphics.draw(misc_graphics["select_mode"], 20, 40)
|
||||
|
||||
love.graphics.setFont(font_8x11)
|
||||
love.graphics.print("SELECT REPLAY", 20, 35)
|
||||
|
||||
if self.display_warning then
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf(
|
||||
"You have no replays.",
|
||||
80, 200, 480, "center"
|
||||
)
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
love.graphics.printf(
|
||||
"Come back to this menu after playing some games. " ..
|
||||
"Press any button to return to the main menu.",
|
||||
80, 250, 480, "center"
|
||||
)
|
||||
return
|
||||
elseif self.display_error then
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf(
|
||||
"You are missing this mode or ruleset.",
|
||||
80, 200, 480, "center"
|
||||
)
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
love.graphics.printf(
|
||||
"Come back after getting the proper mode or ruleset. " ..
|
||||
"Press any button to return to the main menu.",
|
||||
80, 250, 480, "center"
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
love.graphics.rectangle("fill", 3, 258, 634, 22)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
for idx, replay in ipairs(replays) do
|
||||
if(idx >= self.menu_state.replay-9 and idx <= self.menu_state.replay+9) then
|
||||
local display_string = os.date("%c", replay["timestamp"]).." - "..replay["mode"].." - "..replay["ruleset"]
|
||||
if replay["level"] ~= nil then
|
||||
display_string = display_string.." - Level: "..replay["level"]
|
||||
end
|
||||
if replay["timer"] ~= nil then
|
||||
display_string = display_string.." - Time: "..formatTime(replay["timer"])
|
||||
end
|
||||
if #display_string > 75 then
|
||||
display_string = display_string:sub(1, 75) .. "..."
|
||||
end
|
||||
love.graphics.printf(display_string, 6, (260 - 20*(self.menu_state.replay)) + 20 * idx, 640, "left")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ReplaySelectScene:onInputPress(e)
|
||||
if (self.display_warning or self.display_error) and e.input then
|
||||
scene = TitleScene()
|
||||
elseif e.type == "wheel" then
|
||||
if e.y ~= 0 then
|
||||
self:changeOption(-e.y)
|
||||
end
|
||||
elseif e.input == "menu_decide" or e.scancode == "return" then
|
||||
current_replay = self.menu_state.replay
|
||||
-- Same as mode decide
|
||||
playSE("mode_decide")
|
||||
-- Get game mode and ruleset
|
||||
local mode
|
||||
local rules
|
||||
for key, value in pairs(game_modes) do
|
||||
if value.name == replays[self.menu_state.replay]["mode"] then
|
||||
mode = value
|
||||
break
|
||||
end
|
||||
end
|
||||
for key, value in pairs(rulesets) do
|
||||
if value.name == replays[self.menu_state.replay]["ruleset"] then
|
||||
rules = value
|
||||
break
|
||||
end
|
||||
end
|
||||
if mode == nil or rules == nil then
|
||||
self.display_error = true
|
||||
return
|
||||
end
|
||||
-- TODO compare replay versions to current versions for Cambridge, ruleset, and mode
|
||||
scene = ReplayScene(
|
||||
replays[self.menu_state.replay],
|
||||
mode,
|
||||
rules
|
||||
)
|
||||
elseif e.input == "up" or e.scancode == "up" then
|
||||
self:changeOption(-1)
|
||||
self.das_up = true
|
||||
self.das_down = nil
|
||||
self.das_left = nil
|
||||
self.das_right = nil
|
||||
elseif e.input == "down" or e.scancode == "down" then
|
||||
self:changeOption(1)
|
||||
self.das_down = true
|
||||
self.das_up = nil
|
||||
self.das_left = nil
|
||||
self.das_right = nil
|
||||
elseif e.input == "left" or e.scancode == "left" then
|
||||
self:changeOption(-9)
|
||||
self.das_left = true
|
||||
self.das_right = nil
|
||||
self.das_up = nil
|
||||
self.das_down = nil
|
||||
elseif e.input == "right" or e.scancode == "right" then
|
||||
self:changeOption(9)
|
||||
self.das_right = true
|
||||
self.das_left = nil
|
||||
self.das_up = nil
|
||||
self.das_down = nil
|
||||
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||
scene = TitleScene()
|
||||
end
|
||||
end
|
||||
|
||||
function ReplaySelectScene:onInputRelease(e)
|
||||
if e.input == "up" or e.scancode == "up" then
|
||||
self.das_up = nil
|
||||
elseif e.input == "down" or e.scancode == "down" then
|
||||
self.das_down = nil
|
||||
elseif e.input == "right" or e.scancode == "right" then
|
||||
self.das_right = nil
|
||||
elseif e.input == "left" or e.scancode == "left" then
|
||||
self.das_left = nil
|
||||
end
|
||||
end
|
||||
|
||||
function ReplaySelectScene:changeOption(rel)
|
||||
local len = table.getn(replays)
|
||||
self.menu_state.replay = Mod1(self.menu_state.replay + rel, len)
|
||||
playSE("cursor")
|
||||
end
|
||||
|
||||
return ReplaySelectScene
|
|
@ -20,7 +20,7 @@ function SettingsScene:new()
|
|||
self.menu_state = 1
|
||||
DiscordRPC:update({
|
||||
details = "In settings",
|
||||
state = settingsidle[math.random(#settingsidle)],
|
||||
state = settingsidle[love.math.random(#settingsidle)],
|
||||
largeImageKey = "settings",
|
||||
})
|
||||
end
|
||||
|
@ -29,11 +29,7 @@ function SettingsScene:update() end
|
|||
|
||||
function SettingsScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds["game_config"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground("options_game")
|
||||
|
||||
love.graphics.setFont(font_3x5_4)
|
||||
love.graphics.print("SETTINGS", 80, 40)
|
||||
|
|
|
@ -46,11 +46,7 @@ end
|
|||
|
||||
function StickConfigScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds["input_config"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground("options_input")
|
||||
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
for i, input in ipairs(configurable_inputs) do
|
||||
|
|
|
@ -5,6 +5,7 @@ TitleScene.restart_message = false
|
|||
|
||||
local main_menu_screens = {
|
||||
ModeSelectScene,
|
||||
ReplaySelectScene,
|
||||
SettingsScene,
|
||||
CreditsScene,
|
||||
ExitScene,
|
||||
|
@ -43,7 +44,7 @@ function TitleScene:new()
|
|||
self.text_flag = false
|
||||
DiscordRPC:update({
|
||||
details = "In menus",
|
||||
state = mainmenuidle[math.random(#mainmenuidle)],
|
||||
state = mainmenuidle[love.math.random(#mainmenuidle)],
|
||||
largeImageKey = "icon2",
|
||||
largeImageText = version
|
||||
})
|
||||
|
@ -59,35 +60,42 @@ function TitleScene:update()
|
|||
else self.y_offset = 310 - self.frames end
|
||||
end
|
||||
|
||||
local block_offsets = {
|
||||
{color = "M", x = 0, y = 0},
|
||||
{color = "G", x = 32, y = 0},
|
||||
{color = "Y", x = 64, y = 0},
|
||||
{color = "B", x = 0, y = 32},
|
||||
{color = "O", x = 0, y = 64},
|
||||
{color = "C", x = 32, y = 64},
|
||||
{color = "R", x = 64, y = 64}
|
||||
}
|
||||
|
||||
function TitleScene:render()
|
||||
love.graphics.setFont(font_3x5_4)
|
||||
love.graphics.setColor(1, 1, 1, 1 - self.snow_bg_opacity)
|
||||
drawBackground("title_no_icon") -- title, title_night
|
||||
|
||||
-- 490, 192
|
||||
for _, b in ipairs(block_offsets) do
|
||||
love.graphics.draw(
|
||||
blocks["2tie"][b.color],
|
||||
490 + b.x, 192 + b.y, 0,
|
||||
2, 2
|
||||
)
|
||||
end
|
||||
|
||||
--[[
|
||||
love.graphics.draw(
|
||||
backgrounds["title"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
]]
|
||||
love.graphics.draw(
|
||||
backgrounds["title_night"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
love.graphics.draw(
|
||||
misc_graphics["icon"],
|
||||
460, 170, 0,
|
||||
490, 192, 0,
|
||||
2, 2
|
||||
)
|
||||
love.graphics.printf("Thanks for 1 year!", 430, 280, 160, "center")
|
||||
]]
|
||||
--love.graphics.printf("Thanks for 1 year!", 430, 280, 160, "center")
|
||||
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
love.graphics.setColor(1, 1, 1, self.snow_bg_opacity)
|
||||
love.graphics.draw(
|
||||
backgrounds["snow"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground("snow")
|
||||
|
||||
love.graphics.draw(
|
||||
misc_graphics["santa"],
|
||||
|
@ -125,8 +133,6 @@ function TitleScene:onInputPress(e)
|
|||
playSE("cursor")
|
||||
elseif e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete" then
|
||||
love.event.quit()
|
||||
-- no winter easter egg for now
|
||||
--[[
|
||||
else
|
||||
self.text = self.text .. (e.scancode or "")
|
||||
if self.text == "ffffff" then
|
||||
|
@ -135,7 +141,6 @@ function TitleScene:onInputPress(e)
|
|||
largeImageKey = "snow"
|
||||
})
|
||||
end
|
||||
]]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -34,11 +34,7 @@ end
|
|||
|
||||
function TuningScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds["game_config"],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground("options_game")
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
love.graphics.rectangle("fill", 75, 98 + self.highlight * 75, 400, 33)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
@echo OFF
|
||||
|
||||
rem This solution of detecting the current CPU taken from here: https://stackoverflow.com/a/24590583
|
||||
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set CURRENT_CPU=32BIT || set CURRENT_CPU=64BIT
|
||||
|
||||
if %CURRENT_CPU%==32BIT .\dist\win32\love.exe .
|
||||
if %CURRENT_CPU%==64BIT .\dist\windows\love.exe .
|
|
@ -182,6 +182,19 @@ function Grid:clearSpecificRow(row)
|
|||
end
|
||||
end
|
||||
|
||||
function Grid:clearBlock(x, y)
|
||||
self.grid[x+1][y+1] = empty
|
||||
end
|
||||
|
||||
function Grid:clearBottomRows(num)
|
||||
local old_isRowFull = self.isRowFull
|
||||
self.isRowFull = function(self, row)
|
||||
return row >= self.height + 1 - num
|
||||
end
|
||||
self:clearClearedRows()
|
||||
self.isRowFull = old_isRowFull
|
||||
end
|
||||
|
||||
function Grid:applyPiece(piece)
|
||||
if piece.big then
|
||||
self:applyBigPiece(piece)
|
||||
|
@ -218,12 +231,15 @@ function Grid:applyBigPiece(piece)
|
|||
end
|
||||
end
|
||||
|
||||
function Grid:checkForBravo(cleared_row_count)
|
||||
for i = 0, self.height - 1 - cleared_row_count do
|
||||
for j = 0, self.width - 1 do
|
||||
if self:isOccupied(j, i) then return false end
|
||||
end
|
||||
-- places where you see this take an argument used the old, buggy method
|
||||
function Grid:checkForBravo()
|
||||
for i = 0, self.height - 1 do
|
||||
if not self:isRowFull(i+1) then
|
||||
for j = 0, self.width - 1 do
|
||||
if self:isOccupied(j, i) then return false end
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -10,41 +10,10 @@ BigA2Game.tagline = "Big blocks in the most celebrated TGM mode!"
|
|||
function BigA2Game:new()
|
||||
BigA2Game.super:new()
|
||||
self.big_mode = true
|
||||
end
|
||||
|
||||
function BigA2Game:updateScore(level, drop_bonus, cleared_lines)
|
||||
cleared_lines = cleared_lines / 2
|
||||
if not self.clear then
|
||||
self:updateGrade(cleared_lines)
|
||||
if cleared_lines >= 4 then
|
||||
self.tetris_count = self.tetris_count + 1
|
||||
end
|
||||
if self.grid:checkForBravo(cleared_lines) then self.bravo = 4 else self.bravo = 1 end
|
||||
if cleared_lines > 0 then
|
||||
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||
self.score = self.score + (
|
||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||
cleared_lines * self.combo * self.bravo
|
||||
)
|
||||
else
|
||||
self.combo = 1
|
||||
end
|
||||
self.drop_bonus = 0
|
||||
else self.lines = self.lines + cleared_lines end
|
||||
end
|
||||
|
||||
function BigA2Game:onLineClear(cleared_row_count)
|
||||
cleared_row_count = cleared_row_count / 2
|
||||
self:updateSectionTimes(self.level, self.level + cleared_row_count)
|
||||
self.level = math.min(self.level + cleared_row_count, 999)
|
||||
if self.level == 999 and not self.clear then
|
||||
self.clear = true
|
||||
self.grid:clear()
|
||||
if self:qualifiesForMRoll() then self.grade = 32 end
|
||||
self.roll_frames = -150
|
||||
local getClearedRowCount = self.grid.getClearedRowCount
|
||||
self.grid.getClearedRowCount = function(self)
|
||||
return getClearedRowCount(self) / 2
|
||||
end
|
||||
self.lock_drop = self.level >= 900
|
||||
self.lock_hard_drop = self.level >= 900
|
||||
end
|
||||
|
||||
return BigA2Game
|
|
@ -7,6 +7,7 @@ local playedGoSE = false
|
|||
local Grid = require 'tetris.components.grid'
|
||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||
local BagRandomizer = require 'tetris.randomizers.bag'
|
||||
local binser = require 'libs.binser'
|
||||
|
||||
local GameMode = Object:extend()
|
||||
|
||||
|
@ -15,7 +16,12 @@ GameMode.hash = ""
|
|||
GameMode.tagline = ""
|
||||
GameMode.rollOpacityFunction = function(age) return 0 end
|
||||
|
||||
function GameMode:new(secret_inputs)
|
||||
function GameMode:new()
|
||||
self.replay_inputs = {}
|
||||
self.random_low, self.random_high = love.math.getRandomSeed()
|
||||
self.random_state = love.math.getRandomState()
|
||||
self.save_replay = config.gamesettings.save_replay == 1
|
||||
|
||||
self.grid = Grid(10, 24)
|
||||
self.randomizer = Randomizer()
|
||||
self.piece = nil
|
||||
|
@ -114,8 +120,69 @@ function GameMode:initialize(ruleset)
|
|||
self.lock_on_hard_drop = ({ruleset.harddrop_lock, self.instant_hard_drop, true, false})[config.gamesettings.manlock]
|
||||
end
|
||||
|
||||
function GameMode:saveReplay()
|
||||
-- Save replay.
|
||||
local replay = {}
|
||||
replay["inputs"] = self.replay_inputs
|
||||
replay["random_low"] = self.random_low
|
||||
replay["random_high"] = self.random_high
|
||||
replay["random_state"] = self.random_state
|
||||
replay["mode"] = self.name
|
||||
replay["ruleset"] = self.ruleset.name
|
||||
replay["timer"] = self.frames
|
||||
replay["score"] = self.score
|
||||
replay["level"] = self.level
|
||||
replay["lines"] = self.lines
|
||||
replay["gamesettings"] = config.gamesettings
|
||||
replay["secret_inputs"] = self.secret_inputs
|
||||
replay["delayed_auto_shift"] = config.das
|
||||
replay["auto_repeat_rate"] = config.arr
|
||||
replay["das_cut_delay"] = config.dcd
|
||||
replay["timestamp"] = os.time()
|
||||
replay["pause_count"] = self.pause_count
|
||||
replay["pause_time"] = self.pause_time
|
||||
if love.filesystem.getInfo("replays") == nil then
|
||||
love.filesystem.createDirectory("replays")
|
||||
end
|
||||
local init_name = string.format("replays/%s.crp", os.date("%Y-%m-%d_%H-%M-%S"))
|
||||
local replay_name = init_name
|
||||
local replay_number = 0
|
||||
while true do
|
||||
if love.filesystem.getInfo(replay_name, "file") then
|
||||
replay_number = replay_number + 1
|
||||
replay_name = string.format("%s (%d)", init_name, replay_number)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
love.filesystem.write(replay_name, binser.serialize(replay))
|
||||
end
|
||||
|
||||
function GameMode:addReplayInput(inputs)
|
||||
-- check if inputs have changed since last frame
|
||||
if not equals(self.prev_inputs, inputs) then
|
||||
-- insert new inputs into replay inputs table
|
||||
local new_inputs = {}
|
||||
new_inputs["inputs"] = {}
|
||||
new_inputs["frames"] = 1
|
||||
for key, value in pairs(inputs) do
|
||||
new_inputs["inputs"][key] = value
|
||||
end
|
||||
self.replay_inputs[#self.replay_inputs + 1] = new_inputs
|
||||
else
|
||||
-- add 1 to input frame counter
|
||||
self.replay_inputs[#self.replay_inputs]["frames"] = self.replay_inputs[#self.replay_inputs]["frames"] + 1
|
||||
end
|
||||
end
|
||||
|
||||
function GameMode:update(inputs, ruleset)
|
||||
if self.game_over or self.completed then
|
||||
if self.save_replay and self.game_over_frames == 0 then
|
||||
self:saveReplay()
|
||||
|
||||
-- ensure replays are only saved once per game, incase self.game_over_frames == 0 for longer than one frame
|
||||
self.save_replay = false
|
||||
end
|
||||
self.game_over_frames = self.game_over_frames + 1
|
||||
return
|
||||
end
|
||||
|
@ -129,6 +196,8 @@ function GameMode:update(inputs, ruleset)
|
|||
end
|
||||
end
|
||||
|
||||
if self.save_replay then self:addReplayInput(inputs) end
|
||||
|
||||
-- advance one frame
|
||||
if self:advanceOneFrame(inputs, ruleset) == false then return end
|
||||
|
||||
|
@ -334,7 +403,17 @@ end
|
|||
|
||||
function GameMode:onGameOver()
|
||||
switchBGM(nil)
|
||||
love.graphics.setColor(0, 0, 0, 1 - 2 ^ (-self.game_over_frames / 30))
|
||||
pitchBGM(1)
|
||||
local alpha = 0
|
||||
local animation_length = 120
|
||||
if self.game_over_frames < animation_length then
|
||||
-- Show field for a bit, then fade out.
|
||||
alpha = math.pow(2048, self.game_over_frames/animation_length - 1)
|
||||
elseif self.game_over_frames < 2 * animation_length then
|
||||
-- Keep field hidden for a short time, then pop it back in (for screenshots).
|
||||
alpha = 1
|
||||
end
|
||||
love.graphics.setColor(0, 0, 0, alpha)
|
||||
love.graphics.rectangle(
|
||||
"fill", 64, 80,
|
||||
16 * self.grid.width, 16 * (self.grid.height - 4)
|
||||
|
@ -530,6 +609,8 @@ function GameMode:onEnterOrHold(inputs, ruleset)
|
|||
if not self.grid:canPlacePiece(self.piece) then
|
||||
self.game_over = true
|
||||
return
|
||||
elseif self.piece:isDropBlocked(self.grid) then
|
||||
playSE("bottom")
|
||||
end
|
||||
ruleset:dropPiece(
|
||||
inputs, self.piece, self.grid, self:getGravity(),
|
||||
|
@ -578,10 +659,6 @@ function GameMode:initializeNextPiece(
|
|||
self.piece_soft_locked = false
|
||||
self.buffer_hard_drop = false
|
||||
self.buffer_soft_drop = false
|
||||
if self.piece:isDropBlocked(self.grid) and
|
||||
self.grid:canPlacePiece(self.piece) then
|
||||
playSE("bottom")
|
||||
end
|
||||
if generate_next_piece == nil then
|
||||
table.remove(self.next_queue, 1)
|
||||
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
||||
|
@ -600,11 +677,18 @@ function GameMode:getHighScoreData()
|
|||
end
|
||||
|
||||
function GameMode:animation(x, y, skin, colour)
|
||||
-- Animation progress where 0 = start and 1 = end
|
||||
local progress = 1
|
||||
if self.last_lcd ~= 0 then
|
||||
progress = (self.last_lcd - self.lcd) / self.last_lcd
|
||||
end
|
||||
-- Convert progress through the animation into an alpha value, with easing
|
||||
local alpha = 1 - progress ^ 2
|
||||
return {
|
||||
1, 1, 1,
|
||||
-0.25 + 1.25 * (self.lcd / self.last_lcd),
|
||||
skin, colour,
|
||||
48 + x * 16, y * 16
|
||||
1, 1, 1,
|
||||
alpha,
|
||||
skin, colour,
|
||||
48 + x * 16, y * 16
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -616,8 +700,56 @@ function GameMode:drawLineClearAnimation()
|
|||
-- animation function
|
||||
-- params: block x, y, skin, colour
|
||||
-- returns: table with RGBA, skin, colour, x, y
|
||||
|
||||
-- Fadeout (default)
|
||||
|
||||
-- Quadratic Fadeout (default)
|
||||
--[[
|
||||
function animation(x, y, skin, colour)
|
||||
-- Animation progress where 0 = start and 1 = end
|
||||
local progress = 1
|
||||
if self.last_lcd ~= 0 then
|
||||
progress = (self.last_lcd - self.lcd) / self.last_lcd
|
||||
end
|
||||
-- Convert progress through the animation into an alpha value, with easing
|
||||
local alpha = 1 - progress ^ 2
|
||||
return {
|
||||
1, 1, 1,
|
||||
alpha,
|
||||
skin, colour,
|
||||
48 + x * 16, y * 16
|
||||
}
|
||||
end
|
||||
--]]
|
||||
|
||||
-- Flashy Fadeout
|
||||
--[[
|
||||
function animation(x, y, skin, colour)
|
||||
-- Animation progress where 0 = start and 1 = end
|
||||
local progress = 1
|
||||
if self.last_lcd ~= 0 then
|
||||
progress = (self.last_lcd - self.lcd) / self.last_lcd
|
||||
end
|
||||
-- Change this number to change "bounciness"
|
||||
local bounce = 13
|
||||
-- Convert progress through the animation into an alpha value
|
||||
local alpha = 0
|
||||
-- Cutoff is arbitrary: corresponds to level 500 in Marathon A2
|
||||
if self.last_lcd > 25 then
|
||||
-- Goes up and down: looks better when animation is long
|
||||
alpha = 1 - (bounce * progress^3 - 1.5 * bounce * progress^2 + (0.5 * bounce + 1) * progress)
|
||||
else
|
||||
-- Always decreasing: looks better when animation is short
|
||||
alpha = 1 - progress * progress
|
||||
end
|
||||
return {
|
||||
1, 1, 1,
|
||||
alpha,
|
||||
skin, colour,
|
||||
48 + x * 16, y * 16
|
||||
}
|
||||
end
|
||||
--]]
|
||||
|
||||
-- Fadeout
|
||||
--[[
|
||||
function animation(x, y, skin, colour)
|
||||
return {
|
||||
|
@ -851,12 +983,10 @@ function GameMode:drawSectionTimesWithSplits(current_section, section_limit)
|
|||
end
|
||||
|
||||
function GameMode:drawBackground()
|
||||
local id = self:getBackground()
|
||||
if type(id) == "number" then id = clamp(id, 0, #backgrounds) end
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(
|
||||
backgrounds[self:getBackground()],
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
drawBackground(id)
|
||||
end
|
||||
|
||||
function GameMode:drawFrame()
|
||||
|
@ -906,7 +1036,7 @@ function GameMode:drawCustom() end
|
|||
|
||||
function GameMode:drawIfPaused()
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf("GAME PAUSED!", 64, 160, 160, "center")
|
||||
love.graphics.printf("PAUSED!", 64, 160, 160, "center")
|
||||
end
|
||||
|
||||
-- transforms specified in here will transform the whole screen
|
||||
|
|
|
@ -283,7 +283,7 @@ function Marathon2020Game:sectionPassed(old_level, new_level)
|
|||
)
|
||||
else
|
||||
return (
|
||||
(new_level < 2001 and math.floor(old_level / 100) < math.floor(new_level / 100)) or
|
||||
(new_level < 2000 and math.floor(old_level / 100) < math.floor(new_level / 100)) or
|
||||
(new_level >= 2020)
|
||||
)
|
||||
end
|
||||
|
@ -353,15 +353,10 @@ function Marathon2020Game:updateSectionTimes(old_level, new_level)
|
|||
self.section_start_time = self.frames
|
||||
|
||||
if (
|
||||
self.section_status[section - 1] == "cool" and
|
||||
self.secondary_section_times[section] <= self.secondary_section_times[section - 1] + 120 and
|
||||
self.secondary_section_times[section] < cool_cutoffs[self.delay_level]
|
||||
(self.secondary_section_times[section] < cool_cutoffs[self.delay_level]) and
|
||||
(section == 1 or self.secondary_section_times[section] <= self.secondary_section_times[section - 1] + 120)
|
||||
) then
|
||||
sectionCool(section)
|
||||
elseif self.section_status[section - 1] == "cool" then
|
||||
table.insert(self.section_status, "none")
|
||||
elseif self.secondary_section_times[section] < cool_cutoffs[self.delay_level] then
|
||||
sectionCool(section)
|
||||
else
|
||||
table.insert(self.section_status, "none")
|
||||
end
|
||||
|
|
|
@ -112,7 +112,7 @@ function MarathonA2Game:advanceOneFrame()
|
|||
if self.clear then
|
||||
self.roll_frames = self.roll_frames + 1
|
||||
if self.roll_frames < 0 then return false end
|
||||
if self.roll_frames > 3694 then
|
||||
if self.roll_frames > 3701 then
|
||||
self.completed = true
|
||||
if self.grade == 32 then
|
||||
self.grade = 33
|
||||
|
@ -249,10 +249,13 @@ local grade_conversion = {
|
|||
}
|
||||
|
||||
function MarathonA2Game:whilePieceActive()
|
||||
self.grade_point_decay_counter = self.grade_point_decay_counter + 1
|
||||
if self.grade_point_decay_counter >= grade_point_decays[self.grade + 1] then
|
||||
self.grade_point_decay_counter = 0
|
||||
self.grade_points = math.max(0, self.grade_points - 1)
|
||||
if self.clear then return
|
||||
else
|
||||
self.grade_point_decay_counter = self.grade_point_decay_counter + 1
|
||||
if self.grade_point_decay_counter >= grade_point_decays[self.grade + 1] then
|
||||
self.grade_point_decay_counter = 0
|
||||
self.grade_points = math.max(0, self.grade_points - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -365,10 +368,10 @@ function MarathonA2Game:drawScoringInfo()
|
|||
love.graphics.setFont(font_3x5_3)
|
||||
if self.clear then
|
||||
if self:qualifiesForMRoll() then
|
||||
if self.lines >= 32 and self.roll_frames > 3694 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||
if self.lines >= 32 and self.roll_frames > 3701 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||
else love.graphics.setColor(0, 1, 0, 1) end
|
||||
else
|
||||
if self.roll_frames > 3694 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||
if self.roll_frames > 3701 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||
else love.graphics.setColor(0, 1, 0, 1) end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,9 @@ function MarathonA3Game:new()
|
|||
self.roll_points = 0
|
||||
self.grade_point_decay_counter = 0
|
||||
self.section_cool_grade = 0
|
||||
self.section_status = { [0] = "none" }
|
||||
--self.section_status = { [0] = "none" }
|
||||
self.section_cools = { [0] = 0 }
|
||||
self.section_regrets = { [0] = 0 }
|
||||
self.section_start_time = 0
|
||||
self.secondary_section_times = { [0] = 0 }
|
||||
self.section_times = { [0] = 0 }
|
||||
|
@ -201,15 +203,23 @@ function MarathonA3Game:updateSectionTimes(old_level, new_level)
|
|||
self.speed_level = self.section_cool and self.speed_level + 100 or self.speed_level
|
||||
|
||||
if section_time > regret_cutoffs[section] then
|
||||
self.section_cool_grade = self.section_cool_grade - 1
|
||||
table.insert(self.section_status, "regret")
|
||||
if self.grade > 0 then
|
||||
--this happens after the points are added, intentionally
|
||||
local currentgrade = self:getAggregateGrade()
|
||||
while self:getAggregateGrade() >= currentgrade do
|
||||
self.grade = self.grade - 1
|
||||
end
|
||||
self.grade_points = 0
|
||||
end
|
||||
table.insert(self.section_regrets, 1)
|
||||
self.coolregret_message = "REGRET!!"
|
||||
self.coolregret_timer = 300
|
||||
elseif self.section_cool then
|
||||
self.section_cool_grade = self.section_cool_grade + 1
|
||||
table.insert(self.section_status, "cool")
|
||||
else
|
||||
table.insert(self.section_status, "none")
|
||||
table.insert(self.section_regrets, 0)
|
||||
end
|
||||
|
||||
if self.section_cool then
|
||||
self.section_cool_grade = self.section_cool_grade + 1
|
||||
end
|
||||
|
||||
self.section_cool = false
|
||||
|
@ -223,6 +233,9 @@ function MarathonA3Game:updateSectionTimes(old_level, new_level)
|
|||
self.section_cool = true
|
||||
self.coolregret_message = "COOL!!"
|
||||
self.coolregret_timer = 300
|
||||
table.insert(self.section_cools, 1)
|
||||
else
|
||||
table.insert(self.section_cools, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -309,7 +322,7 @@ local mroll_points = {10, 20, 30, 100}
|
|||
local grade_conversion = {
|
||||
[0] = 0,
|
||||
1, 2, 3, 4, 5, 5, 6, 6, 7, 7,
|
||||
7, 8, 8, 8, 9, 9, 9, 10, 11, 12, 12,
|
||||
7, 8, 8, 8, 9, 9, 9, 10, 11, 12,
|
||||
12, 12, 13, 13, 14, 14, 15, 15, 16, 16,
|
||||
17
|
||||
}
|
||||
|
@ -354,8 +367,7 @@ function MarathonA3Game:getAggregateGrade()
|
|||
return math.min(
|
||||
self.section_cool_grade +
|
||||
math.floor(self.roll_points / 100) +
|
||||
grade_conversion[self.grade],
|
||||
self.roll_frames > 3238 and 32 or 31
|
||||
grade_conversion[self.grade]
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -403,9 +415,11 @@ MarathonA3Game.mRollOpacityFunction = function(age)
|
|||
end
|
||||
|
||||
function MarathonA3Game:sectionColourFunction(section)
|
||||
if self.section_status[section] == "cool" then
|
||||
if self.section_cools[section] == 1 and self.section_regrets[section] == 1 then
|
||||
return { 1, 1, 0, 1 }
|
||||
elseif self.section_cools[section] == 1 then
|
||||
return { 0, 1, 0, 1 }
|
||||
elseif self.section_status[section] == "regret" then
|
||||
elseif self.section_regrets[section] == 1 then
|
||||
return { 1, 0, 0, 1 }
|
||||
else
|
||||
return { 1, 1, 1, 1 }
|
||||
|
|
|
@ -28,7 +28,6 @@ function PhantomManiaGame:new()
|
|||
self.combo = 1
|
||||
self.tetrises = 0
|
||||
self.section_tetrises = {[0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
self.section_req = true
|
||||
self.randomizer = History6RollsRandomizer()
|
||||
end
|
||||
|
||||
|
@ -55,7 +54,7 @@ function PhantomManiaGame:getDasLimit()
|
|||
end
|
||||
|
||||
function PhantomManiaGame:getLineClearDelay()
|
||||
return self:getLineARE()
|
||||
return self:getLineARE() - 2
|
||||
end
|
||||
|
||||
function PhantomManiaGame:getLockDelay()
|
||||
|
@ -120,11 +119,6 @@ function PhantomManiaGame:onLineClear(cleared_row_count)
|
|||
self.level = 999
|
||||
end
|
||||
self.clear = true
|
||||
for i = 0, 9 do
|
||||
if self.section_tetrises[i] < (i == 9 and 1 or 2) then
|
||||
self.section_req = false
|
||||
end
|
||||
end
|
||||
else
|
||||
self.level = new_level
|
||||
end
|
||||
|
@ -175,6 +169,10 @@ local function getLetterGrade(level, clear)
|
|||
end
|
||||
end
|
||||
|
||||
function PhantomManiaGame:qualifiesForGM()
|
||||
return true
|
||||
end
|
||||
|
||||
function PhantomManiaGame:drawScoringInfo()
|
||||
PhantomManiaGame.super.drawScoringInfo(self)
|
||||
|
||||
|
@ -195,7 +193,7 @@ function PhantomManiaGame:drawScoringInfo()
|
|||
if getLetterGrade(self.level, self.clear) ~= "" then
|
||||
if self.roll_frames > 1982 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||
elseif self.level == 999 and self.clear then love.graphics.setColor(0, 1, 0, 1) end
|
||||
if self.level == 999 and self.section_req and self.tetrises >= 31 then
|
||||
if self.level == 999 and self:qualifiesForGM() then
|
||||
love.graphics.printf("GM", text_x, 140, 90, "left")
|
||||
else
|
||||
love.graphics.printf(getLetterGrade(self.level, self.clear), text_x, 140, 90, "left")
|
||||
|
|
|
@ -41,6 +41,7 @@ function PhantomMania2Game:new()
|
|||
|
||||
self.coolregret_message = ""
|
||||
self.coolregret_timer = 0
|
||||
self.coolregrets = { [0] = 0 }
|
||||
end
|
||||
|
||||
function PhantomMania2Game:getARE()
|
||||
|
@ -202,13 +203,13 @@ end
|
|||
local cool_cutoffs = {
|
||||
frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36),
|
||||
frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30),
|
||||
frameTime(0,27), frameTime(0,27), frameTime(0,27),
|
||||
frameTime(0,30), frameTime(0,30), frameTime(0,30),
|
||||
}
|
||||
|
||||
local regret_cutoffs = {
|
||||
frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50),
|
||||
frameTime(0,40), frameTime(0,40), frameTime(0,40), frameTime(0,40), frameTime(0,40),
|
||||
frameTime(0,35), frameTime(0,35), frameTime(0,35),
|
||||
frameTime(0,42), frameTime(0,42), frameTime(0,42), frameTime(0,42), frameTime(0,42),
|
||||
frameTime(0,42), frameTime(0,42), frameTime(0,42),
|
||||
}
|
||||
|
||||
function PhantomMania2Game:updateSectionTimes(old_level, new_level)
|
||||
|
@ -219,11 +220,14 @@ function PhantomMania2Game:updateSectionTimes(old_level, new_level)
|
|||
self.section_start_time = self.frames
|
||||
if section_time <= cool_cutoffs[section] then
|
||||
self.grade = self.grade + 2
|
||||
table.insert(self.coolregrets, 2)
|
||||
self.coolregret_message = "COOL!!"
|
||||
self.coolregret_timer = 300
|
||||
elseif section_time <= regret_cutoffs[section] then
|
||||
self.grade = self.grade + 1
|
||||
table.insert(self.coolregrets, 1)
|
||||
else
|
||||
table.insert(self.coolregrets, 0)
|
||||
self.coolregret_message = "REGRET!!"
|
||||
self.coolregret_timer = 300
|
||||
end
|
||||
|
@ -292,6 +296,16 @@ function PhantomMania2Game:setHoldOpacity()
|
|||
end
|
||||
end
|
||||
|
||||
function PhantomMania2Game:sectionColourFunction(section)
|
||||
if self.coolregrets[section] == 2 then
|
||||
return { 0, 1, 0, 1 }
|
||||
elseif self.coolregrets[section] == 0 then
|
||||
return { 1, 0, 0, 1 }
|
||||
else
|
||||
return { 1, 1, 1, 1 }
|
||||
end
|
||||
end
|
||||
|
||||
function PhantomMania2Game:drawScoringInfo()
|
||||
PhantomMania2Game.super.drawScoringInfo(self)
|
||||
|
||||
|
|
|
@ -13,4 +13,14 @@ function PhantomManiaNGame:new()
|
|||
self.enable_hold = true
|
||||
end
|
||||
|
||||
function PhantomManiaNGame:qualifiesForGM()
|
||||
if self.tetrises < 31 then return false end
|
||||
for i = 0, 9 do
|
||||
if self.section_tetrises[i] < (i == 9 and 1 or 2) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return PhantomManiaNGame
|
||||
|
|
|
@ -143,7 +143,7 @@ end
|
|||
function Survival2020Game:onPieceEnter()
|
||||
if not self.clear and (
|
||||
(self.level < 1900 and self.level % 100 ~= 99) or
|
||||
self.level == 2019
|
||||
(1900 <= self.level and self.level < 2019)
|
||||
) then
|
||||
self.level = self.level + 1
|
||||
end
|
||||
|
@ -201,7 +201,7 @@ end
|
|||
|
||||
Survival2020Game.opacityFunction = function(age)
|
||||
if age > 300 then return 0
|
||||
else return 1 - Math.max(age - 240, 0) / 60 end
|
||||
else return 1 - math.max(age - 240, 0) / 60 end
|
||||
end
|
||||
|
||||
function Survival2020Game:drawGrid()
|
||||
|
@ -249,7 +249,7 @@ function Survival2020Game:drawScoringInfo()
|
|||
end
|
||||
|
||||
function Survival2020Game:getBackground()
|
||||
return math.floor(self.level / 100)
|
||||
return math.min(19, math.floor(self.level / 100))
|
||||
end
|
||||
|
||||
function Survival2020Game:getHighscoreData()
|
||||
|
|
|
@ -19,7 +19,7 @@ function SurvivalA2Game:new()
|
|||
self.roll_frames = 0
|
||||
self.combo = 1
|
||||
self.randomizer = History6RollsRandomizer()
|
||||
|
||||
|
||||
self.SGnames = {
|
||||
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
||||
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||
|
@ -101,6 +101,7 @@ function SurvivalA2Game:onLineClear(cleared_row_count)
|
|||
self.clear = true
|
||||
if new_level < 999 then
|
||||
self.game_over = true
|
||||
return
|
||||
end
|
||||
end
|
||||
self.level = new_level
|
||||
|
|
|
@ -13,7 +13,7 @@ function BagRandomizer:generatePiece()
|
|||
table.insert(self.bag, v)
|
||||
end
|
||||
end
|
||||
local x = math.random(table.getn(self.bag))
|
||||
local x = love.math.random(table.getn(self.bag))
|
||||
return table.remove(self.bag, x)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ function Bag7Randomizer:generatePiece()
|
|||
if next(self.bag) == nil then
|
||||
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
end
|
||||
local x = math.random(table.getn(self.bag))
|
||||
local x = love.math.random(table.getn(self.bag))
|
||||
return table.remove(self.bag, x)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ function Bag7NoSZOStartRandomizer:shuffleBag()
|
|||
local b = self.bag
|
||||
local ln = #b
|
||||
for i = 1, ln do
|
||||
local j = math.random(i, ln)
|
||||
local j = love.math.random(i, ln)
|
||||
b[i], b[j] = b[j], b[i]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,8 +8,13 @@ function Sequence:initialize()
|
|||
end
|
||||
|
||||
function Sequence:generatePiece()
|
||||
local piece = string.sub(self.sequence, self.counter + 1, self.counter + 1)
|
||||
self.counter = (self.counter + 1) % string.len(self.sequence)
|
||||
local piece
|
||||
if type(self.sequence) == "string" then
|
||||
piece = string.sub(self.sequence, self.counter + 1, self.counter + 1)
|
||||
else
|
||||
piece = self.sequence[self.counter + 1]
|
||||
end
|
||||
self.counter = (self.counter + 1) % (#self.sequence)
|
||||
return piece
|
||||
end
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ end
|
|||
function History4RollsRandomizer:generatePiece()
|
||||
if self.first then
|
||||
self.first = false
|
||||
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
||||
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
|
||||
else
|
||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
for i = 1, 4 do
|
||||
local x = math.random(7)
|
||||
local x = love.math.random(7)
|
||||
if not inHistory(shapes[x], self.history) or i == 4 then
|
||||
return self:updateHistory(shapes[x])
|
||||
end
|
||||
|
|
|
@ -10,11 +10,11 @@ end
|
|||
function History6RollsRandomizer:generatePiece()
|
||||
if self.first then
|
||||
self.first = false
|
||||
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
||||
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
|
||||
else
|
||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
for i = 1, 6 do
|
||||
local x = math.random(7)
|
||||
local x = love.math.random(7)
|
||||
if not inHistory(shapes[x], self.history) or i == 6 then
|
||||
return self:updateHistory(shapes[x])
|
||||
end
|
||||
|
|
|
@ -28,12 +28,12 @@ end
|
|||
function History6Rolls35PoolRandomizer:generatePiece()
|
||||
local index, x
|
||||
if self.first then
|
||||
index = math.random(20)
|
||||
index = love.math.random(20)
|
||||
x = self.pool[index]
|
||||
self.first = false
|
||||
else
|
||||
for i = 1, 6 do
|
||||
index = math.random(#self.pool)
|
||||
index = love.math.random(#self.pool)
|
||||
x = self.pool[index]
|
||||
if not inHistory(x, self.history) or i == 6 then
|
||||
break
|
||||
|
|
|
@ -16,7 +16,7 @@ function Randomizer:initialize()
|
|||
end
|
||||
|
||||
function Randomizer:generatePiece()
|
||||
return self.possible_pieces[math.random(7)]
|
||||
return self.possible_pieces[love.math.random(7)]
|
||||
end
|
||||
|
||||
return Randomizer
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
local Piece = require 'tetris.components.piece'
|
||||
local Ruleset = require 'tetris.rulesets.arika_ace2'
|
||||
|
||||
local ARS = Ruleset:extend()
|
||||
|
||||
ARS.name = "ARS-X"
|
||||
ARS.hash = "ArikaEXP"
|
||||
|
||||
ARS.MANIPULATIONS_MAX = 24
|
||||
ARS.ROTATIONS_MAX = 12
|
||||
|
||||
function ARS:onPieceCreate(piece, grid)
|
||||
piece.manipulations = 0
|
||||
piece.rotations = 0
|
||||
piece.lowest_y = -math.huge
|
||||
end
|
||||
|
||||
function ARS:checkNewLow(piece)
|
||||
for _, block in pairs(piece:getBlockOffsets()) do
|
||||
local y = piece.position.y + block.y
|
||||
if y > piece.lowest_y then
|
||||
piece.manipulations = 0
|
||||
piece.rotations = 0
|
||||
piece.lowest_y = y
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ARS:onPieceMove(piece, grid)
|
||||
piece.lock_delay = 0 -- move reset
|
||||
if piece:isDropBlocked(grid) then
|
||||
piece.manipulations = piece.manipulations + 1
|
||||
if piece.manipulations >= ARS.MANIPULATIONS_MAX then
|
||||
piece.locked = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ARS:onPieceRotate(piece, grid, upward)
|
||||
piece.lock_delay = 0 -- rotate reset
|
||||
if upward or piece:isDropBlocked(grid) then
|
||||
piece.rotations = piece.rotations + 1
|
||||
if piece.rotations >= ARS.ROTATIONS_MAX and piece:isDropBlocked(grid) then
|
||||
piece.locked = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return ARS
|
|
@ -209,7 +209,7 @@ function Ruleset:initializePiece(
|
|||
|
||||
local colours
|
||||
if table.equalvalues(
|
||||
self.colourscheme, {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
table.keys(self.colourscheme), {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
) then
|
||||
colours = ({self.colourscheme, ColourSchemes.Arika, ColourSchemes.TTC})[config.gamesettings.piece_colour]
|
||||
else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
local Piece = require 'tetris.components.piece'
|
||||
local Ruleset = require 'tetris.rulesets.standard_exp'
|
||||
local Ruleset = require 'tetris.rulesets.standard_ace'
|
||||
|
||||
local SRS = Ruleset:extend()
|
||||
|
||||
|
@ -8,6 +8,8 @@ SRS.hash = "Standard"
|
|||
SRS.softdrop_lock = false
|
||||
SRS.harddrop_lock = true
|
||||
|
||||
SRS.enable_IRS_wallkicks = true
|
||||
|
||||
SRS.MANIPULATIONS_MAX = 15
|
||||
|
||||
SRS.wallkicks_line = {
|
||||
|
@ -33,8 +35,8 @@ SRS.wallkicks_line = {
|
|||
},
|
||||
};
|
||||
|
||||
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||
|
||||
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||
local kicks
|
||||
if piece.shape == "O" then
|
||||
return
|
||||
|
@ -69,6 +71,12 @@ function SRS:checkNewLow(piece)
|
|||
end
|
||||
end
|
||||
|
||||
function SRS:onPieceCreate(piece, grid)
|
||||
piece.manipulations = 0
|
||||
piece.rotations = 0
|
||||
piece.lowest_y = -math.huge
|
||||
end
|
||||
|
||||
function SRS:onPieceDrop(piece, grid)
|
||||
self:checkNewLow(piece)
|
||||
if piece.manipulations >= self.MANIPULATIONS_MAX and piece:isDropBlocked(grid) then
|
||||
|
@ -85,6 +93,8 @@ function SRS:onPieceMove(piece, grid)
|
|||
if piece.manipulations >= SRS.MANIPULATIONS_MAX then
|
||||
piece.locked = true
|
||||
end
|
||||
else
|
||||
piece.locked = false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -102,4 +112,6 @@ end
|
|||
|
||||
function SRS:canPieceRotate() return true end
|
||||
|
||||
function SRS:get180RotationValue() return 2 end
|
||||
|
||||
return SRS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
local Piece = require 'tetris.components.piece'
|
||||
local Ruleset = require 'tetris.rulesets.ti_srs'
|
||||
local Ruleset = require 'tetris.rulesets.standard_ti'
|
||||
|
||||
local SRS = Ruleset:extend()
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
local Piece = require 'tetris.components.piece'
|
||||
local Ruleset = require 'tetris.rulesets.arika_srs'
|
||||
local Ruleset = require 'tetris.rulesets.standard_ti'
|
||||
|
||||
local SRS = Ruleset:extend()
|
||||
|
||||
|
@ -27,8 +27,6 @@ function SRS:checkNewLow(piece)
|
|||
for _, block in pairs(piece:getBlockOffsets()) do
|
||||
local y = piece.position.y + block.y
|
||||
if y > piece.lowest_y then
|
||||
--piece.manipulations = 0
|
||||
--piece.rotations = 0
|
||||
piece.lowest_y = y
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue