mirror of
https://github.com/SashLilac/cambridge.git
synced 2025-05-13 20:21:25 -05:00
Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b0fdba27d | ||
|
|
d8fad3dc37 | ||
|
|
f9368fa806 | ||
|
|
189feb1802 | ||
|
|
dc09dabacb | ||
|
|
e13278c6a8 | ||
|
|
f7f11b0e22 | ||
|
|
869a0f7ec5 | ||
|
|
10a9d97848 | ||
|
|
a470b40def | ||
|
|
fd739dcfdf | ||
|
|
e1dc01d0d0 | ||
|
|
7228707241 | ||
|
|
af86ce3a98 | ||
|
|
78ae0ae671 | ||
|
|
c614e9c4cd | ||
|
|
b27ef0e9f4 | ||
|
|
843b1e108a | ||
|
|
a8d697064c | ||
|
|
cf32474898 | ||
|
|
6a295cad59 | ||
|
|
2d80e20c82 | ||
|
|
2279c24d11 | ||
|
|
8510ad9bea | ||
|
|
6b77ad8547 | ||
|
|
6834e92674 | ||
|
|
3479374686 | ||
|
|
863c614a4c | ||
|
|
49e52c6a39 | ||
|
|
a105086ca6 | ||
|
|
1b381c4bf3 | ||
|
|
91a87fea73 | ||
|
|
28b455fcc0 | ||
|
|
2e3eff025f | ||
|
|
4670cb7c15 | ||
|
|
9b04e14388 | ||
|
|
f52da36bf7 | ||
|
|
76142c1dff | ||
|
|
a3458e2413 | ||
|
|
7eba9c012f | ||
|
|
4d2868b7b6 | ||
|
|
2e6fcd232b | ||
|
|
10833f2ec1 | ||
|
|
abb2b9491e | ||
|
|
062ab2005e | ||
|
|
468025fc80 | ||
|
|
c8544975d6 | ||
|
|
6776229bfb | ||
|
|
84b4dc5073 | ||
|
|
35dafb6615 | ||
|
|
3641d85fcb | ||
|
|
9b89c4d1de | ||
|
|
2dba120919 | ||
|
|
9224f271b1 | ||
|
|
febb5d546c | ||
|
|
c6482c423e | ||
|
|
6beb313c6b | ||
|
|
eb70f55b6e | ||
|
|
0badcde9ad | ||
|
|
6f39b591d3 | ||
|
|
129237f0b0 | ||
|
|
741c246244 | ||
|
|
b5937af8b2 | ||
|
|
33b8533d8e | ||
|
|
69959ff687 | ||
|
|
f91cd99dfd | ||
|
|
be59727ca5 | ||
|
|
cca295066c | ||
|
|
f2862b4d93 | ||
|
|
2aafd30253 | ||
|
|
b27ba335ba | ||
|
|
33244736b8 | ||
|
|
a324e0015a | ||
|
|
285108ca08 | ||
|
|
4b1fed727c | ||
|
|
d38168ca00 | ||
|
|
b0ce0f17f5 | ||
|
|
9fca272e8d | ||
|
|
5a21c8244b | ||
|
|
4923b2e2d4 | ||
|
|
8810f24e7a | ||
|
|
57a9f6ef55 | ||
|
|
342036bc28 | ||
|
|
78dcfe43c4 | ||
|
|
cdf6b5cf33 | ||
|
|
e6a60b0021 | ||
|
|
5f29c987f2 | ||
|
|
608d75b1ac | ||
|
|
1427c0d19e | ||
|
|
e221a91d73 | ||
|
|
bdcd25b82c | ||
|
|
a5158e0994 | ||
|
|
d946b17e13 | ||
|
|
69a5c0a21a | ||
|
|
b6423c3335 | ||
|
|
5b960d7291 | ||
|
|
54f4b0b890 | ||
|
|
8c62f321a0 | ||
|
|
fdffd2cd9a | ||
|
|
8ddf468121 | ||
|
|
8e77407ff2 | ||
|
|
92c852d178 | ||
|
|
f658ed63f2 | ||
|
|
c2d1c1183c | ||
|
|
36c568feaf | ||
|
|
bf30fcefbd | ||
|
|
d9f5bd16d7 | ||
|
|
d978ff8d87 | ||
|
|
b47d0f36b9 | ||
|
|
abc210c69c | ||
|
|
436e4ac861 | ||
|
|
a48d7c67b5 | ||
|
|
f6ca79ff91 | ||
|
|
4eb3901610 | ||
|
|
3f7fc4b622 | ||
|
|
ac7ae91c39 | ||
|
|
0c8e910245 | ||
|
|
6233ffb12d | ||
|
|
1f78bb9e99 | ||
|
|
a125c09106 | ||
|
|
090ffa5126 | ||
|
|
12a6f42198 | ||
|
|
0c317d9ce1 | ||
|
|
eddfee566d | ||
|
|
7fe366a8de | ||
|
|
55be30c99f | ||
|
|
36ceef8488 | ||
|
|
b59edb5e8e | ||
|
|
5d32b6a3e7 | ||
|
|
05230ac046 | ||
|
|
f28dc08ae2 | ||
|
|
ecd958bdc5 | ||
|
|
43f59cfde8 | ||
|
|
00c46961f9 | ||
|
|
0a0053276b | ||
|
|
d0f1d869a8 | ||
|
|
29ee000998 | ||
|
|
995fd7fee9 | ||
|
|
67abf35a28 | ||
|
|
9982613e26 | ||
|
|
629beb7240 | ||
|
|
4cb20101b0 | ||
|
|
63c0721978 | ||
|
|
1366451a3d | ||
|
|
6b624b9853 | ||
|
|
b0bda25466 | ||
|
|
2bde9d1378 | ||
|
|
6178b2cee9 | ||
|
|
4e8a237de3 | ||
|
|
5606251ea7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,3 +2,5 @@
|
|||||||
*.love
|
*.love
|
||||||
dist/*.zip
|
dist/*.zip
|
||||||
dist/**/cambridge.exe
|
dist/**/cambridge.exe
|
||||||
|
dist/**/libs
|
||||||
|
dist/**/*.md
|
||||||
55
README.md
55
README.md
@@ -1,41 +1,59 @@
|
|||||||
|

|
||||||
|
|
||||||
Cambridge
|
Cambridge
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Welcome to Cambridge, the next open-source falling-block game engine!
|
Welcome to Cambridge, the next open-source falling-block game engine!
|
||||||
|
|
||||||
This fork is written and maintained exclusively by [SashLilac](https://github.com/SashLilac) and [Oshisaure](https://github.com/oshisaure)!
|
This fork is written and maintained exclusively by [SashLilac](https://github.com/SashLilac), [joezeng](https://github.com/joezeng) and [Oshisaure](https://github.com/oshisaure)!
|
||||||
|
|
||||||
|
Join our Discord server for help and a welcoming community! https://discord.gg/mteMJw4
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
-------
|
-------
|
||||||
|
|
||||||
- [Lilla Oshisaure](https://www.youtube.com/user/LeSpyroshisaure) for their amazing contributions to my life in general!
|
- [Lilla Oshisaure](https://www.youtube.com/user/LeSpyroshisaure) for being my co-dev!
|
||||||
|
- [joezeng](https://github.com/joezeng) for the original project, and for offering to help with the expansion!
|
||||||
- [The Tetra Legends Discord](http://discord.com/invite/7hMx5r2) for supporting me and playtesting!
|
- [The Tetra Legends Discord](http://discord.com/invite/7hMx5r2) for supporting me and playtesting!
|
||||||
- [joezeng](https://github.com/joezeng) for the original project.
|
- [The Absolute Plus](https://discord.gg/6Gf2awJ) for being another source of motivation!
|
||||||
|
|
||||||
Installation instructions
|
The following people in no particular order also helped with the project:
|
||||||
-------------------------
|
- [Hailey](https://github.com/haileylgbt)
|
||||||
|
- CylinderKnot
|
||||||
|
- MarkGamed7794
|
||||||
|
- [Mizu](https://github.com/rexxt)
|
||||||
|
- MattMayuga
|
||||||
|
- Kitaru
|
||||||
|
- switchpalacecorner
|
||||||
|
- [sinefuse](https://github.com/sinefuse)
|
||||||
|
- [2Tie](https://github.com/2Tie)
|
||||||
|
- [nightmareci](https://github.com/nightmareci)
|
||||||
|
- [MyPasswordIsWeak](https://github.com/MyPasswordIsWeak)
|
||||||
|
|
||||||
Pre-built releases are available on the releases page.
|

|
||||||
|
|
||||||
|
Playing the game
|
||||||
|
----------------
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
Unzip the exe file and run it directly. All assets are currently bundled inside the executable.
|
You do not need LÖVE on Windows, as it comes bundled with the program.
|
||||||
|
|
||||||
### macOS
|
To get the stable release, simply download the ZIP in the latest release. All assets needed are bundled with the executable.
|
||||||
|
|
||||||
For the time being, the file `cambridge.love` only works on the command line. Install `love` with [Homebrew](https://brew.sh), and run:
|
If you want the bleeding edge version, or want mod pack support, download [this](https://github.com/SashLilac/cambridge/archive/master.zip).
|
||||||
|
|
||||||
$ love cambridge.love
|
Extract the ZIP, open a Command Prompt at the folder you extracted Cambridge to, then run this command:
|
||||||
|
|
||||||
### Linux
|
dist\windows\love.exe .
|
||||||
|
|
||||||
Same as macOS, except install `love` with your favourite package manager.
|
Alternatively, if you're on a 32-bit system, run this instead:
|
||||||
|
|
||||||
|
dist\win32\love.exe .
|
||||||
|
|
||||||
Running from source
|
32-bit systems do not support rich presence integration.
|
||||||
-------------------
|
|
||||||
|
|
||||||
If you want the bleeding-edge release, you can also clone the code straight from this repository.
|
Then, check the mod pack section at the bottom of this page.
|
||||||
|
|
||||||
### macOS, Linux
|
### macOS, Linux
|
||||||
|
|
||||||
@@ -45,12 +63,19 @@ Clone the repository in git:
|
|||||||
|
|
||||||
git clone https://github.com/SashLilac/cambridge
|
git clone https://github.com/SashLilac/cambridge
|
||||||
|
|
||||||
|
Alternatively, download the source code ZIP in the latest release.
|
||||||
|
|
||||||
Then, navigate to the root directory that you just cloned, and type:
|
Then, navigate to the root directory that you just cloned, and type:
|
||||||
|
|
||||||
love .
|
love .
|
||||||
|
|
||||||
It should run automatically!
|
It should run automatically!
|
||||||
|
|
||||||
|
## Installing modpacks
|
||||||
|
|
||||||
|
Simply drag your mode, ruleset, and randomizer Lua files into their respective directory, and they should appear automatically.
|
||||||
|
|
||||||
|
Alternatively, install [this](https://github.com/SashLilac/cambridge-modpack) mod pack to get a taste of the mod potential.
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|||||||
11
clean.bat
Normal file
11
clean.bat
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@del cambridge.love
|
||||||
|
@del dist\windows\cambridge.exe
|
||||||
|
@del dist\windows\SOURCES.md
|
||||||
|
@del dist\windows\LICENSE.md
|
||||||
|
@rmdir /Q /S dist\windows\libs
|
||||||
|
@del dist\win32\cambridge.exe
|
||||||
|
@del dist\win32\SOURCES.md
|
||||||
|
@del dist\win32\LICENSE.md
|
||||||
|
@rmdir /Q /S dist\win32\libs
|
||||||
|
@del dist\cambridge-windows.zip
|
||||||
|
@del dist\cambridge-win32.zip
|
||||||
@@ -62,3 +62,8 @@ function formatBigNum(number)
|
|||||||
return string.sub(s, 1, pos)
|
return string.sub(s, 1, pos)
|
||||||
.. string.gsub(string.sub(s, pos+1), "(...)", ",%1")
|
.. string.gsub(string.sub(s, pos+1), "(...)", ",%1")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Mod1(n, m)
|
||||||
|
-- returns a number congruent to n modulo m in the range [1;m] (as opposed to [0;m-1])
|
||||||
|
return ((n-1) % m) + 1
|
||||||
|
end
|
||||||
BIN
libs/discord-rpc.dll
Normal file
BIN
libs/discord-rpc.dll
Normal file
Binary file not shown.
BIN
libs/discord-rpc.dylib
Normal file
BIN
libs/discord-rpc.dylib
Normal file
Binary file not shown.
BIN
libs/discord-rpc.so
Normal file
BIN
libs/discord-rpc.so
Normal file
Binary file not shown.
282
libs/discordRPC.lua
Normal file
282
libs/discordRPC.lua
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
local ffi = require "ffi"
|
||||||
|
|
||||||
|
|
||||||
|
-- Get the host os to load correct lib
|
||||||
|
local osname = love.system.getOS()
|
||||||
|
local discordRPClib = nil
|
||||||
|
|
||||||
|
-- FFI requires the libraries really be files just sitting in the filesystem. It
|
||||||
|
-- can't load libraries from a .love archive, nor a fused executable on Windows.
|
||||||
|
-- Merely using love.filesystem.getSource() only works when running LOVE with
|
||||||
|
-- the game unarchived from command line, like "love .".
|
||||||
|
--
|
||||||
|
-- The code here setting "source" will set the directory where the game was run
|
||||||
|
-- from, so FFI can load discordRPC. We assume that the discordRPC library's
|
||||||
|
-- libs directory is in the same directory as the .love archive; if it's
|
||||||
|
-- missing, it just won't load.
|
||||||
|
local source = love.filesystem.getSource()
|
||||||
|
if string.sub(source, -5) == ".love" or love.filesystem.isFused() then
|
||||||
|
source = love.filesystem.getSourceBaseDirectory()
|
||||||
|
end
|
||||||
|
|
||||||
|
if osname == "Linux" then
|
||||||
|
discordRPClib = ffi.load(source.."/libs/discord-rpc.so")
|
||||||
|
elseif osname == "OS X" then
|
||||||
|
discordRPClib = ffi.load(source.."/libs/discord-rpc.dylib")
|
||||||
|
elseif osname == "Windows" then
|
||||||
|
discordRPClib = ffi.load(source.."/libs/discord-rpc.dll")
|
||||||
|
else
|
||||||
|
-- Else it crashes later on
|
||||||
|
error(string.format("Discord rpc not supported on platform (%s)", osname))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
ffi.cdef[[
|
||||||
|
typedef struct DiscordRichPresence {
|
||||||
|
const char* state; /* max 128 bytes */
|
||||||
|
const char* details; /* max 128 bytes */
|
||||||
|
int64_t startTimestamp;
|
||||||
|
int64_t endTimestamp;
|
||||||
|
const char* largeImageKey; /* max 32 bytes */
|
||||||
|
const char* largeImageText; /* max 128 bytes */
|
||||||
|
const char* smallImageKey; /* max 32 bytes */
|
||||||
|
const char* smallImageText; /* max 128 bytes */
|
||||||
|
const char* partyId; /* max 128 bytes */
|
||||||
|
int partySize;
|
||||||
|
int partyMax;
|
||||||
|
const char* matchSecret; /* max 128 bytes */
|
||||||
|
const char* joinSecret; /* max 128 bytes */
|
||||||
|
const char* spectateSecret; /* max 128 bytes */
|
||||||
|
int8_t instance;
|
||||||
|
} DiscordRichPresence;
|
||||||
|
|
||||||
|
typedef struct DiscordUser {
|
||||||
|
const char* userId;
|
||||||
|
const char* username;
|
||||||
|
const char* discriminator;
|
||||||
|
const char* avatar;
|
||||||
|
} DiscordUser;
|
||||||
|
|
||||||
|
typedef void (*readyPtr)(const DiscordUser* request);
|
||||||
|
typedef void (*disconnectedPtr)(int errorCode, const char* message);
|
||||||
|
typedef void (*erroredPtr)(int errorCode, const char* message);
|
||||||
|
typedef void (*joinGamePtr)(const char* joinSecret);
|
||||||
|
typedef void (*spectateGamePtr)(const char* spectateSecret);
|
||||||
|
typedef void (*joinRequestPtr)(const DiscordUser* request);
|
||||||
|
|
||||||
|
typedef struct DiscordEventHandlers {
|
||||||
|
readyPtr ready;
|
||||||
|
disconnectedPtr disconnected;
|
||||||
|
erroredPtr errored;
|
||||||
|
joinGamePtr joinGame;
|
||||||
|
spectateGamePtr spectateGame;
|
||||||
|
joinRequestPtr joinRequest;
|
||||||
|
} DiscordEventHandlers;
|
||||||
|
|
||||||
|
void Discord_Initialize(const char* applicationId,
|
||||||
|
DiscordEventHandlers* handlers,
|
||||||
|
int autoRegister,
|
||||||
|
const char* optionalSteamId);
|
||||||
|
|
||||||
|
void Discord_Shutdown(void);
|
||||||
|
|
||||||
|
void Discord_RunCallbacks(void);
|
||||||
|
|
||||||
|
void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||||
|
|
||||||
|
void Discord_ClearPresence(void);
|
||||||
|
|
||||||
|
void Discord_Respond(const char* userid, int reply);
|
||||||
|
|
||||||
|
void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
|
||||||
|
]]
|
||||||
|
|
||||||
|
local discordRPC = {} -- module table
|
||||||
|
|
||||||
|
-- proxy to detect garbage collection of the module
|
||||||
|
discordRPC.gcDummy = newproxy(true)
|
||||||
|
|
||||||
|
local function unpackDiscordUser(request)
|
||||||
|
return ffi.string(request.userId), ffi.string(request.username),
|
||||||
|
ffi.string(request.discriminator), ffi.string(request.avatar)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- callback proxies
|
||||||
|
-- note: callbacks are not JIT compiled (= SLOW), try to avoid doing performance critical tasks in them
|
||||||
|
-- luajit.org/ext_ffi_semantics.html
|
||||||
|
local ready_proxy = ffi.cast("readyPtr", function(request)
|
||||||
|
if discordRPC.ready then
|
||||||
|
discordRPC.ready(unpackDiscordUser(request))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local disconnected_proxy = ffi.cast("disconnectedPtr", function(errorCode, message)
|
||||||
|
if discordRPC.disconnected then
|
||||||
|
discordRPC.disconnected(errorCode, ffi.string(message))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local errored_proxy = ffi.cast("erroredPtr", function(errorCode, message)
|
||||||
|
if discordRPC.errored then
|
||||||
|
discordRPC.errored(errorCode, ffi.string(message))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local joinGame_proxy = ffi.cast("joinGamePtr", function(joinSecret)
|
||||||
|
if discordRPC.joinGame then
|
||||||
|
discordRPC.joinGame(ffi.string(joinSecret))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local spectateGame_proxy = ffi.cast("spectateGamePtr", function(spectateSecret)
|
||||||
|
if discordRPC.spectateGame then
|
||||||
|
discordRPC.spectateGame(ffi.string(spectateSecret))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local joinRequest_proxy = ffi.cast("joinRequestPtr", function(request)
|
||||||
|
if discordRPC.joinRequest then
|
||||||
|
discordRPC.joinRequest(unpackDiscordUser(request))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- helpers
|
||||||
|
local function checkArg(arg, argType, argName, func, maybeNil)
|
||||||
|
assert(type(arg) == argType or (maybeNil and arg == nil),
|
||||||
|
string.format("Argument \"%s\" to function \"%s\" has to be of type \"%s\"",
|
||||||
|
argName, func, argType))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function checkStrArg(arg, maxLen, argName, func, maybeNil)
|
||||||
|
if maxLen then
|
||||||
|
assert(type(arg) == "string" and arg:len() <= maxLen or (maybeNil and arg == nil),
|
||||||
|
string.format("Argument \"%s\" of function \"%s\" has to be of type string with maximum length %d",
|
||||||
|
argName, func, maxLen))
|
||||||
|
else
|
||||||
|
checkArg(arg, "string", argName, func, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function checkIntArg(arg, maxBits, argName, func, maybeNil)
|
||||||
|
maxBits = math.min(maxBits or 32, 52) -- lua number (double) can only store integers < 2^53
|
||||||
|
local maxVal = 2^(maxBits-1) -- assuming signed integers, which, for now, are the only ones in use
|
||||||
|
assert(type(arg) == "number" and math.floor(arg) == arg
|
||||||
|
and arg < maxVal and arg >= -maxVal
|
||||||
|
or (maybeNil and arg == nil),
|
||||||
|
string.format("Argument \"%s\" of function \"%s\" has to be a whole number <= %d",
|
||||||
|
argName, func, maxVal))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- function wrappers
|
||||||
|
function discordRPC.initialize(applicationId, autoRegister, optionalSteamId)
|
||||||
|
local func = "discordRPC.Initialize"
|
||||||
|
checkStrArg(applicationId, nil, "applicationId", func)
|
||||||
|
checkArg(autoRegister, "boolean", "autoRegister", func)
|
||||||
|
if optionalSteamId ~= nil then
|
||||||
|
checkStrArg(optionalSteamId, nil, "optionalSteamId", func)
|
||||||
|
end
|
||||||
|
|
||||||
|
local eventHandlers = ffi.new("struct DiscordEventHandlers")
|
||||||
|
eventHandlers.ready = ready_proxy
|
||||||
|
eventHandlers.disconnected = disconnected_proxy
|
||||||
|
eventHandlers.errored = errored_proxy
|
||||||
|
eventHandlers.joinGame = joinGame_proxy
|
||||||
|
eventHandlers.spectateGame = spectateGame_proxy
|
||||||
|
eventHandlers.joinRequest = joinRequest_proxy
|
||||||
|
|
||||||
|
discordRPClib.Discord_Initialize(applicationId, eventHandlers,
|
||||||
|
autoRegister and 1 or 0, optionalSteamId)
|
||||||
|
end
|
||||||
|
|
||||||
|
function discordRPC.shutdown()
|
||||||
|
discordRPClib.Discord_Shutdown()
|
||||||
|
end
|
||||||
|
|
||||||
|
function discordRPC.runCallbacks()
|
||||||
|
discordRPClib.Discord_RunCallbacks()
|
||||||
|
end
|
||||||
|
-- http://luajit.org/ext_ffi_semantics.html#callback :
|
||||||
|
-- It is not allowed, to let an FFI call into a C function (runCallbacks)
|
||||||
|
-- get JIT-compiled, which in turn calls a callback, calling into Lua again (e.g. discordRPC.ready).
|
||||||
|
-- Usually this attempt is caught by the interpreter first and the C function
|
||||||
|
-- is blacklisted for compilation.
|
||||||
|
-- solution:
|
||||||
|
-- "Then you'll need to manually turn off JIT-compilation with jit.off() for
|
||||||
|
-- the surrounding Lua function that invokes such a message polling function."
|
||||||
|
jit.off(discordRPC.runCallbacks)
|
||||||
|
|
||||||
|
function discordRPC.updatePresence(presence)
|
||||||
|
local func = "discordRPC.updatePresence"
|
||||||
|
checkArg(presence, "table", "presence", func)
|
||||||
|
|
||||||
|
-- -1 for string length because of 0-termination
|
||||||
|
checkStrArg(presence.state, 127, "presence.state", func, true)
|
||||||
|
checkStrArg(presence.details, 127, "presence.details", func, true)
|
||||||
|
|
||||||
|
checkIntArg(presence.startTimestamp, 64, "presence.startTimestamp", func, true)
|
||||||
|
checkIntArg(presence.endTimestamp, 64, "presence.endTimestamp", func, true)
|
||||||
|
|
||||||
|
checkStrArg(presence.largeImageKey, 31, "presence.largeImageKey", func, true)
|
||||||
|
checkStrArg(presence.largeImageText, 127, "presence.largeImageText", func, true)
|
||||||
|
checkStrArg(presence.smallImageKey, 31, "presence.smallImageKey", func, true)
|
||||||
|
checkStrArg(presence.smallImageText, 127, "presence.smallImageText", func, true)
|
||||||
|
checkStrArg(presence.partyId, 127, "presence.partyId", func, true)
|
||||||
|
|
||||||
|
checkIntArg(presence.partySize, 32, "presence.partySize", func, true)
|
||||||
|
checkIntArg(presence.partyMax, 32, "presence.partyMax", func, true)
|
||||||
|
|
||||||
|
checkStrArg(presence.matchSecret, 127, "presence.matchSecret", func, true)
|
||||||
|
checkStrArg(presence.joinSecret, 127, "presence.joinSecret", func, true)
|
||||||
|
checkStrArg(presence.spectateSecret, 127, "presence.spectateSecret", func, true)
|
||||||
|
|
||||||
|
checkIntArg(presence.instance, 8, "presence.instance", func, true)
|
||||||
|
|
||||||
|
local cpresence = ffi.new("struct DiscordRichPresence")
|
||||||
|
cpresence.state = presence.state
|
||||||
|
cpresence.details = presence.details
|
||||||
|
cpresence.startTimestamp = presence.startTimestamp or 0
|
||||||
|
cpresence.endTimestamp = presence.endTimestamp or 0
|
||||||
|
cpresence.largeImageKey = presence.largeImageKey
|
||||||
|
cpresence.largeImageText = presence.largeImageText
|
||||||
|
cpresence.smallImageKey = presence.smallImageKey
|
||||||
|
cpresence.smallImageText = presence.smallImageText
|
||||||
|
cpresence.partyId = presence.partyId
|
||||||
|
cpresence.partySize = presence.partySize or 0
|
||||||
|
cpresence.partyMax = presence.partyMax or 0
|
||||||
|
cpresence.matchSecret = presence.matchSecret
|
||||||
|
cpresence.joinSecret = presence.joinSecret
|
||||||
|
cpresence.spectateSecret = presence.spectateSecret
|
||||||
|
cpresence.instance = presence.instance or 0
|
||||||
|
|
||||||
|
discordRPClib.Discord_UpdatePresence(cpresence)
|
||||||
|
end
|
||||||
|
|
||||||
|
function discordRPC.clearPresence()
|
||||||
|
discordRPClib.Discord_ClearPresence()
|
||||||
|
end
|
||||||
|
|
||||||
|
local replyMap = {
|
||||||
|
no = 0,
|
||||||
|
yes = 1,
|
||||||
|
ignore = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
-- maybe let reply take ints too (0, 1, 2) and add constants to the module
|
||||||
|
function discordRPC.respond(userId, reply)
|
||||||
|
checkStrArg(userId, nil, "userId", "discordRPC.respond")
|
||||||
|
assert(replyMap[reply], "Argument 'reply' to discordRPC.respond has to be one of \"yes\", \"no\" or \"ignore\"")
|
||||||
|
discordRPClib.Discord_Respond(userId, replyMap[reply])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- garbage collection callback
|
||||||
|
getmetatable(discordRPC.gcDummy).__gc = function()
|
||||||
|
discordRPC.shutdown()
|
||||||
|
ready_proxy:free()
|
||||||
|
disconnected_proxy:free()
|
||||||
|
errored_proxy:free()
|
||||||
|
joinGame_proxy:free()
|
||||||
|
spectateGame_proxy:free()
|
||||||
|
joinRequest_proxy:free()
|
||||||
|
end
|
||||||
|
|
||||||
|
return discordRPC
|
||||||
@@ -6,7 +6,7 @@ bgm = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local current_bgm = nil
|
local current_bgm = nil
|
||||||
local bgm_locked = false
|
local bgm_locked = true
|
||||||
|
|
||||||
function switchBGM(sound, subsound)
|
function switchBGM(sound, subsound)
|
||||||
if bgm_locked then return end
|
if bgm_locked then return end
|
||||||
|
|||||||
@@ -20,35 +20,58 @@ backgrounds = {
|
|||||||
love.graphics.newImage("res/backgrounds/1800-railways.png"),
|
love.graphics.newImage("res/backgrounds/1800-railways.png"),
|
||||||
love.graphics.newImage("res/backgrounds/1900-world-wide-web.png"),
|
love.graphics.newImage("res/backgrounds/1900-world-wide-web.png"),
|
||||||
title = love.graphics.newImage("res/backgrounds/title_v0.1.png"),
|
title = love.graphics.newImage("res/backgrounds/title_v0.1.png"),
|
||||||
|
input_config = love.graphics.newImage("res/backgrounds/options-pcb.png"),
|
||||||
|
game_config = love.graphics.newImage("res/backgrounds/options-gears.png"),
|
||||||
}
|
}
|
||||||
|
|
||||||
blocks = {
|
blocks = {
|
||||||
["2tie"] = {
|
["2tie"] = {
|
||||||
I = love.graphics.newImage("res/img/s1.png"),
|
R = love.graphics.newImage("res/img/s1.png"),
|
||||||
J = love.graphics.newImage("res/img/s4.png"),
|
O = love.graphics.newImage("res/img/s3.png"),
|
||||||
L = love.graphics.newImage("res/img/s3.png"),
|
Y = love.graphics.newImage("res/img/s7.png"),
|
||||||
O = love.graphics.newImage("res/img/s7.png"),
|
G = love.graphics.newImage("res/img/s6.png"),
|
||||||
S = love.graphics.newImage("res/img/s5.png"),
|
C = love.graphics.newImage("res/img/s2.png"),
|
||||||
T = love.graphics.newImage("res/img/s2.png"),
|
B = love.graphics.newImage("res/img/s4.png"),
|
||||||
Z = love.graphics.newImage("res/img/s6.png"),
|
M = love.graphics.newImage("res/img/s5.png"),
|
||||||
F = love.graphics.newImage("res/img/s9.png"),
|
F = love.graphics.newImage("res/img/s9.png"),
|
||||||
G = love.graphics.newImage("res/img/s9.png"),
|
A = love.graphics.newImage("res/img/s8.png"),
|
||||||
X = love.graphics.newImage("res/img/s9.png"),
|
X = love.graphics.newImage("res/img/s9.png"),
|
||||||
},
|
},
|
||||||
["bone"] = {
|
["bone"] = {
|
||||||
I = love.graphics.newImage("res/img/bone.png"),
|
R = love.graphics.newImage("res/img/bone.png"),
|
||||||
J = love.graphics.newImage("res/img/bone.png"),
|
|
||||||
L = love.graphics.newImage("res/img/bone.png"),
|
|
||||||
O = love.graphics.newImage("res/img/bone.png"),
|
O = love.graphics.newImage("res/img/bone.png"),
|
||||||
S = love.graphics.newImage("res/img/bone.png"),
|
Y = love.graphics.newImage("res/img/bone.png"),
|
||||||
T = love.graphics.newImage("res/img/bone.png"),
|
|
||||||
Z = love.graphics.newImage("res/img/bone.png"),
|
|
||||||
F = love.graphics.newImage("res/img/bone.png"),
|
|
||||||
G = love.graphics.newImage("res/img/bone.png"),
|
G = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
C = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
B = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
M = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
F = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
A = love.graphics.newImage("res/img/bone.png"),
|
||||||
X = love.graphics.newImage("res/img/bone.png"),
|
X = love.graphics.newImage("res/img/bone.png"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColourSchemes = {
|
||||||
|
Arika = {
|
||||||
|
I = "R",
|
||||||
|
L = "O",
|
||||||
|
J = "B",
|
||||||
|
S = "M",
|
||||||
|
Z = "G",
|
||||||
|
O = "Y",
|
||||||
|
T = "C",
|
||||||
|
},
|
||||||
|
TTC = {
|
||||||
|
I = "C",
|
||||||
|
L = "O",
|
||||||
|
J = "B",
|
||||||
|
S = "G",
|
||||||
|
Z = "R",
|
||||||
|
O = "Y",
|
||||||
|
T = "M",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
for name, blockset in pairs(blocks) do
|
for name, blockset in pairs(blocks) do
|
||||||
for shape, image in pairs(blockset) do
|
for shape, image in pairs(blockset) do
|
||||||
image:setFilter("nearest")
|
image:setFilter("nearest")
|
||||||
|
|||||||
58
load/rpc.lua
Normal file
58
load/rpc.lua
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
print("Loading discord RPC...")
|
||||||
|
DiscordRPC = {
|
||||||
|
loaded = false
|
||||||
|
}
|
||||||
|
local success, RPC = pcall(require, "libs.discordRPC")
|
||||||
|
if success then
|
||||||
|
DiscordRPC.loaded = true
|
||||||
|
DiscordRPC.appId = "599778517789573120"
|
||||||
|
|
||||||
|
function RPC.ready(userId, username, discriminator, avatar)
|
||||||
|
print(string.format("Discord: ready (%s, %s, %s, %s)", userId, username, discriminator, avatar))
|
||||||
|
end
|
||||||
|
|
||||||
|
function RPC.disconnected(errorCode, message)
|
||||||
|
print(string.format("Discord: disconnected (%d: %s)", errorCode, message))
|
||||||
|
end
|
||||||
|
|
||||||
|
function RPC.errored(errorCode, message)
|
||||||
|
print(string.format("Discord: error (%d: %s)", errorCode, message))
|
||||||
|
end
|
||||||
|
|
||||||
|
function RPC.joinGame(joinSecret)
|
||||||
|
print(string.format("Discord: join (%s)", joinSecret))
|
||||||
|
end
|
||||||
|
|
||||||
|
function RPC.spectateGame(spectateSecret)
|
||||||
|
print(string.format("Discord: spectate (%s)", spectateSecret))
|
||||||
|
end
|
||||||
|
|
||||||
|
function RPC.joinRequest(userId, username, discriminator, avatar)
|
||||||
|
print(string.format("Discord: join request (%s, %s, %s, %s)", userId, username, discriminator, avatar))
|
||||||
|
RPC.respond(userId, "yes")
|
||||||
|
end
|
||||||
|
|
||||||
|
RPC.initialize(DiscordRPC.appId, true)
|
||||||
|
local now = os.time(os.date("*t"))
|
||||||
|
|
||||||
|
DiscordRPC.RPC = RPC
|
||||||
|
print("DiscordRPC successfully loaded.")
|
||||||
|
else
|
||||||
|
print("DiscordRPC failed to load!")
|
||||||
|
print(RPC)
|
||||||
|
end
|
||||||
|
|
||||||
|
DiscordRPC.presence = {
|
||||||
|
startTimestamp = now,
|
||||||
|
details = "Loading game...",
|
||||||
|
state = "",
|
||||||
|
largeImageKey = "icon2",
|
||||||
|
largeImageText = "Arcade Stacker",
|
||||||
|
smallImageKey = "",
|
||||||
|
smallImageText = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
function DiscordRPC:update(newstuff)
|
||||||
|
for k, v in pairs(newstuff) do self.presence[k] = v end
|
||||||
|
if self.loaded then self.RPC.updatePresence(self.presence) end
|
||||||
|
end
|
||||||
@@ -10,11 +10,21 @@ sounds = {
|
|||||||
},
|
},
|
||||||
move = love.audio.newSource("res/se/move.wav", "static"),
|
move = love.audio.newSource("res/se/move.wav", "static"),
|
||||||
bottom = love.audio.newSource("res/se/bottom.wav", "static"),
|
bottom = love.audio.newSource("res/se/bottom.wav", "static"),
|
||||||
|
cursor = love.audio.newSource("res/se/cursor.wav", "static"),
|
||||||
|
cursor_lr = love.audio.newSource("res/se/cursor_lr.wav", "static"),
|
||||||
|
main_decide = love.audio.newSource("res/se/main_decide.wav", "static"),
|
||||||
|
mode_decide = love.audio.newSource("res/se/mode_decide.wav", "static"),
|
||||||
|
lock = love.audio.newSource("res/se/lock.wav", "static"),
|
||||||
|
hold = love.audio.newSource("res/se/hold.wav", "static"),
|
||||||
|
erase = love.audio.newSource("res/se/erase.wav", "static"),
|
||||||
|
fall = love.audio.newSource("res/se/fall.wav", "static"),
|
||||||
|
ready = love.audio.newSource("res/se/ready.wav", "static"),
|
||||||
|
go = love.audio.newSource("res/se/go.wav", "static"),
|
||||||
}
|
}
|
||||||
|
|
||||||
function playSE(sound, subsound)
|
function playSE(sound, subsound)
|
||||||
if subsound == nil then
|
if subsound == nil then
|
||||||
sounds[sound]:setVolume(0.1)
|
sounds[sound]:setVolume(0.5)
|
||||||
if sounds[sound]:isPlaying() then
|
if sounds[sound]:isPlaying() then
|
||||||
sounds[sound]:stop()
|
sounds[sound]:stop()
|
||||||
end
|
end
|
||||||
@@ -27,3 +37,19 @@ function playSE(sound, subsound)
|
|||||||
sounds[sound][subsound]:play()
|
sounds[sound][subsound]:play()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function playSEOnce(sound, subsound)
|
||||||
|
if subsound == nil then
|
||||||
|
sounds[sound]:setVolume(0.5)
|
||||||
|
if sounds[sound]:isPlaying() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
sounds[sound]:play()
|
||||||
|
else
|
||||||
|
sounds[sound][subsound]:setVolume(0.5)
|
||||||
|
if sounds[sound][subsound]:isPlaying() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
sounds[sound][subsound]:play()
|
||||||
|
end
|
||||||
|
end
|
||||||
146
main.lua
146
main.lua
@@ -1,6 +1,7 @@
|
|||||||
function love.load()
|
function love.load()
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
highscores = {}
|
highscores = {}
|
||||||
|
require "load.rpc"
|
||||||
require "load.graphics"
|
require "load.graphics"
|
||||||
require "load.fonts"
|
require "load.fonts"
|
||||||
require "load.sounds"
|
require "load.sounds"
|
||||||
@@ -14,14 +15,42 @@ function love.load()
|
|||||||
|
|
||||||
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
||||||
|
|
||||||
|
if not config.gamesettings then config.gamesettings = {} end
|
||||||
|
for _, option in ipairs(GameConfigScene.options) do
|
||||||
|
if not config.gamesettings[option[1]] then
|
||||||
|
config.gamesettings[option[1]] = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if not config.input then
|
if not config.input then
|
||||||
config.input = {}
|
|
||||||
scene = InputConfigScene()
|
scene = InputConfigScene()
|
||||||
else
|
else
|
||||||
if config.current_mode then current_mode = config.current_mode end
|
if config.current_mode then current_mode = config.current_mode end
|
||||||
if config.current_ruleset then current_ruleset = config.current_ruleset end
|
if config.current_ruleset then current_ruleset = config.current_ruleset end
|
||||||
scene = TitleScene()
|
scene = TitleScene()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
game_modes = {}
|
||||||
|
mode_list = love.filesystem.getDirectoryItems("tetris/modes")
|
||||||
|
for i=1,#mode_list do
|
||||||
|
if(mode_list[i] ~= "gamemode.lua" and mode_list[i] ~= "unrefactored_modes") then
|
||||||
|
game_modes[#game_modes+1] = require ("tetris.modes."..string.sub(mode_list[i],1,-5))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rulesets = {}
|
||||||
|
rule_list = love.filesystem.getDirectoryItems("tetris/rulesets")
|
||||||
|
for i=1,#rule_list do
|
||||||
|
if(rule_list[i] ~= "ruleset.lua" and rule_list[i] ~= "unrefactored_rulesets") then
|
||||||
|
rulesets[#rulesets+1] = require ("tetris.rulesets."..string.sub(rule_list[i],1,-5))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--sort mode/rule lists
|
||||||
|
local function padnum(d) return ("%03d%s"):format(#d, d) end
|
||||||
|
table.sort(game_modes, function(a,b)
|
||||||
|
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
||||||
|
table.sort(rulesets, function(a,b)
|
||||||
|
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local TARGET_FPS = 60
|
local TARGET_FPS = 60
|
||||||
@@ -80,13 +109,124 @@ function love.draw()
|
|||||||
love.graphics.pop()
|
love.graphics.pop()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key, scancode, isrepeat)
|
function love.keypressed(key, scancode)
|
||||||
-- global hotkeys
|
-- global hotkeys
|
||||||
if scancode == "f4" then
|
if scancode == "f4" then
|
||||||
config["fullscreen"] = not config["fullscreen"]
|
config["fullscreen"] = not config["fullscreen"]
|
||||||
love.window.setFullscreen(config["fullscreen"])
|
love.window.setFullscreen(config["fullscreen"])
|
||||||
|
elseif scancode == "f2" and scene.title ~= "Input Config" and scene.title ~= "Game" then
|
||||||
|
scene = InputConfigScene()
|
||||||
|
-- function keys are reserved
|
||||||
|
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
||||||
|
return
|
||||||
|
-- escape is reserved for menu_back
|
||||||
|
elseif scancode == "escape" then
|
||||||
|
scene:onInputPress({input="menu_back", type="key", key=key, scancode=scancode})
|
||||||
|
-- pass any other key to the scene, with its configured mapping
|
||||||
else
|
else
|
||||||
scene:onKeyPress({key=key, scancode=scancode, isRepeat=isrepeat})
|
local input_pressed = nil
|
||||||
|
if config.input and config.input.keys then
|
||||||
|
input_pressed = config.input.keys[scancode]
|
||||||
|
end
|
||||||
|
scene:onInputPress({input=input_pressed, type="key", key=key, scancode=scancode})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.keyreleased(key, scancode)
|
||||||
|
-- escape is reserved for menu_back
|
||||||
|
if scancode == "escape" then
|
||||||
|
scene:onInputRelease({input="menu_back", type="key", key=key, scancode=scancode})
|
||||||
|
-- function keys are reserved
|
||||||
|
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
||||||
|
return
|
||||||
|
-- handle all other keys; tab is reserved, but the input config scene keeps it from getting configured as a game input, so pass tab to the scene here
|
||||||
|
else
|
||||||
|
local input_released = nil
|
||||||
|
if config.input and config.input.keys then
|
||||||
|
input_released = config.input.keys[scancode]
|
||||||
|
end
|
||||||
|
scene:onInputRelease({input=input_released, type="key", key=key, scancode=scancode})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.joystickpressed(joystick, button)
|
||||||
|
local input_pressed = nil
|
||||||
|
if
|
||||||
|
config.input and
|
||||||
|
config.input.joysticks and
|
||||||
|
config.input.joysticks[joystick:getName()] and
|
||||||
|
config.input.joysticks[joystick:getName()].buttons
|
||||||
|
then
|
||||||
|
input_pressed = config.input.joysticks[joystick:getName()].buttons[button]
|
||||||
|
end
|
||||||
|
scene:onInputPress({input=input_pressed, type="joybutton", name=joystick:getName(), button=button})
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.joystickreleased(joystick, button)
|
||||||
|
local input_released = nil
|
||||||
|
if
|
||||||
|
config.input and
|
||||||
|
config.input.joysticks and
|
||||||
|
config.input.joysticks[joystick:getName()] and
|
||||||
|
config.input.joysticks[joystick:getName()].buttons
|
||||||
|
then
|
||||||
|
input_released = config.input.joysticks[joystick:getName()].buttons[button]
|
||||||
|
end
|
||||||
|
scene:onInputRelease({input=input_released, type="joybutton", name=joystick:getName(), button=button})
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.joystickaxis(joystick, axis, value)
|
||||||
|
local input_pressed = nil
|
||||||
|
local positive_released = nil
|
||||||
|
local negative_released = nil
|
||||||
|
if
|
||||||
|
config.input and
|
||||||
|
config.input.joysticks and
|
||||||
|
config.input.joysticks[joystick:getName()] and
|
||||||
|
config.input.joysticks[joystick:getName()].axes and
|
||||||
|
config.input.joysticks[joystick:getName()].axes[axis]
|
||||||
|
then
|
||||||
|
if math.abs(value) >= 0.5 then
|
||||||
|
input_pressed = config.input.joysticks[joystick:getName()].axes[axis][value >= 0.5 and "positive" or "negative"]
|
||||||
|
end
|
||||||
|
positive_released = config.input.joysticks[joystick:getName()].axes[axis].positive
|
||||||
|
negative_released = config.input.joysticks[joystick:getName()].axes[axis].negative
|
||||||
|
end
|
||||||
|
if math.abs(value) >= 0.5 then
|
||||||
|
scene:onInputPress({input=input_pressed, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
||||||
|
else
|
||||||
|
scene:onInputRelease({input=positive_released, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
||||||
|
scene:onInputRelease({input=negative_released, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.joystickhat(joystick, hat, direction)
|
||||||
|
local input_pressed = nil
|
||||||
|
local has_hat = false
|
||||||
|
if
|
||||||
|
config.input and
|
||||||
|
config.input.joysticks and
|
||||||
|
config.input.joysticks[joystick:getName()] and
|
||||||
|
config.input.joysticks[joystick:getName()].hats and
|
||||||
|
config.input.joysticks[joystick:getName()].hats[hat]
|
||||||
|
then
|
||||||
|
if direction ~= "c" then
|
||||||
|
input_pressed = config.input.joysticks[joystick:getName()].hats[hat][direction]
|
||||||
|
end
|
||||||
|
has_hat = true
|
||||||
|
end
|
||||||
|
if input_pressed then
|
||||||
|
scene:onInputPress({input=input_pressed, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
|
elseif has_hat then
|
||||||
|
for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do
|
||||||
|
scene:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][direction], type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
|
end
|
||||||
|
elseif direction ~= "c" then
|
||||||
|
scene:onInputPress({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
|
else
|
||||||
|
for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do
|
||||||
|
scene:onInputRelease({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
2
package.bat
Normal file
2
package.bat
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
tar -a -c -f cambridge.zip libs/binser.lua libs/classic.lua libs/discordRPC.lua load res scene tetris conf.lua main.lua scene.lua funcs.lua
|
||||||
|
rename cambridge.zip cambridge.love
|
||||||
26
release.bat
Normal file
26
release.bat
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
call package.bat
|
||||||
|
|
||||||
|
mkdir dist
|
||||||
|
mkdir dist\windows
|
||||||
|
mkdir dist\windows\libs
|
||||||
|
mkdir dist\win32
|
||||||
|
mkdir dist\win32\libs
|
||||||
|
|
||||||
|
copy /b dist\windows\love.exe+cambridge.love dist\windows\cambridge.exe
|
||||||
|
copy /b dist\win32\love.exe+cambridge.love dist\win32\cambridge.exe
|
||||||
|
|
||||||
|
copy libs\discord-rpc.dll dist\windows\libs
|
||||||
|
copy libs\discord-rpc.dll dist\win32\libs
|
||||||
|
|
||||||
|
copy SOURCES.md dist\windows
|
||||||
|
copy LICENSE.md dist\windows
|
||||||
|
copy SOURCES.md dist\win32
|
||||||
|
copy LICENSE.md dist\win32
|
||||||
|
|
||||||
|
cd dist\windows
|
||||||
|
tar -a -c -f ..\cambridge-windows.zip cambridge.exe *.dll libs *.md
|
||||||
|
cd ..\..
|
||||||
|
|
||||||
|
cd dist\win32
|
||||||
|
tar -a -c -f ..\cambridge-win32.zip cambridge.exe *.dll libs *.md
|
||||||
|
cd ..\..
|
||||||
BIN
res/backgrounds/options-gears.png
Normal file
BIN
res/backgrounds/options-gears.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 MiB |
BIN
res/backgrounds/options-pcb.png
Normal file
BIN
res/backgrounds/options-pcb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.3 MiB |
BIN
res/img/bonew.png
Normal file
BIN
res/img/bonew.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 B |
BIN
res/img/s8.png
Normal file
BIN
res/img/s8.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 233 B |
Binary file not shown.
BIN
res/se/cursor.wav
Normal file
BIN
res/se/cursor.wav
Normal file
Binary file not shown.
BIN
res/se/cursor_lr.wav
Normal file
BIN
res/se/cursor_lr.wav
Normal file
Binary file not shown.
BIN
res/se/erase.wav
Normal file
BIN
res/se/erase.wav
Normal file
Binary file not shown.
BIN
res/se/fall.wav
Normal file
BIN
res/se/fall.wav
Normal file
Binary file not shown.
BIN
res/se/go.wav
Normal file
BIN
res/se/go.wav
Normal file
Binary file not shown.
BIN
res/se/hold.wav
Normal file
BIN
res/se/hold.wav
Normal file
Binary file not shown.
BIN
res/se/lock.wav
Normal file
BIN
res/se/lock.wav
Normal file
Binary file not shown.
BIN
res/se/main_decide.wav
Normal file
BIN
res/se/main_decide.wav
Normal file
Binary file not shown.
BIN
res/se/mode_decide.wav
Normal file
BIN
res/se/mode_decide.wav
Normal file
Binary file not shown.
BIN
res/se/ready.wav
Normal file
BIN
res/se/ready.wav
Normal file
Binary file not shown.
@@ -5,10 +5,12 @@ Scene = Object:extend()
|
|||||||
function Scene:new() end
|
function Scene:new() end
|
||||||
function Scene:update() end
|
function Scene:update() end
|
||||||
function Scene:render() end
|
function Scene:render() end
|
||||||
function Scene:onKeyPress() end
|
function Scene:onInputPress() end
|
||||||
|
function Scene:onInputRelease() end
|
||||||
|
|
||||||
|
ExitScene = require "scene.exit"
|
||||||
GameScene = require "scene.game"
|
GameScene = require "scene.game"
|
||||||
ModeSelectScene = require "scene.mode_select"
|
ModeSelectScene = require "scene.mode_select"
|
||||||
InputConfigScene = require "scene.input_config"
|
InputConfigScene = require "scene.input_config"
|
||||||
ConfigScene = require "scene.config"
|
GameConfigScene = require "scene.game_config"
|
||||||
TitleScene = require "scene.title"
|
TitleScene = require "scene.title"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function ConfigScene:changeOption(rel)
|
|||||||
self.main_menu_state = (self.main_menu_state + len + rel - 1) % len + 1
|
self.main_menu_state = (self.main_menu_state + len + rel - 1) % len + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:onKeyPress(e)
|
function ConfigScene:onInputPress(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
return ConfigScene
|
return ConfigScene
|
||||||
|
|||||||
23
scene/exit.lua
Normal file
23
scene/exit.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
local ExitScene = Scene:extend()
|
||||||
|
require 'load.save'
|
||||||
|
|
||||||
|
ExitScene.title = "Exit Game"
|
||||||
|
|
||||||
|
function ExitScene:new()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExitScene:update()
|
||||||
|
love.event.quit()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExitScene:render()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExitScene:changeOption(rel)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExitScene:onInputPress(e)
|
||||||
|
end
|
||||||
|
|
||||||
|
return ExitScene
|
||||||
|
|
||||||
@@ -1,26 +1,40 @@
|
|||||||
local GameScene = Scene:extend()
|
local GameScene = Scene:extend()
|
||||||
|
|
||||||
|
GameScene.title = "Game"
|
||||||
|
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
function GameScene:new(game_mode, ruleset)
|
function GameScene:new(game_mode, ruleset)
|
||||||
|
self.retry_mode = game_mode
|
||||||
|
self.retry_ruleset = ruleset
|
||||||
self.game = game_mode()
|
self.game = game_mode()
|
||||||
self.ruleset = ruleset()
|
self.ruleset = ruleset()
|
||||||
self.game:initialize(self.ruleset)
|
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,
|
||||||
|
}
|
||||||
|
DiscordRPC:update({
|
||||||
|
details = self.game.rpc_details,
|
||||||
|
state = self.game.name,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:update()
|
function GameScene:update()
|
||||||
if love.window.hasFocus() then
|
if love.window.hasFocus() then
|
||||||
self.game:update({
|
local inputs = {}
|
||||||
left = love.keyboard.isScancodeDown(config.input.left),
|
for input, value in pairs(self.inputs) do
|
||||||
right = love.keyboard.isScancodeDown(config.input.right),
|
inputs[input] = value
|
||||||
up = love.keyboard.isScancodeDown(config.input.up),
|
end
|
||||||
down = love.keyboard.isScancodeDown(config.input.down),
|
self.game:update(inputs, self.ruleset)
|
||||||
rotate_left = love.keyboard.isScancodeDown(config.input.rotate_left),
|
|
||||||
rotate_left2 = love.keyboard.isScancodeDown(config.input.rotate_left2),
|
|
||||||
rotate_right = love.keyboard.isScancodeDown(config.input.rotate_right),
|
|
||||||
rotate_right2 = love.keyboard.isScancodeDown(config.input.rotate_right2),
|
|
||||||
rotate_180 = love.keyboard.isScancodeDown(config.input.rotate_180),
|
|
||||||
hold = love.keyboard.isScancodeDown(config.input.hold),
|
|
||||||
}, self.ruleset)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.game.grid:update()
|
self.game.grid:update()
|
||||||
@@ -45,6 +59,7 @@ function GameScene:render()
|
|||||||
self.game:drawScoringInfo()
|
self.game:drawScoringInfo()
|
||||||
|
|
||||||
-- ready/go graphics
|
-- ready/go graphics
|
||||||
|
|
||||||
if self.game.ready_frames <= 100 and self.game.ready_frames > 52 then
|
if self.game.ready_frames <= 100 and self.game.ready_frames > 52 then
|
||||||
love.graphics.draw(misc_graphics["ready"], 144 - 50, 240 - 14)
|
love.graphics.draw(misc_graphics["ready"], 144 - 50, 240 - 14)
|
||||||
elseif self.game.ready_frames <= 50 and self.game.ready_frames > 2 then
|
elseif self.game.ready_frames <= 50 and self.game.ready_frames > 2 then
|
||||||
@@ -55,13 +70,24 @@ function GameScene:render()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:onKeyPress(e)
|
function GameScene:onInputPress(e)
|
||||||
if (self.game.completed) and
|
if self.game.completed and (e.input == "menu_decide" or e.input == "menu_back" or e.input == "retry") then
|
||||||
e.scancode == "return" and e.isRepeat == false then
|
|
||||||
highscore_entry = self.game:getHighscoreData()
|
highscore_entry = self.game:getHighscoreData()
|
||||||
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
||||||
submitHighscore(highscore_hash, highscore_entry)
|
submitHighscore(highscore_hash, highscore_entry)
|
||||||
|
scene = e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset) or ModeSelectScene()
|
||||||
|
elseif e.input == "retry" then
|
||||||
|
scene = GameScene(self.retry_mode, self.retry_ruleset)
|
||||||
|
elseif e.input == "menu_back" then
|
||||||
scene = ModeSelectScene()
|
scene = ModeSelectScene()
|
||||||
|
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
|
||||||
|
self.inputs[e.input] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function GameScene:onInputRelease(e)
|
||||||
|
if e.input and string.sub(e.input, 1, 5) ~= "menu_" then
|
||||||
|
self.inputs[e.input] = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
79
scene/game_config.lua
Normal file
79
scene/game_config.lua
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
local ConfigScene = Scene:extend()
|
||||||
|
|
||||||
|
ConfigScene.title = "Game Settings"
|
||||||
|
|
||||||
|
require 'load.save'
|
||||||
|
|
||||||
|
ConfigScene.options = {
|
||||||
|
-- this serves as reference to what the options' values mean i guess?
|
||||||
|
{"manlock", "Manual locking",{"Per ruleset","Per gamemode","Harddrop", "Softdrop"}},
|
||||||
|
{"piece_colour", "Piece Colours", {"Per ruleset","Arika" ,"TTC"}},
|
||||||
|
{"world_reverse","A Button Rotation", {"Left" ,"Auto" ,"Right"}},
|
||||||
|
}
|
||||||
|
local optioncount = #ConfigScene.options
|
||||||
|
|
||||||
|
function ConfigScene:new()
|
||||||
|
-- load current config
|
||||||
|
self.config = config.input
|
||||||
|
self.highlight = 1
|
||||||
|
|
||||||
|
DiscordRPC:update({
|
||||||
|
details = "In menus",
|
||||||
|
state = "Changing game settings",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function ConfigScene:update()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ConfigScene:render()
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.draw(
|
||||||
|
backgrounds["game_config"],
|
||||||
|
0, 0, 0,
|
||||||
|
0.5, 0.5
|
||||||
|
)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_4)
|
||||||
|
love.graphics.print("GAME SETTINGS", 80, 40)
|
||||||
|
|
||||||
|
love.graphics.setColor(1, 1, 1, 0.5)
|
||||||
|
love.graphics.rectangle("fill", 20, 98 + self.highlight * 20, 170, 22)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_2)
|
||||||
|
for i, option in ipairs(ConfigScene.options) do
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.printf(option[2], 40, 100 + i * 20, 150, "left")
|
||||||
|
for j, setting in ipairs(option[3]) do
|
||||||
|
love.graphics.setColor(1, 1, 1, config.gamesettings[option[1]] == j and 1 or 0.5)
|
||||||
|
love.graphics.printf(setting, 100 + 110 * j, 100 + i * 20, 100, "center")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ConfigScene:onInputPress(e)
|
||||||
|
if e.input == "menu_decide" or e.scancode == "return" then
|
||||||
|
playSE("mode_decide")
|
||||||
|
saveConfig()
|
||||||
|
scene = TitleScene()
|
||||||
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
|
playSE("cursor")
|
||||||
|
self.highlight = Mod1(self.highlight-1, optioncount)
|
||||||
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
|
playSE("cursor")
|
||||||
|
self.highlight = Mod1(self.highlight+1, optioncount)
|
||||||
|
elseif e.input == "left" or e.scancode == "left" then
|
||||||
|
playSE("cursor_lr")
|
||||||
|
local option = ConfigScene.options[self.highlight]
|
||||||
|
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]-1, #option[3])
|
||||||
|
elseif e.input == "right" or e.scancode == "right" then
|
||||||
|
playSE("cursor_lr")
|
||||||
|
local option = ConfigScene.options[self.highlight]
|
||||||
|
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[3])
|
||||||
|
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
|
loadSave()
|
||||||
|
scene = TitleScene()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return ConfigScene
|
||||||
@@ -5,6 +5,8 @@ ConfigScene.title = "Input Config"
|
|||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
local configurable_inputs = {
|
local configurable_inputs = {
|
||||||
|
"menu_decide",
|
||||||
|
"menu_back",
|
||||||
"left",
|
"left",
|
||||||
"right",
|
"right",
|
||||||
"up",
|
"up",
|
||||||
@@ -15,47 +17,140 @@ local configurable_inputs = {
|
|||||||
"rotate_right2",
|
"rotate_right2",
|
||||||
"rotate_180",
|
"rotate_180",
|
||||||
"hold",
|
"hold",
|
||||||
|
"retry",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function newSetInputs()
|
||||||
|
local set_inputs = {}
|
||||||
|
for i, input in ipairs(configurable_inputs) do
|
||||||
|
set_inputs[input] = false
|
||||||
|
end
|
||||||
|
return set_inputs
|
||||||
|
end
|
||||||
|
|
||||||
function ConfigScene:new()
|
function ConfigScene:new()
|
||||||
-- load current config
|
|
||||||
self.config = config.input
|
|
||||||
self.input_state = 1
|
self.input_state = 1
|
||||||
|
self.set_inputs = newSetInputs()
|
||||||
|
self.new_input = {}
|
||||||
|
|
||||||
|
DiscordRPC:update({
|
||||||
|
details = "In menus",
|
||||||
|
state = "Changing input config",
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:update()
|
function ConfigScene:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:render()
|
function ConfigScene:render()
|
||||||
love.graphics.setFont(font_3x5_2)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
for i, input in pairs(configurable_inputs) do
|
love.graphics.draw(
|
||||||
if config.input[input] then
|
backgrounds["input_config"],
|
||||||
love.graphics.printf(input, 40, 50 + i * 20, 200, "left")
|
0, 0, 0,
|
||||||
love.graphics.printf(
|
0.5, 0.5
|
||||||
love.keyboard.getKeyFromScancode(config.input[input]) .. " (" .. config.input[input] .. ")",
|
|
||||||
240, 50 + i * 20, 200, "left"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_2)
|
||||||
|
for i, input in ipairs(configurable_inputs) do
|
||||||
|
love.graphics.printf(input, 40, 50 + i * 20, 200, "left")
|
||||||
|
if self.set_inputs[input] then
|
||||||
|
love.graphics.printf(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.input_state > table.getn(configurable_inputs) then
|
if self.input_state > table.getn(configurable_inputs) then
|
||||||
love.graphics.print("press enter to confirm, delete to retry")
|
love.graphics.print("press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""))
|
||||||
else
|
else
|
||||||
love.graphics.print("press key for " .. configurable_inputs[self.input_state])
|
love.graphics.print("press key or joystick input for " .. configurable_inputs[self.input_state] .. ", tab to skip" .. (config.input and ", escape to cancel" or ""), 0, 0)
|
||||||
|
love.graphics.print("function keys (F1, F2, etc.), escape, and tab can't be changed", 0, 20)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:onKeyPress(e)
|
local function addJoystick(input, name)
|
||||||
if self.input_state > table.getn(configurable_inputs) then
|
if not input.joysticks then
|
||||||
|
input.joysticks = {}
|
||||||
|
end
|
||||||
|
if not input.joysticks[name] then
|
||||||
|
input.joysticks[name] = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ConfigScene:onInputPress(e)
|
||||||
|
if e.type == "key" then
|
||||||
|
-- function keys, escape, and tab are reserved and can't be remapped
|
||||||
|
if e.scancode == "escape" and config.input then
|
||||||
|
-- cancel only if there was an input config already
|
||||||
|
scene = TitleScene()
|
||||||
|
elseif self.input_state > table.getn(configurable_inputs) then
|
||||||
if e.scancode == "return" then
|
if e.scancode == "return" then
|
||||||
-- save, then load next scene
|
-- save new input, then load next scene
|
||||||
|
config.input = self.new_input
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = TitleScene()
|
scene = TitleScene()
|
||||||
elseif e.scancode == "delete" or e.scancode == "backspace" then
|
elseif e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
|
-- retry
|
||||||
self.input_state = 1
|
self.input_state = 1
|
||||||
|
self.set_inputs = newSetInputs()
|
||||||
|
self.new_input = {}
|
||||||
end
|
end
|
||||||
else
|
elseif e.scancode == "tab" then
|
||||||
config.input[configurable_inputs[self.input_state]] = e.scancode
|
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
|
||||||
self.input_state = self.input_state + 1
|
self.input_state = self.input_state + 1
|
||||||
|
elseif e.scancode ~= "escape" then
|
||||||
|
-- all other keys can be configured
|
||||||
|
if not self.new_input.keys then
|
||||||
|
self.new_input.keys = {}
|
||||||
|
end
|
||||||
|
self.set_inputs[configurable_inputs[self.input_state]] = "key " .. love.keyboard.getKeyFromScancode(e.scancode) .. " (" .. e.scancode .. ")"
|
||||||
|
self.new_input.keys[e.scancode] = configurable_inputs[self.input_state]
|
||||||
|
self.input_state = self.input_state + 1
|
||||||
|
end
|
||||||
|
elseif string.sub(e.type, 1, 3) == "joy" then
|
||||||
|
if self.input_state <= table.getn(configurable_inputs) then
|
||||||
|
if e.type == "joybutton" then
|
||||||
|
addJoystick(self.new_input, e.name)
|
||||||
|
if not self.new_input.joysticks[e.name].buttons then
|
||||||
|
self.new_input.joysticks[e.name].buttons = {}
|
||||||
|
end
|
||||||
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
|
"jbtn " ..
|
||||||
|
e.button ..
|
||||||
|
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
||||||
|
self.new_input.joysticks[e.name].buttons[e.button] = configurable_inputs[self.input_state]
|
||||||
|
self.input_state = self.input_state + 1
|
||||||
|
elseif e.type == "joyaxis" then
|
||||||
|
if math.abs(e.value) >= 0.5 then
|
||||||
|
addJoystick(self.new_input, e.name)
|
||||||
|
if not self.new_input.joysticks[e.name].axes then
|
||||||
|
self.new_input.joysticks[e.name].axes = {}
|
||||||
|
end
|
||||||
|
if not self.new_input.joysticks[e.name].axes[e.axis] then
|
||||||
|
self.new_input.joysticks[e.name].axes[e.axis] = {}
|
||||||
|
end
|
||||||
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
|
"jaxis " ..
|
||||||
|
(e.value >= 0.5 and "+" or "-") .. e.axis ..
|
||||||
|
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
||||||
|
self.new_input.joysticks[e.name].axes[e.axis][e.value >= 0.5 and "positive" or "negative"] = configurable_inputs[self.input_state]
|
||||||
|
self.input_state = self.input_state + 1
|
||||||
|
end
|
||||||
|
elseif e.type == "joyhat" then
|
||||||
|
if e.direction ~= "c" then
|
||||||
|
addJoystick(self.new_input, e.name)
|
||||||
|
if not self.new_input.joysticks[e.name].hats then
|
||||||
|
self.new_input.joysticks[e.name].hats = {}
|
||||||
|
end
|
||||||
|
if not self.new_input.joysticks[e.name].hats[e.hat] then
|
||||||
|
self.new_input.joysticks[e.name].hats[e.hat] = {}
|
||||||
|
end
|
||||||
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
|
"jhat " ..
|
||||||
|
e.hat .. " " .. e.direction ..
|
||||||
|
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
||||||
|
self.new_input.joysticks[e.name].hats[e.hat][e.direction] = configurable_inputs[self.input_state]
|
||||||
|
self.input_state = self.input_state + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,47 +5,16 @@ ModeSelectScene.title = "Game Start"
|
|||||||
current_mode = 1
|
current_mode = 1
|
||||||
current_ruleset = 1
|
current_ruleset = 1
|
||||||
|
|
||||||
game_modes = {
|
|
||||||
require 'tetris.modes.marathon_2020',
|
|
||||||
require 'tetris.modes.survival_2020',
|
|
||||||
--require 'tetris.modes.strategy',
|
|
||||||
--require 'tetris.modes.interval_training',
|
|
||||||
--require 'tetris.modes.pacer_test',
|
|
||||||
--require 'tetris.modes.demon_mode',
|
|
||||||
require 'tetris.modes.phantom_mania',
|
|
||||||
require 'tetris.modes.phantom_mania2',
|
|
||||||
require 'tetris.modes.phantom_mania_n',
|
|
||||||
require 'tetris.modes.race_40',
|
|
||||||
require 'tetris.modes.marathon_a1',
|
|
||||||
require 'tetris.modes.marathon_a2',
|
|
||||||
require 'tetris.modes.marathon_a3',
|
|
||||||
require 'tetris.modes.marathon_ax4',
|
|
||||||
require 'tetris.modes.marathon_c89',
|
|
||||||
require 'tetris.modes.survival_a1',
|
|
||||||
require 'tetris.modes.survival_a2',
|
|
||||||
require 'tetris.modes.survival_a3',
|
|
||||||
require 'tetris.modes.big_a2',
|
|
||||||
require 'tetris.modes.konoha',
|
|
||||||
}
|
|
||||||
|
|
||||||
rulesets = {
|
|
||||||
require 'tetris.rulesets.cambridge',
|
|
||||||
require 'tetris.rulesets.arika',
|
|
||||||
require 'tetris.rulesets.arika_ti',
|
|
||||||
require 'tetris.rulesets.arika_ace',
|
|
||||||
require 'tetris.rulesets.arika_srs',
|
|
||||||
require 'tetris.rulesets.standard_exp',
|
|
||||||
--require 'tetris.rulesets.bonkers',
|
|
||||||
--require 'tetris.rulesets.shirase',
|
|
||||||
--require 'tetris.rulesets.super302',
|
|
||||||
}
|
|
||||||
|
|
||||||
function ModeSelectScene:new()
|
function ModeSelectScene:new()
|
||||||
self.menu_state = {
|
self.menu_state = {
|
||||||
mode = current_mode,
|
mode = current_mode,
|
||||||
ruleset = current_ruleset,
|
ruleset = current_ruleset,
|
||||||
select = "mode",
|
select = "mode",
|
||||||
}
|
}
|
||||||
|
DiscordRPC:update({
|
||||||
|
details = "In menus",
|
||||||
|
state = "Choosing a mode",
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ModeSelectScene:update()
|
function ModeSelectScene:update()
|
||||||
@@ -63,14 +32,14 @@ function ModeSelectScene:render()
|
|||||||
elseif self.menu_state.select == "ruleset" then
|
elseif self.menu_state.select == "ruleset" then
|
||||||
love.graphics.setColor(1, 1, 1, 0.25)
|
love.graphics.setColor(1, 1, 1, 0.25)
|
||||||
end
|
end
|
||||||
love.graphics.rectangle("fill", 20, 78 + 20 * self.menu_state.mode, 240, 22)
|
love.graphics.rectangle("fill", 20, 258, 240, 22)
|
||||||
|
|
||||||
if self.menu_state.select == "mode" then
|
if self.menu_state.select == "mode" then
|
||||||
love.graphics.setColor(1, 1, 1, 0.25)
|
love.graphics.setColor(1, 1, 1, 0.25)
|
||||||
elseif self.menu_state.select == "ruleset" then
|
elseif self.menu_state.select == "ruleset" then
|
||||||
love.graphics.setColor(1, 1, 1, 0.5)
|
love.graphics.setColor(1, 1, 1, 0.5)
|
||||||
end
|
end
|
||||||
love.graphics.rectangle("fill", 340, 78 + 20 * self.menu_state.ruleset, 200, 22)
|
love.graphics.rectangle("fill", 340, 258, 200, 22)
|
||||||
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
|
||||||
@@ -78,28 +47,37 @@ function ModeSelectScene:render()
|
|||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
love.graphics.setFont(font_3x5_2)
|
||||||
for idx, mode in pairs(game_modes) do
|
for idx, mode in pairs(game_modes) do
|
||||||
love.graphics.printf(mode.name, 40, 80 + 20 * idx, 200, "left")
|
if(idx >= self.menu_state.mode-9 and idx <= self.menu_state.mode+9) then
|
||||||
|
love.graphics.printf(mode.name, 40, (260 - 20*(self.menu_state.mode)) + 20 * idx, 200, "left")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
for idx, ruleset in pairs(rulesets) do
|
for idx, ruleset in pairs(rulesets) do
|
||||||
love.graphics.printf(ruleset.name, 360, 80 + 20 * idx, 160, "left")
|
if(idx >= self.menu_state.ruleset-9 and idx <= self.menu_state.ruleset+9) then
|
||||||
|
love.graphics.printf(ruleset.name, 360, (260 - 20*(self.menu_state.ruleset)) + 20 * idx, 160, "left")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ModeSelectScene:onKeyPress(e)
|
function ModeSelectScene:onInputPress(e)
|
||||||
if e.scancode == "return" and e.isRepeat == false then
|
if e.input == "menu_decide" or e.scancode == "return" then
|
||||||
current_mode = self.menu_state.mode
|
current_mode = self.menu_state.mode
|
||||||
current_ruleset = self.menu_state.ruleset
|
current_ruleset = self.menu_state.ruleset
|
||||||
config.current_mode = current_mode
|
config.current_mode = current_mode
|
||||||
config.current_ruleset = current_ruleset
|
config.current_ruleset = current_ruleset
|
||||||
|
playSE("mode_decide")
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = GameScene(game_modes[self.menu_state.mode], rulesets[self.menu_state.ruleset])
|
scene = GameScene(game_modes[self.menu_state.mode], rulesets[self.menu_state.ruleset])
|
||||||
elseif (e.scancode == config.input["up"] or e.scancode == "up") and e.isRepeat == false then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
self:changeOption(-1)
|
self:changeOption(-1)
|
||||||
elseif (e.scancode == config.input["down"] or e.scancode == "down") and e.isRepeat == false then
|
playSE("cursor")
|
||||||
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
self:changeOption(1)
|
self:changeOption(1)
|
||||||
elseif (e.scancode == config.input["left"] or e.scancode == "left") or
|
playSE("cursor")
|
||||||
(e.scancode == config.input["right"] or e.scancode == "right") then
|
elseif e.input == "left" or e.input == "right" or e.scancode == "left" or e.scancode == "right" then
|
||||||
self:switchSelect()
|
self:switchSelect()
|
||||||
|
playSE("cursor_lr")
|
||||||
|
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
|
scene = TitleScene()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,31 @@ local TitleScene = Scene:extend()
|
|||||||
local main_menu_screens = {
|
local main_menu_screens = {
|
||||||
ModeSelectScene,
|
ModeSelectScene,
|
||||||
InputConfigScene,
|
InputConfigScene,
|
||||||
|
GameConfigScene,
|
||||||
|
ExitScene,
|
||||||
|
}
|
||||||
|
|
||||||
|
local mainmenuidle = {
|
||||||
|
"Idle",
|
||||||
|
"On title screen",
|
||||||
|
"On main menu screen",
|
||||||
|
"Twiddling their thumbs",
|
||||||
|
"Admiring the main menu's BG",
|
||||||
|
"Waiting for spring to come",
|
||||||
|
"Actually not playing",
|
||||||
|
"Contemplating collecting stars",
|
||||||
|
"Preparing to put the block!!",
|
||||||
|
"Having a nap",
|
||||||
|
"In menus",
|
||||||
|
"Bottom text",
|
||||||
}
|
}
|
||||||
|
|
||||||
function TitleScene:new()
|
function TitleScene:new()
|
||||||
self.main_menu_state = 1
|
self.main_menu_state = 1
|
||||||
|
DiscordRPC:update({
|
||||||
|
details = "In menus",
|
||||||
|
state = mainmenuidle[math.random(#mainmenuidle)],
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function TitleScene:update()
|
function TitleScene:update()
|
||||||
@@ -36,13 +57,18 @@ function TitleScene:changeOption(rel)
|
|||||||
self.main_menu_state = (self.main_menu_state + len + rel - 1) % len + 1
|
self.main_menu_state = (self.main_menu_state + len + rel - 1) % len + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function TitleScene:onKeyPress(e)
|
function TitleScene:onInputPress(e)
|
||||||
if e.scancode == "return" and e.isRepeat == false then
|
if e.input == "menu_decide" or e.scancode == "return" then
|
||||||
|
playSE("main_decide")
|
||||||
scene = main_menu_screens[self.main_menu_state]()
|
scene = main_menu_screens[self.main_menu_state]()
|
||||||
elseif (e.scancode == config.input["up"] or e.scancode == "up") and e.isRepeat == false then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
self:changeOption(-1)
|
self:changeOption(-1)
|
||||||
elseif (e.scancode == config.input["down"] or e.scancode == "down") and e.isRepeat == false then
|
playSE("cursor")
|
||||||
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
self:changeOption(1)
|
self:changeOption(1)
|
||||||
|
playSE("cursor")
|
||||||
|
elseif e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete" then
|
||||||
|
love.event.quit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local Grid = Object:extend()
|
|||||||
|
|
||||||
local empty = { skin = "", colour = "" }
|
local empty = { skin = "", colour = "" }
|
||||||
local oob = { skin = "", colour = "" }
|
local oob = { skin = "", colour = "" }
|
||||||
|
local block = { skin = "2tie", colour = "A" }
|
||||||
|
|
||||||
function Grid:new()
|
function Grid:new()
|
||||||
self.grid = {}
|
self.grid = {}
|
||||||
@@ -141,14 +142,49 @@ function Grid:copyBottomRow()
|
|||||||
self.grid[24] = {empty, empty, empty, empty, empty, empty, empty, empty, empty, empty}
|
self.grid[24] = {empty, empty, empty, empty, empty, empty, empty, empty, empty, empty}
|
||||||
self.grid_age[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
self.grid_age[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
for col = 1, 10 do
|
for col = 1, 10 do
|
||||||
self.grid[24][col] = (self.grid[23][col] == empty) and empty or {
|
self.grid[24][col] = (self.grid[23][col] == empty) and empty or block
|
||||||
skin = self.grid[23][col].skin,
|
|
||||||
colour = "G"
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Grid:garbageRise(row_vals)
|
||||||
|
for row = 1, 23 do
|
||||||
|
self.grid[row] = self.grid[row+1]
|
||||||
|
self.grid_age[row] = self.grid_age[row+1]
|
||||||
|
end
|
||||||
|
self.grid[24] = {empty, empty, empty, empty, empty, empty, empty, empty, empty, empty}
|
||||||
|
self.grid_age[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
|
for col = 1, 10 do
|
||||||
|
self.grid[24][col] = (row_vals[col] == "e") and empty or block
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Grid:applyFourWide()
|
||||||
|
for row = 1, 24 do
|
||||||
|
local x = self.grid[row]
|
||||||
|
x[1] = x[1]~=block and block or x[1]
|
||||||
|
x[2] = x[2]~=block and block or x[2]
|
||||||
|
x[3] = x[3]~=block and block or x[3]
|
||||||
|
x[8] = x[8]~=block and block or x[8]
|
||||||
|
x[9] = x[9]~=block and block or x[9]
|
||||||
|
x[10] = x[10]~=block and block or x[10]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Grid:applyCeiling(lines)
|
||||||
|
for row = 1, lines do
|
||||||
|
for col = 1, 9 do
|
||||||
|
self.grid[row][col] = block
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Grid:clearSpecificRow(row)
|
||||||
|
for col = 1, 10 do
|
||||||
|
self.grid[row][col] = empty
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Grid:applyPiece(piece)
|
function Grid:applyPiece(piece)
|
||||||
if piece.big then
|
if piece.big then
|
||||||
self:applyBigPiece(piece)
|
self:applyBigPiece(piece)
|
||||||
@@ -161,7 +197,7 @@ function Grid:applyPiece(piece)
|
|||||||
if y + 1 > 0 then
|
if y + 1 > 0 then
|
||||||
self.grid[y+1][x+1] = {
|
self.grid[y+1][x+1] = {
|
||||||
skin = piece.skin,
|
skin = piece.skin,
|
||||||
colour = piece.shape
|
colour = piece.colour
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -177,7 +213,7 @@ function Grid:applyBigPiece(piece)
|
|||||||
if y*2+a > 0 then
|
if y*2+a > 0 then
|
||||||
self.grid[y*2+a][x*2+b] = {
|
self.grid[y*2+a][x*2+b] = {
|
||||||
skin = piece.skin,
|
skin = piece.skin,
|
||||||
colour = piece.shape
|
colour = piece.colour
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -185,6 +221,49 @@ function Grid:applyBigPiece(piece)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Grid:checkForBravo(cleared_row_count)
|
||||||
|
for i = 0, 23 - cleared_row_count do
|
||||||
|
for j = 0, 9 do
|
||||||
|
if self:isOccupied(j, i) then return false end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function Grid:checkSecretGrade()
|
||||||
|
local sgrade = 0
|
||||||
|
for i=23,5,-1 do
|
||||||
|
local validLine = true
|
||||||
|
local emptyCell = 0
|
||||||
|
if i > 13 then
|
||||||
|
emptyCell = 23-i
|
||||||
|
end
|
||||||
|
if i <= 13 then
|
||||||
|
emptyCell = i-5
|
||||||
|
end
|
||||||
|
for j=0,9 do
|
||||||
|
if (not self:isOccupied(j,i) and j ~= emptyCell) or (j == emptyCell and self:isOccupied(j,i)) then
|
||||||
|
validLine = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not self:isOccupied(emptyCell,i-1) then
|
||||||
|
validLine = false
|
||||||
|
end
|
||||||
|
if(validLine) then
|
||||||
|
sgrade = sgrade + 1
|
||||||
|
else
|
||||||
|
return sgrade
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
if(sgrade == 0) then return ""
|
||||||
|
elseif(sgrade < 10) then return 10-sgrade
|
||||||
|
elseif(sgrade < 19) then return "S"..(sgrade-9) end
|
||||||
|
return "GM"
|
||||||
|
--]]
|
||||||
|
return sgrade
|
||||||
|
end
|
||||||
|
|
||||||
function Grid:update()
|
function Grid:update()
|
||||||
for y = 1, 24 do
|
for y = 1, 24 do
|
||||||
for x = 1, 10 do
|
for x = 1, 10 do
|
||||||
@@ -196,14 +275,18 @@ function Grid:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Grid:draw()
|
function Grid:draw()
|
||||||
for y = 1, 24 do
|
for y = 5, 24 do
|
||||||
for x = 1, 10 do
|
for x = 1, 10 do
|
||||||
if self.grid[y][x] ~= empty then
|
if self.grid[y][x] ~= empty then
|
||||||
if self.grid_age[y][x] < 1 then
|
if self.grid_age[y][x] < 2 then
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.draw(blocks[self.grid[y][x].skin]["F"], 48+x*16, y*16)
|
love.graphics.draw(blocks[self.grid[y][x].skin]["F"], 48+x*16, y*16)
|
||||||
|
else
|
||||||
|
if self.grid[y][x].skin == "bone" then
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
else
|
else
|
||||||
love.graphics.setColor(0.5, 0.5, 0.5, 1)
|
love.graphics.setColor(0.5, 0.5, 0.5, 1)
|
||||||
|
end
|
||||||
love.graphics.draw(blocks[self.grid[y][x].skin][self.grid[y][x].colour], 48+x*16, y*16)
|
love.graphics.draw(blocks[self.grid[y][x].skin][self.grid[y][x].colour], 48+x*16, y*16)
|
||||||
end
|
end
|
||||||
if self.grid[y][x].skin ~= "bone" then
|
if self.grid[y][x].skin ~= "bone" then
|
||||||
@@ -228,12 +311,12 @@ function Grid:draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Grid:drawInvisible(opacity_function, garbage_opacity_function)
|
function Grid:drawInvisible(opacity_function, garbage_opacity_function)
|
||||||
for y = 1, 24 do
|
for y = 5, 24 do
|
||||||
for x = 1, 10 do
|
for x = 1, 10 do
|
||||||
if self.grid[y][x] ~= empty then
|
if self.grid[y][x] ~= empty then
|
||||||
if self.grid[y][x].colour == "X" then
|
if self.grid[y][x].colour == "X" then
|
||||||
opacity = 1
|
opacity = 1
|
||||||
elseif garbage_opacity_function and self.grid[y][x].colour == "G" then
|
elseif garbage_opacity_function and self.grid[y][x].colour == "A" then
|
||||||
opacity = garbage_opacity_function(self.grid_age[y][x])
|
opacity = garbage_opacity_function(self.grid_age[y][x])
|
||||||
else
|
else
|
||||||
opacity = opacity_function(self.grid_age[y][x])
|
opacity = opacity_function(self.grid_age[y][x])
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ local Object = require 'libs.classic'
|
|||||||
|
|
||||||
local Piece = Object:extend()
|
local Piece = Object:extend()
|
||||||
|
|
||||||
function Piece:new(shape, rotation, position, block_offsets, gravity, lock_delay, skin, big)
|
function Piece:new(shape, rotation, position, block_offsets, gravity, lock_delay, skin, colour, big)
|
||||||
self.shape = shape
|
self.shape = shape
|
||||||
self.rotation = rotation
|
self.rotation = rotation
|
||||||
self.position = position
|
self.position = position
|
||||||
@@ -10,6 +10,7 @@ function Piece:new(shape, rotation, position, block_offsets, gravity, lock_delay
|
|||||||
self.gravity = gravity
|
self.gravity = gravity
|
||||||
self.lock_delay = lock_delay
|
self.lock_delay = lock_delay
|
||||||
self.skin = skin
|
self.skin = skin
|
||||||
|
self.colour = colour
|
||||||
self.ghost = false
|
self.ghost = false
|
||||||
self.locked = false
|
self.locked = false
|
||||||
self.big = big
|
self.big = big
|
||||||
@@ -21,7 +22,7 @@ function Piece:withOffset(offset)
|
|||||||
return Piece(
|
return Piece(
|
||||||
self.shape, self.rotation,
|
self.shape, self.rotation,
|
||||||
{x = self.position.x + offset.x, y = self.position.y + offset.y},
|
{x = self.position.x + offset.x, y = self.position.y + offset.y},
|
||||||
self.block_offsets, self.gravity, self.lock_delay, self.skin, self.big
|
self.block_offsets, self.gravity, self.lock_delay, self.skin, self.colour, self.big
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ function Piece:withRelativeRotation(rot)
|
|||||||
while new_rot >= 4 do new_rot = new_rot - 4 end
|
while new_rot >= 4 do new_rot = new_rot - 4 end
|
||||||
return Piece(
|
return Piece(
|
||||||
self.shape, new_rot, self.position,
|
self.shape, new_rot, self.position,
|
||||||
self.block_offsets, self.gravity, self.lock_delay, self.skin, self.big
|
self.block_offsets, self.gravity, self.lock_delay, self.skin, self.colour, self.big
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ end
|
|||||||
|
|
||||||
function Piece:dropToBottom(grid)
|
function Piece:dropToBottom(grid)
|
||||||
local piece_y = self.position.y
|
local piece_y = self.position.y
|
||||||
self:dropSquares(24, grid)
|
self:dropSquares(math.huge, grid)
|
||||||
self.gravity = 0
|
self.gravity = 0
|
||||||
if self.position.y > piece_y then
|
if self.position.y > piece_y then
|
||||||
-- if it got dropped any, also reset lock delay
|
-- if it got dropped any, also reset lock delay
|
||||||
@@ -148,13 +149,13 @@ function Piece:draw(opacity, brightness, grid, partial_das)
|
|||||||
local y = self.position.y + offset.y
|
local y = self.position.y + offset.y
|
||||||
if self.big then
|
if self.big then
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
blocks[self.skin][self.shape],
|
blocks[self.skin][self.colour],
|
||||||
64+x*32+partial_das*2, 16+y*32+gravity_offset*2,
|
64+x*32+partial_das*2, 16+y*32+gravity_offset*2,
|
||||||
0, 2, 2
|
0, 2, 2
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
blocks[self.skin][self.shape],
|
blocks[self.skin][self.colour],
|
||||||
64+x*16+partial_das, 16+y*16+gravity_offset
|
64+x*16+partial_das, 16+y*16+gravity_offset
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,21 +15,19 @@ MarathonA2Game.tagline = "The points don't matter! Can you reach the invisible r
|
|||||||
|
|
||||||
|
|
||||||
function MarathonA2Game:new()
|
function MarathonA2Game:new()
|
||||||
MarathonA2Game.super:new()
|
self.super:new()
|
||||||
self.big_mode = true
|
self.big_mode = true
|
||||||
self.roll_frames = 0
|
self.roll_frames = 0
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
self.randomizer = History6RollsRandomizer()
|
|
||||||
self.grade = 0
|
self.grade = 0
|
||||||
self.grade_points = 0
|
self.grade_points = 0
|
||||||
self.grade_point_decay_counter = 0
|
self.grade_point_decay_counter = 0
|
||||||
self.section_start_time = 0
|
|
||||||
self.section_times = { [0] = 0 }
|
|
||||||
self.section_tetrises = { [0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
|
||||||
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = History6RollsRandomizer()
|
||||||
|
|
||||||
self.lock_drop = false
|
self.lock_drop = false
|
||||||
|
self.lock_hard_drop = false
|
||||||
self.enable_hold = false
|
self.enable_hold = false
|
||||||
self.next_queue_length = 1
|
self.next_queue_length = 1
|
||||||
end
|
end
|
||||||
@@ -103,11 +101,9 @@ end
|
|||||||
function MarathonA2Game:advanceOneFrame()
|
function MarathonA2Game:advanceOneFrame()
|
||||||
if self.clear then
|
if self.clear then
|
||||||
self.roll_frames = self.roll_frames + 1
|
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 > 3694 then
|
||||||
self.completed = true
|
self.completed = true
|
||||||
if self.grade == 32 then
|
|
||||||
self.grade = 33
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif self.ready_frames == 0 then
|
elseif self.ready_frames == 0 then
|
||||||
self.frames = self.frames + 1
|
self.frames = self.frames + 1
|
||||||
@@ -123,42 +119,31 @@ end
|
|||||||
|
|
||||||
function MarathonA2Game:onLineClear(cleared_row_count)
|
function MarathonA2Game:onLineClear(cleared_row_count)
|
||||||
cleared_row_count = cleared_row_count / 2
|
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)
|
self.level = math.min(self.level + cleared_row_count, 999)
|
||||||
if self.level == 999 and not self.clear then
|
if self.level == 999 and not self.clear then
|
||||||
self.clear = true
|
self.clear = true
|
||||||
if self:qualifiesForMRoll() then
|
|
||||||
self.grade = 32
|
|
||||||
end
|
|
||||||
self.grid:clear()
|
self.grid:clear()
|
||||||
self.roll_frames = -150
|
self.roll_frames = -150
|
||||||
end
|
end
|
||||||
|
self.lock_drop = self.level >= 900
|
||||||
|
self.lock_hard_drop = self.level >= 900
|
||||||
end
|
end
|
||||||
|
|
||||||
function MarathonA2Game:updateScore(level, drop_bonus, cleared_lines)
|
function MarathonA2Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
cleared_lines = cleared_lines / 2
|
cleared_lines = cleared_lines / 2
|
||||||
self:updateGrade(cleared_lines)
|
self:updateGrade(cleared_lines)
|
||||||
|
if self.grid:checkForBravo(cleared_lines) then self.bravo = 4 else self.bravo = 1 end
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
cleared_lines * self.combo * self.bravo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
end
|
self.drop_bonus = 0
|
||||||
|
|
||||||
function MarathonA2Game:updateSectionTimes(old_level, new_level)
|
|
||||||
if self.clear then return end
|
|
||||||
if math.floor(old_level / 100) < math.floor(new_level / 100) or
|
|
||||||
new_level >= 999 then
|
|
||||||
-- record new section
|
|
||||||
section_time = self.frames - self.section_start_time
|
|
||||||
self.section_times[math.floor(old_level / 100)] = section_time
|
|
||||||
self.section_start_time = self.frames
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -223,7 +208,7 @@ local grade_conversion = {
|
|||||||
1, 2, 3, 4, 5, 5, 6, 6, 7, 7,
|
1, 2, 3, 4, 5, 5, 6, 6, 7, 7,
|
||||||
7, 8, 8, 8, 9, 9, 9, 10, 11, 12,
|
7, 8, 8, 8, 9, 9, 9, 10, 11, 12,
|
||||||
12, 12, 13, 13, 14, 14, 15, 15, 16, 16,
|
12, 12, 13, 13, 14, 14, 15, 15, 16, 16,
|
||||||
17, 18, 19
|
17
|
||||||
}
|
}
|
||||||
|
|
||||||
function MarathonA2Game:updateGrade(cleared_lines)
|
function MarathonA2Game:updateGrade(cleared_lines)
|
||||||
@@ -248,49 +233,12 @@ function MarathonA2Game:updateGrade(cleared_lines)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tetris_requirements = { [0] = 2, 2, 2, 2, 2, 1, 1, 1, 1, 1 }
|
|
||||||
|
|
||||||
function MarathonA2Game:qualifiesForMRoll()
|
|
||||||
if not self.clear then return false end
|
|
||||||
-- tetris requirements
|
|
||||||
for section = 0, 9 do
|
|
||||||
if self.section_tetrises[section] < tetris_requirements[section] then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- section time requirements
|
|
||||||
local section_average = 0
|
|
||||||
for section = 0, 4 do
|
|
||||||
section_average = section_average + self.section_times[section]
|
|
||||||
if self.section_times[section] > frameTime(1,05) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- section time average requirements
|
|
||||||
if self.section_times[5] > section_average / 5 then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
for section = 6, 9 do
|
|
||||||
if self.section_times[section] > self.section_times[section - 1] + 120 then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if self.grade < 17 or self.frames > frameTime(8,45) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonA2Game:getLetterGrade()
|
function MarathonA2Game:getLetterGrade()
|
||||||
local grade = grade_conversion[self.grade]
|
local grade = grade_conversion[self.grade]
|
||||||
if grade < 9 then
|
if grade < 9 then
|
||||||
return tostring(9 - grade)
|
return tostring(9 - grade)
|
||||||
elseif grade < 18 then
|
elseif grade < 18 then
|
||||||
return "S" .. tostring(grade - 8)
|
return "S" .. tostring(grade - 8)
|
||||||
elseif grade == 18 then
|
|
||||||
return "M"
|
|
||||||
else
|
|
||||||
return "GM"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -300,18 +248,9 @@ MarathonA2Game.rollOpacityFunction = function(age)
|
|||||||
else return 1 - (age - 240) / 60 end
|
else return 1 - (age - 240) / 60 end
|
||||||
end
|
end
|
||||||
|
|
||||||
MarathonA2Game.mRollOpacityFunction = function(age)
|
|
||||||
if age > 4 then return 0
|
|
||||||
else return 1 - age / 4 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonA2Game:drawGrid(ruleset)
|
function MarathonA2Game:drawGrid(ruleset)
|
||||||
if self.clear and not (self.completed or self.game_over) then
|
if self.clear and not (self.completed or self.game_over) then
|
||||||
if self:qualifiesForMRoll() then
|
|
||||||
self.grid:drawInvisible(self.mRollOpacityFunction)
|
|
||||||
else
|
|
||||||
self.grid:drawInvisible(self.rollOpacityFunction)
|
self.grid:drawInvisible(self.rollOpacityFunction)
|
||||||
end
|
|
||||||
else
|
else
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
if self.piece ~= nil and self.level < 100 then
|
if self.piece ~= nil and self.level < 100 then
|
||||||
@@ -335,7 +274,10 @@ function MarathonA2Game:drawScoringInfo()
|
|||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
|
if self.roll_frames > 3694 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||||
|
elseif self.clear then love.graphics.setColor(0, 1, 0, 1) end
|
||||||
love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left")
|
love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left")
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.printf(self.score, 240, 220, 90, "left")
|
love.graphics.printf(self.score, 240, 220, 90, "left")
|
||||||
love.graphics.printf(self.level, 240, 340, 40, "right")
|
love.graphics.printf(self.level, 240, 340, 40, "right")
|
||||||
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
||||||
|
|||||||
@@ -1,258 +0,0 @@
|
|||||||
require 'funcs'
|
|
||||||
|
|
||||||
local GameMode = require 'tetris.modes.gamemode'
|
|
||||||
local Piece = require 'tetris.components.piece'
|
|
||||||
|
|
||||||
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls'
|
|
||||||
|
|
||||||
local DemonModeGame = GameMode:extend()
|
|
||||||
|
|
||||||
DemonModeGame.name = "Demon Mode"
|
|
||||||
DemonModeGame.hash = "DemonMode"
|
|
||||||
DemonModeGame.tagline = "Can you handle the ludicrous speed past level 20?"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function DemonModeGame:new()
|
|
||||||
DemonModeGame.super:new()
|
|
||||||
self.roll_frames = 0
|
|
||||||
self.combo = 1
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
|
||||||
|
|
||||||
self.grade = 0
|
|
||||||
self.section_start_time = 0
|
|
||||||
self.section_times = { [0] = 0 }
|
|
||||||
self.section_tetris_count = 0
|
|
||||||
self.section_tries = 0
|
|
||||||
|
|
||||||
self.enable_hold = true
|
|
||||||
self.lock_drop = true
|
|
||||||
self.next_queue_length = 3
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getARE()
|
|
||||||
if self.level < 500 then return 30
|
|
||||||
elseif self.level < 600 then return 25
|
|
||||||
elseif self.level < 700 then return 15
|
|
||||||
elseif self.level < 800 then return 14
|
|
||||||
elseif self.level < 900 then return 12
|
|
||||||
elseif self.level < 1000 then return 11
|
|
||||||
elseif self.level < 1100 then return 10
|
|
||||||
elseif self.level < 1300 then return 8
|
|
||||||
elseif self.level < 1400 then return 6
|
|
||||||
elseif self.level < 1700 then return 4
|
|
||||||
elseif self.level < 1800 then return 3
|
|
||||||
elseif self.level < 1900 then return 2
|
|
||||||
elseif self.level < 2000 then return 1
|
|
||||||
else return 0 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getLineARE()
|
|
||||||
return self:getARE()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getDasLimit()
|
|
||||||
if self.level < 500 then return 15
|
|
||||||
elseif self.level < 1000 then return 10
|
|
||||||
elseif self.level < 1500 then return 5
|
|
||||||
elseif self.level < 1700 then return 4
|
|
||||||
elseif self.level < 1900 then return 3
|
|
||||||
elseif self.level < 2000 then return 2
|
|
||||||
else return 1 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getLineClearDelay()
|
|
||||||
if self.level < 600 then return 15
|
|
||||||
elseif self.level < 800 then return 10
|
|
||||||
elseif self.level < 1000 then return 8
|
|
||||||
elseif self.level < 1500 then return 5
|
|
||||||
elseif self.level < 1700 then return 3
|
|
||||||
elseif self.level < 1900 then return 2
|
|
||||||
elseif self.level < 2000 then return 1
|
|
||||||
else return 0 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getLockDelay()
|
|
||||||
if self.level < 100 then return 30
|
|
||||||
elseif self.level < 200 then return 25
|
|
||||||
elseif self.level < 300 then return 22
|
|
||||||
elseif self.level < 400 then return 20
|
|
||||||
elseif self.level < 1000 then return 15
|
|
||||||
elseif self.level < 1200 then return 10
|
|
||||||
elseif self.level < 1400 then return 9
|
|
||||||
elseif self.level < 1500 then return 8
|
|
||||||
elseif self.level < 1600 then return 7
|
|
||||||
elseif self.level < 1700 then return 6
|
|
||||||
elseif self.level < 1800 then return 5
|
|
||||||
elseif self.level < 1900 then return 4
|
|
||||||
elseif self.level < 2000 then return 3
|
|
||||||
else return 2 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getGravity()
|
|
||||||
return 20
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getSectionForLevel(level)
|
|
||||||
return math.floor(level / 100) + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local cleared_row_levels = {1, 3, 6, 10}
|
|
||||||
|
|
||||||
function DemonModeGame:advanceOneFrame()
|
|
||||||
if self.clear then
|
|
||||||
self.roll_frames = self.roll_frames + 1
|
|
||||||
if self.roll_frames < 0 then
|
|
||||||
return false
|
|
||||||
elseif self.roll_frames >= 1337 then
|
|
||||||
self.completed = true
|
|
||||||
end
|
|
||||||
elseif self.ready_frames == 0 then
|
|
||||||
self.frames = self.frames + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:onPieceEnter()
|
|
||||||
if (self.level % 100 ~= 99) and self.frames ~= 0 then
|
|
||||||
self.level = self.level + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:onLineClear(cleared_row_count)
|
|
||||||
if cleared_row_count == 4 then
|
|
||||||
self.section_tetris_count = self.section_tetris_count + 1
|
|
||||||
end
|
|
||||||
local advanced_levels = cleared_row_levels[cleared_row_count]
|
|
||||||
if not self.clear then
|
|
||||||
self:updateSectionTimes(self.level, self.level + advanced_levels)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:updateSectionTimes(old_level, new_level)
|
|
||||||
local section = math.floor(old_level / 100) + 1
|
|
||||||
if math.floor(old_level / 100) < math.floor(new_level / 100) then
|
|
||||||
-- If at least one Tetris in this section hasn't been made,
|
|
||||||
-- deny section passage.
|
|
||||||
if old_level > 500 then
|
|
||||||
if self.section_tetris_count == 0 then
|
|
||||||
self.level = 100 * math.floor(old_level / 100)
|
|
||||||
self.section_tries = self.section_tries + 1
|
|
||||||
else
|
|
||||||
self.level = math.min(new_level, 2500)
|
|
||||||
-- if this is first try (no denials, add a grade)
|
|
||||||
if self.section_tries == 0 then
|
|
||||||
self.grade = self.grade + 1
|
|
||||||
end
|
|
||||||
self.section_tries = 0
|
|
||||||
self.section_tetris_count = 0
|
|
||||||
-- record new section
|
|
||||||
section_time = self.frames - self.section_start_time
|
|
||||||
table.insert(self.section_times, section_time)
|
|
||||||
self.section_start_time = self.frames
|
|
||||||
-- maybe clear
|
|
||||||
if self.level == 2500 and not self.clear then
|
|
||||||
self.clear = true
|
|
||||||
self.grid:clear()
|
|
||||||
self.roll_frames = -150
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif old_level < 100 then
|
|
||||||
-- If section time is under cutoff, skip to level 500.
|
|
||||||
if self.frames < frameTime(1,00) then
|
|
||||||
self.level = 500
|
|
||||||
self.grade = 5
|
|
||||||
self.section_tries = 0
|
|
||||||
self.section_tetris_count = 0
|
|
||||||
else
|
|
||||||
self.level = math.min(new_level, 2500)
|
|
||||||
end
|
|
||||||
-- record new section
|
|
||||||
section_time = self.frames - self.section_start_time
|
|
||||||
table.insert(self.section_times, section_time)
|
|
||||||
self.section_start_time = self.frames
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.level = math.min(new_level, 2500)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:updateScore(level, drop_bonus, cleared_lines)
|
|
||||||
if cleared_lines > 0 then
|
|
||||||
self.score = self.score + (
|
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
|
||||||
)
|
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local letter_grades = {
|
|
||||||
[0] = "", "D", "C", "B", "A",
|
|
||||||
"S", "S-A", "S-B", "S-C", "S-D",
|
|
||||||
"X", "X-A", "X-B", "X-C", "X-D",
|
|
||||||
"W", "W-A", "W-B", "W-C", "W-D",
|
|
||||||
"Master", "MasterS", "MasterX", "MasterW", "Grand Master",
|
|
||||||
"Demon Master"
|
|
||||||
}
|
|
||||||
|
|
||||||
function DemonModeGame:getLetterGrade()
|
|
||||||
return letter_grades[self.grade]
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:drawGrid()
|
|
||||||
if self.clear and not (self.completed or self.game_over) then
|
|
||||||
self.grid:drawInvisible(self.rollOpacityFunction)
|
|
||||||
else
|
|
||||||
self.grid:draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
DemonModeGame.rollOpacityFunction = function(age)
|
|
||||||
if age > 4 then return 0
|
|
||||||
else return 1 - age / 4 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:drawScoringInfo()
|
|
||||||
DemonModeGame.super.drawScoringInfo(self)
|
|
||||||
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
|
||||||
love.graphics.print(
|
|
||||||
self.das.direction .. " " ..
|
|
||||||
self.das.frames .. " " ..
|
|
||||||
strTrueValues(self.prev_inputs)
|
|
||||||
)
|
|
||||||
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
||||||
love.graphics.printf("GRADE", 240, 120, 40, "left")
|
|
||||||
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
|
||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
|
||||||
|
|
||||||
-- draw section time data
|
|
||||||
local current_section = getSectionForLevel(self.level)
|
|
||||||
self:drawSectionTimesWithSecondary(current_section)
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
|
||||||
love.graphics.printf(self.score, 240, 220, 90, "left")
|
|
||||||
love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left")
|
|
||||||
love.graphics.printf(string.format("%.2f", self.level / 100), 240, 340, 70, "right")
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getHighscoreData()
|
|
||||||
return {
|
|
||||||
grade = self.grade,
|
|
||||||
level = self.level,
|
|
||||||
frames = self.frames,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function DemonModeGame:getBackground()
|
|
||||||
return math.floor(self.level / 100)
|
|
||||||
end
|
|
||||||
|
|
||||||
return DemonModeGame
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
local Object = require 'libs.classic'
|
local Object = require 'libs.classic'
|
||||||
require 'funcs'
|
require 'funcs'
|
||||||
|
|
||||||
|
local playedReadySE = false
|
||||||
|
local playedGoSE = false
|
||||||
|
|
||||||
local Grid = require 'tetris.components.grid'
|
local Grid = require 'tetris.components.grid'
|
||||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||||
|
|
||||||
@@ -40,9 +43,12 @@ function GameMode:new()
|
|||||||
self.draw_section_times = false
|
self.draw_section_times = false
|
||||||
self.draw_secondary_section_times = false
|
self.draw_secondary_section_times = false
|
||||||
self.big_mode = false
|
self.big_mode = false
|
||||||
|
self.rpc_details = "In game"
|
||||||
-- variables related to configurable parameters
|
-- variables related to configurable parameters
|
||||||
self.drop_locked = false
|
self.drop_locked = false
|
||||||
self.hard_drop_locked = false
|
self.hard_drop_locked = false
|
||||||
|
self.lock_on_soft_drop = false
|
||||||
|
self.lock_on_hard_drop = false
|
||||||
self.hold_queue = nil
|
self.hold_queue = nil
|
||||||
self.held = false
|
self.held = false
|
||||||
self.section_start_time = 0
|
self.section_start_time = 0
|
||||||
@@ -59,6 +65,7 @@ function GameMode:getLineClearDelay() return 40 end
|
|||||||
function GameMode:getDasLimit() return 15 end
|
function GameMode:getDasLimit() return 15 end
|
||||||
|
|
||||||
function GameMode:getNextPiece(ruleset)
|
function GameMode:getNextPiece(ruleset)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
skin = "2tie",
|
skin = "2tie",
|
||||||
shape = self.randomizer:nextPiece(),
|
shape = self.randomizer:nextPiece(),
|
||||||
@@ -68,9 +75,12 @@ end
|
|||||||
|
|
||||||
function GameMode:initialize(ruleset)
|
function GameMode:initialize(ruleset)
|
||||||
-- generate next queue
|
-- generate next queue
|
||||||
|
self:new()
|
||||||
for i = 1, self.next_queue_length do
|
for i = 1, self.next_queue_length do
|
||||||
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
||||||
end
|
end
|
||||||
|
self.lock_on_soft_drop = ({ruleset.softdrop_lock, self.instant_soft_drop, false, true })[config.gamesettings.manlock]
|
||||||
|
self.lock_on_hard_drop = ({ruleset.harddrop_lock, self.instant_hard_drop, true, false})[config.gamesettings.manlock]
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:update(inputs, ruleset)
|
function GameMode:update(inputs, ruleset)
|
||||||
@@ -124,7 +134,7 @@ function GameMode:update(inputs, ruleset)
|
|||||||
self.piece:isDropBlocked(self.grid) and
|
self.piece:isDropBlocked(self.grid) and
|
||||||
not self.hard_drop_locked then
|
not self.hard_drop_locked then
|
||||||
self:onHardDrop(piece_dy)
|
self:onHardDrop(piece_dy)
|
||||||
if self.instant_hard_drop then
|
if self.lock_on_hard_drop then
|
||||||
self.piece.locked = true
|
self.piece.locked = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -133,7 +143,7 @@ function GameMode:update(inputs, ruleset)
|
|||||||
self:onSoftDrop(piece_dy)
|
self:onSoftDrop(piece_dy)
|
||||||
if self.piece:isDropBlocked(self.grid) and
|
if self.piece:isDropBlocked(self.grid) and
|
||||||
not self.drop_locked and
|
not self.drop_locked and
|
||||||
self.instant_soft_drop
|
self.lock_on_soft_drop
|
||||||
then
|
then
|
||||||
self.piece.locked = true
|
self.piece.locked = true
|
||||||
end
|
end
|
||||||
@@ -154,6 +164,7 @@ function GameMode:update(inputs, ruleset)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if cleared_row_count > 0 then
|
if cleared_row_count > 0 then
|
||||||
|
playSE("erase")
|
||||||
self.lcd = self:getLineClearDelay()
|
self.lcd = self:getLineClearDelay()
|
||||||
self.are = self:getLineARE()
|
self.are = self:getLineARE()
|
||||||
if self.lcd == 0 then
|
if self.lcd == 0 then
|
||||||
@@ -187,10 +198,16 @@ end
|
|||||||
|
|
||||||
-- event functions
|
-- event functions
|
||||||
function GameMode:whilePieceActive() end
|
function GameMode:whilePieceActive() end
|
||||||
function GameMode:onPieceLock(piece, cleared_row_count) end
|
function GameMode:onPieceLock(piece, cleared_row_count)
|
||||||
|
playSE("lock")
|
||||||
|
end
|
||||||
|
|
||||||
function GameMode:onLineClear(cleared_row_count) end
|
function GameMode:onLineClear(cleared_row_count) end
|
||||||
|
|
||||||
function GameMode:onPieceEnter() end
|
function GameMode:onPieceEnter() end
|
||||||
function GameMode:onHold() end
|
function GameMode:onHold()
|
||||||
|
playSE("hold")
|
||||||
|
end
|
||||||
|
|
||||||
function GameMode:onSoftDrop(dropped_row_count)
|
function GameMode:onSoftDrop(dropped_row_count)
|
||||||
self.drop_bonus = self.drop_bonus + 1 * dropped_row_count
|
self.drop_bonus = self.drop_bonus + 1 * dropped_row_count
|
||||||
@@ -232,8 +249,20 @@ function GameMode:chargeDAS(inputs)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:processDelays(inputs, ruleset, drop_speed)
|
function GameMode:processDelays(inputs, ruleset, drop_speed)
|
||||||
|
if self.ready_frames == 100 then
|
||||||
|
playedReadySE = false
|
||||||
|
playedGoSE = false
|
||||||
|
end
|
||||||
if self.ready_frames > 0 then
|
if self.ready_frames > 0 then
|
||||||
|
if not playedReadySE then
|
||||||
|
playedReadySE = true
|
||||||
|
playSEOnce("ready")
|
||||||
|
end
|
||||||
self.ready_frames = self.ready_frames - 1
|
self.ready_frames = self.ready_frames - 1
|
||||||
|
if self.ready_frames == 50 and not playedGoSE then
|
||||||
|
playedGoSE = true
|
||||||
|
playSEOnce("go")
|
||||||
|
end
|
||||||
if self.ready_frames == 0 then
|
if self.ready_frames == 0 then
|
||||||
self:initializeOrHold(inputs, ruleset)
|
self:initializeOrHold(inputs, ruleset)
|
||||||
end
|
end
|
||||||
@@ -241,6 +270,7 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
|
|||||||
self.lcd = self.lcd - 1
|
self.lcd = self.lcd - 1
|
||||||
if self.lcd == 0 then
|
if self.lcd == 0 then
|
||||||
self.grid:clearClearedRows()
|
self.grid:clearClearedRows()
|
||||||
|
playSE("fall")
|
||||||
if self.are == 0 then
|
if self.are == 0 then
|
||||||
self:initializeOrHold(inputs, ruleset)
|
self:initializeOrHold(inputs, ruleset)
|
||||||
end
|
end
|
||||||
@@ -339,11 +369,12 @@ function GameMode:drawGhostPiece(ruleset)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:drawNextQueue(ruleset)
|
function GameMode:drawNextQueue(ruleset)
|
||||||
|
local colourscheme = ({ruleset.colourscheme, ColourSchemes.Arika, ColourSchemes.TTC})[config.gamesettings.piece_colour]
|
||||||
function drawPiece(piece, skin, offsets, pos_x, pos_y)
|
function drawPiece(piece, skin, offsets, pos_x, pos_y)
|
||||||
for index, offset in pairs(offsets) do
|
for index, offset in pairs(offsets) do
|
||||||
local x = offset.x + ruleset.spawn_positions[piece].x
|
local x = offset.x + ruleset.spawn_positions[piece].x
|
||||||
local y = offset.y + 4.7
|
local y = offset.y + 4.7
|
||||||
love.graphics.draw(blocks[skin][piece], pos_x+x*16, pos_y+y*16)
|
love.graphics.draw(blocks[skin][colourscheme[piece]], pos_x+x*16, pos_y+y*16)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i = 1, self.next_queue_length do
|
for i = 1, self.next_queue_length do
|
||||||
@@ -358,7 +389,8 @@ function GameMode:drawNextQueue(ruleset)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.hold_queue ~= nil then
|
if self.hold_queue ~= nil then
|
||||||
self:setHoldOpacity()
|
local hold_color = self.held and 0.6 or 1
|
||||||
|
self:setHoldOpacity(1, hold_color)
|
||||||
drawPiece(
|
drawPiece(
|
||||||
self.hold_queue.shape,
|
self.hold_queue.shape,
|
||||||
self.hold_queue.skin,
|
self.hold_queue.skin,
|
||||||
@@ -369,8 +401,16 @@ function GameMode:drawNextQueue(ruleset)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:setNextOpacity(i) love.graphics.setColor(1, 1, 1, 1) end
|
function GameMode:setNextOpacity(i, j)
|
||||||
function GameMode:setHoldOpacity() love.graphics.setColor(1, 1, 1, 1) end
|
i = i ~= nil and i or 1
|
||||||
|
j = j ~= nil and j or 1
|
||||||
|
love.graphics.setColor(j, j, j, i)
|
||||||
|
end
|
||||||
|
function GameMode:setHoldOpacity(i, j)
|
||||||
|
i = i ~= nil and i or 1
|
||||||
|
j = j ~= nil and j or 1
|
||||||
|
love.graphics.setColor(j, j, j, i)
|
||||||
|
end
|
||||||
|
|
||||||
function GameMode:drawScoringInfo()
|
function GameMode:drawScoringInfo()
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
require 'funcs'
|
|
||||||
|
|
||||||
local GameMode = require 'tetris.modes.gamemode'
|
|
||||||
local Piece = require 'tetris.components.piece'
|
|
||||||
|
|
||||||
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls'
|
|
||||||
|
|
||||||
local IntervalTrainingGame = GameMode:extend()
|
|
||||||
|
|
||||||
IntervalTrainingGame.name = "Interval Training"
|
|
||||||
IntervalTrainingGame.hash = "IntervalTraining"
|
|
||||||
IntervalTrainingGame.tagline = "Can you clear the time hurdles when the game goes this fast?"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function IntervalTrainingGame:new()
|
|
||||||
IntervalTrainingGame.super:new()
|
|
||||||
self.roll_frames = 0
|
|
||||||
self.combo = 1
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
|
||||||
self.section_time_limit = 1800
|
|
||||||
self.section_start_time = 0
|
|
||||||
self.section_times = { [0] = 0 }
|
|
||||||
self.lock_drop = true
|
|
||||||
self.enable_hold = true
|
|
||||||
self.next_queue_length = 3
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getARE()
|
|
||||||
return 4
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getLineARE()
|
|
||||||
return 4
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getDasLimit()
|
|
||||||
return 6
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getLineClearDelay()
|
|
||||||
return 6
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getLockDelay()
|
|
||||||
return 15
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getGravity()
|
|
||||||
return 20
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getSection()
|
|
||||||
return math.floor(level / 100) + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:advanceOneFrame()
|
|
||||||
if self.clear then
|
|
||||||
self.roll_frames = self.roll_frames + 1
|
|
||||||
if self.roll_frames > 2968 then
|
|
||||||
self.completed = true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
elseif self.ready_frames == 0 then
|
|
||||||
self.frames = self.frames + 1
|
|
||||||
if self:getSectionTime() >= self.section_time_limit then
|
|
||||||
self.game_over = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:onPieceEnter()
|
|
||||||
if (self.level % 100 ~= 99 or self.level == 998) and not self.clear and self.frames ~= 0 then
|
|
||||||
self.level = self.level + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:onLineClear(cleared_row_count)
|
|
||||||
if not self.clear then
|
|
||||||
local new_level = self.level + cleared_row_count
|
|
||||||
self:updateSectionTimes(self.level, new_level)
|
|
||||||
self.level = math.min(new_level, 999)
|
|
||||||
if self.level == 999 then
|
|
||||||
self.clear = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getSectionTime()
|
|
||||||
return self.frames - self.section_start_time
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:updateSectionTimes(old_level, new_level)
|
|
||||||
if math.floor(old_level / 100) < math.floor(new_level / 100) then
|
|
||||||
-- record new section
|
|
||||||
table.insert(self.section_times, self:getSectionTime())
|
|
||||||
self.section_start_time = self.frames
|
|
||||||
else
|
|
||||||
self.level = math.min(new_level, 999)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:drawGrid(ruleset)
|
|
||||||
self.grid:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getHighscoreData()
|
|
||||||
return {
|
|
||||||
level = self.level,
|
|
||||||
frames = self.frames,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:drawScoringInfo()
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
|
||||||
love.graphics.print(
|
|
||||||
self.das.direction .. " " ..
|
|
||||||
self.das.frames .. " " ..
|
|
||||||
strTrueValues(self.prev_inputs)
|
|
||||||
)
|
|
||||||
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
||||||
love.graphics.printf("TIME LEFT", 240, 250, 80, "left")
|
|
||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
|
||||||
|
|
||||||
local current_section = math.floor(self.level / 100) + 1
|
|
||||||
self:drawSectionTimesWithSplits(current_section)
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
|
||||||
love.graphics.printf(self.level, 240, 340, 40, "right")
|
|
||||||
|
|
||||||
-- draw time left, flash red if necessary
|
|
||||||
local time_left = self.section_time_limit - math.max(self:getSectionTime(), 0)
|
|
||||||
if not self.game_over and not self.clear and time_left < frameTime(0,10) and time_left % 4 < 2 then
|
|
||||||
love.graphics.setColor(1, 0.3, 0.3, 1)
|
|
||||||
end
|
|
||||||
love.graphics.printf(formatTime(time_left), 240, 270, 160, "left")
|
|
||||||
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getSectionEndLevel()
|
|
||||||
if self.level >= 900 then return 999
|
|
||||||
else return math.floor(self.level / 100 + 1) * 100 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function IntervalTrainingGame:getBackground()
|
|
||||||
return math.floor(self.level / 100)
|
|
||||||
end
|
|
||||||
|
|
||||||
return IntervalTrainingGame
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
require 'funcs'
|
|
||||||
|
|
||||||
local GameMode = require 'tetris.modes.gamemode'
|
|
||||||
local Piece = require 'tetris.components.piece'
|
|
||||||
|
|
||||||
local KonohaRandomizer = require 'tetris.randomizers.bag_konoha'
|
|
||||||
|
|
||||||
local KonohaGame = GameMode:extend()
|
|
||||||
|
|
||||||
KonohaGame.name = "All Clear A4"
|
|
||||||
KonohaGame.hash = "AllClearA4"
|
|
||||||
KonohaGame.tagline = "Get as many bravos as you can under the time limit!"
|
|
||||||
|
|
||||||
function KonohaGame:new()
|
|
||||||
KonohaGame.super:new()
|
|
||||||
|
|
||||||
self.randomizer = KonohaRandomizer()
|
|
||||||
self.bravos = 0
|
|
||||||
self.last_bonus_amount = 0
|
|
||||||
self.last_bonus_display_time = 0
|
|
||||||
self.time_limit = 10800
|
|
||||||
self.big_mode = true
|
|
||||||
|
|
||||||
self.enable_hold = true
|
|
||||||
self.next_queue_length = 3
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getARE()
|
|
||||||
if self.level < 300 then return 30
|
|
||||||
elseif self.level < 400 then return 25
|
|
||||||
elseif self.level < 500 then return 20
|
|
||||||
elseif self.level < 600 then return 17
|
|
||||||
elseif self.level < 800 then return 15
|
|
||||||
elseif self.level < 900 then return 13
|
|
||||||
elseif self.level < 1000 then return 10
|
|
||||||
elseif self.level < 1300 then return 8
|
|
||||||
else return 6 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getLineARE()
|
|
||||||
return self:getARE()
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getDasLimit()
|
|
||||||
if self.level < 500 then return 10
|
|
||||||
elseif self.level < 800 then return 9
|
|
||||||
elseif self.level < 1000 then return 8
|
|
||||||
else return 7 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getLineClearDelay()
|
|
||||||
if self.level < 200 then return 14
|
|
||||||
elseif self.level < 500 then return 9
|
|
||||||
elseif self.level < 800 then return 8
|
|
||||||
elseif self.level < 1000 then return 7
|
|
||||||
else return 6 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getLockDelay()
|
|
||||||
if self.level < 500 then return 30
|
|
||||||
elseif self.level < 600 then return 25
|
|
||||||
elseif self.level < 700 then return 23
|
|
||||||
elseif self.level < 800 then return 20
|
|
||||||
elseif self.level < 900 then return 17
|
|
||||||
elseif self.level < 1000 then return 15
|
|
||||||
elseif self.level < 1200 then return 13
|
|
||||||
elseif self.level < 1300 then return 10
|
|
||||||
else return 8 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getGravity()
|
|
||||||
if (self.level < 30) then return 4/256
|
|
||||||
elseif (self.level < 35) then return 8/256
|
|
||||||
elseif (self.level < 40) then return 12/256
|
|
||||||
elseif (self.level < 50) then return 16/256
|
|
||||||
elseif (self.level < 60) then return 32/256
|
|
||||||
elseif (self.level < 70) then return 48/256
|
|
||||||
elseif (self.level < 80) then return 64/256
|
|
||||||
elseif (self.level < 90) then return 128/256
|
|
||||||
elseif (self.level < 100) then return 192/256
|
|
||||||
elseif (self.level < 120) then return 1
|
|
||||||
elseif (self.level < 140) then return 2
|
|
||||||
elseif (self.level < 160) then return 3
|
|
||||||
elseif (self.level < 170) then return 4
|
|
||||||
elseif (self.level < 200) then return 5
|
|
||||||
else return 20 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getSection()
|
|
||||||
return math.floor(level / 100) + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getSectionEndLevel()
|
|
||||||
return math.floor(self.level / 100 + 1) * 100
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:advanceOneFrame()
|
|
||||||
if self.ready_frames == 0 then
|
|
||||||
self.time_limit = self.time_limit - 1
|
|
||||||
self.frames = self.frames + 1
|
|
||||||
end
|
|
||||||
if self.time_limit <= 0 then
|
|
||||||
self.game_over = true
|
|
||||||
end
|
|
||||||
self.last_bonus_display_time = self.last_bonus_display_time - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:onPieceEnter()
|
|
||||||
if (self.level % 100 ~= 99) and self.frames ~= 0 then
|
|
||||||
self.level = self.level + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:drawGrid(ruleset)
|
|
||||||
self.grid:draw()
|
|
||||||
if self.piece ~= nil and self.level < 100 then
|
|
||||||
self:drawGhostPiece(ruleset)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local cleared_row_levels = {2, 4, 6, 12}
|
|
||||||
local bravo_bonus = {300, 480, 660, 900}
|
|
||||||
local non_bravo_bonus = {0, 0, 20, 40}
|
|
||||||
local bravo_ot_bonus = {0, 60, 120, 180}
|
|
||||||
|
|
||||||
function KonohaGame:onLineClear(cleared_row_count)
|
|
||||||
local oldtime = self.time_limit
|
|
||||||
|
|
||||||
self.level = self.level + cleared_row_levels[cleared_row_count / 2]
|
|
||||||
self.bravo = true
|
|
||||||
for i = 0, 23 - cleared_row_count do
|
|
||||||
for j = 0, 9 do
|
|
||||||
if self.grid:isOccupied(j, i) then
|
|
||||||
self.bravo = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if self.bravo then
|
|
||||||
self.bravos = self.bravos + 1
|
|
||||||
if self.level < 1000 then self.time_limit = self.time_limit + bravo_bonus[cleared_row_count / 2]
|
|
||||||
else self.time_limit = self.time_limit + bravo_ot_bonus[cleared_row_count / 2]
|
|
||||||
end
|
|
||||||
if self.bravos == 11 then self.randomizer.allowrepeat = true end
|
|
||||||
elseif self.level < 1000 then
|
|
||||||
self.time_limit = self.time_limit + non_bravo_bonus[cleared_row_count / 2]
|
|
||||||
end
|
|
||||||
|
|
||||||
local bonus = self.time_limit - oldtime
|
|
||||||
if bonus > 0 then
|
|
||||||
self.last_bonus_amount = bonus
|
|
||||||
self.last_bonus_display_time = 120
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getBackground()
|
|
||||||
return math.min(math.floor(self.level / 100), 9)
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:drawScoringInfo()
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
|
||||||
love.graphics.print(
|
|
||||||
self.das.direction .. " " ..
|
|
||||||
self.das.frames .. " " ..
|
|
||||||
strTrueValues(self.prev_inputs)
|
|
||||||
)
|
|
||||||
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
||||||
love.graphics.printf("TIME LIMIT", 240, 120, 120, "left")
|
|
||||||
love.graphics.printf("BRAVOS", 240, 200, 50, "left")
|
|
||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
|
||||||
if not self.game_over and self.time_limit < frameTime(0,10) and self.time_limit % 4 < 2 then
|
|
||||||
love.graphics.setColor(1, 0.3, 0.3, 1)
|
|
||||||
end
|
|
||||||
love.graphics.printf(formatTime(self.time_limit), 240, 140, 120, "right")
|
|
||||||
if self.last_bonus_display_time > 0 then
|
|
||||||
love.graphics.printf("+"..formatTime(self.last_bonus_amount), 240, 160, 120, "right")
|
|
||||||
end
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
love.graphics.printf(self.bravos, 240, 220, 90, "left")
|
|
||||||
love.graphics.printf(self.level, 240, 340, 50, "right")
|
|
||||||
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 50, "right")
|
|
||||||
|
|
||||||
love.graphics.setFont(font_8x11)
|
|
||||||
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
|
||||||
end
|
|
||||||
|
|
||||||
function KonohaGame:getHighscoreData()
|
|
||||||
return {
|
|
||||||
bravos = self.bravos,
|
|
||||||
level = self.level,
|
|
||||||
frames = self.frames,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return KonohaGame
|
|
||||||
@@ -36,6 +36,8 @@ function Marathon2020Game:new()
|
|||||||
self.grade_points = 0
|
self.grade_points = 0
|
||||||
self.grade_point_decay_counter = 0
|
self.grade_point_decay_counter = 0
|
||||||
self.max_grade_points = 0
|
self.max_grade_points = 0
|
||||||
|
|
||||||
|
self.cool_timer = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function Marathon2020Game:getARE()
|
function Marathon2020Game:getARE()
|
||||||
@@ -327,6 +329,7 @@ function Marathon2020Game:updateSectionTimes(old_level, new_level)
|
|||||||
self.section_cool_count = self.section_cool_count + 1
|
self.section_cool_count = self.section_cool_count + 1
|
||||||
self.delay_level = math.min(20, self.delay_level + 1)
|
self.delay_level = math.min(20, self.delay_level + 1)
|
||||||
table.insert(self.section_status, "cool")
|
table.insert(self.section_status, "cool")
|
||||||
|
self.cool_timer = 300
|
||||||
end
|
end
|
||||||
|
|
||||||
local section = getSectionForLevel(old_level)
|
local section = getSectionForLevel(old_level)
|
||||||
@@ -430,6 +433,11 @@ function Marathon2020Game:drawScoringInfo()
|
|||||||
|
|
||||||
self:drawSectionTimesWithSecondary(current_section)
|
self:drawSectionTimesWithSecondary(current_section)
|
||||||
|
|
||||||
|
if (self.cool_timer > 0) then
|
||||||
|
love.graphics.printf("COOL!!", 64, 400, 160, "center")
|
||||||
|
self.cool_timer = self.cool_timer - 1
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(self:getTotalGrade(), text_x, 120, 90, "left")
|
love.graphics.printf(self:getTotalGrade(), text_x, 120, 90, "left")
|
||||||
love.graphics.printf(self.grade_points, text_x, 220, 90, "left")
|
love.graphics.printf(self.grade_points, text_x, 220, 90, "left")
|
||||||
|
|||||||
@@ -18,11 +18,17 @@ function MarathonA1Game:new()
|
|||||||
|
|
||||||
self.roll_frames = 0
|
self.roll_frames = 0
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
|
self.bravos = 0
|
||||||
self.gm_conditions = {
|
self.gm_conditions = {
|
||||||
level300 = false,
|
level300 = false,
|
||||||
level500 = false,
|
level500 = false,
|
||||||
level999 = false
|
level999 = false
|
||||||
}
|
}
|
||||||
|
self.SGnames = {
|
||||||
|
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.randomizer = History4RollsRandomizer()
|
self.randomizer = History4RollsRandomizer()
|
||||||
|
|
||||||
@@ -131,40 +137,44 @@ function MarathonA1Game:onLineClear(cleared_row_count)
|
|||||||
self:checkGMRequirements(self.level, self.level + cleared_row_count)
|
self:checkGMRequirements(self.level, self.level + cleared_row_count)
|
||||||
if not self.clear then
|
if not self.clear then
|
||||||
local new_level = math.min(self.level + cleared_row_count, 999)
|
local new_level = math.min(self.level + cleared_row_count, 999)
|
||||||
if self.level == 999 then
|
if new_level == 999 then
|
||||||
self.clear = true
|
self.clear = true
|
||||||
else
|
|
||||||
self.level = new_level
|
|
||||||
end
|
end
|
||||||
|
self.level = new_level
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MarathonA1Game:updateScore(level, drop_bonus, cleared_lines)
|
function MarathonA1Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
|
if self.grid:checkForBravo(cleared_lines) then
|
||||||
|
self.bravo = 4
|
||||||
|
self.bravos = self.bravos + 1
|
||||||
|
else self.bravo = 1 end
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
self.combo = self.combo + (cleared_lines - 1) * 2
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * self.combo
|
cleared_lines * self.combo * self.bravo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MarathonA1Game:checkGMRequirements(old_level, new_level)
|
function MarathonA1Game:checkGMRequirements(old_level, new_level)
|
||||||
if old_level < 300 and new_level >= 300 then
|
if old_level < 300 and new_level >= 300 then
|
||||||
if self.score > 12000 and self.frames <= frameTime(4,15) then
|
if self.score >= 12000 and self.frames <= frameTime(4,15) then
|
||||||
self.gm_conditions["level300"] = true
|
self.gm_conditions["level300"] = true
|
||||||
end
|
end
|
||||||
elseif old_level < 500 and new_level >= 500 then
|
elseif old_level < 500 and new_level >= 500 then
|
||||||
if self.score > 40000 and self.frames <= frameTime(7,30) then
|
if self.score >= 40000 and self.frames <= frameTime(7,30) then
|
||||||
self.gm_conditions["level500"] = true
|
self.gm_conditions["level500"] = true
|
||||||
end
|
end
|
||||||
elseif old_level < 999 and new_level >= 999 then
|
elseif old_level < 999 and new_level >= 999 then
|
||||||
if self.score > 126000 and self.frames <= frameTime(13,30) then
|
if self.score >= 126000 and self.frames <= frameTime(13,30) then
|
||||||
self.gm_conditions["level900"] = true
|
self.gm_conditions["level999"] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -191,10 +201,16 @@ function MarathonA1Game:drawScoringInfo()
|
|||||||
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
||||||
love.graphics.printf("NEXT RANK", 240, 260, 90, "left")
|
love.graphics.printf("NEXT RANK", 240, 260, 90, "left")
|
||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.bravos > 0 then love.graphics.printf("BRAVO", 300, 120, 40, "left") end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(self.score, 240, 220, 90, "left")
|
love.graphics.printf(self.score, 240, 220, 90, "left")
|
||||||
if self.gm_conditions["level300"] and self.gm_conditions["level500"] and self.gm_conditions["level900"] then
|
if self.gm_conditions["level300"] and self.gm_conditions["level500"] and self.gm_conditions["level999"] then
|
||||||
love.graphics.printf("GM", 240, 140, 90, "left")
|
love.graphics.printf("GM", 240, 140, 90, "left")
|
||||||
else
|
else
|
||||||
love.graphics.printf(getRankForScore(self.score).rank, 240, 140, 90, "left")
|
love.graphics.printf(getRankForScore(self.score).rank, 240, 140, 90, "left")
|
||||||
@@ -202,6 +218,10 @@ function MarathonA1Game:drawScoringInfo()
|
|||||||
love.graphics.printf(getRankForScore(self.score).next, 240, 280, 90, "left")
|
love.graphics.printf(getRankForScore(self.score).next, 240, 280, 90, "left")
|
||||||
love.graphics.printf(self.level, 240, 340, 40, "right")
|
love.graphics.printf(self.level, 240, 340, 40, "right")
|
||||||
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
|
if self.bravos > 0 then love.graphics.printf(self.bravos, 300, 140, 40, "left") end
|
||||||
|
|
||||||
love.graphics.setFont(font_8x11)
|
love.graphics.setFont(font_8x11)
|
||||||
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
||||||
|
|||||||
@@ -27,9 +27,14 @@ function MarathonA2Game:new()
|
|||||||
self.section_times = { [0] = 0 }
|
self.section_times = { [0] = 0 }
|
||||||
self.section_tetrises = { [0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
self.section_tetrises = { [0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||||
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.SGnames = {
|
||||||
|
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.lock_drop = false
|
self.lock_drop = false
|
||||||
|
self.lock_hard_drop = false
|
||||||
self.enable_hold = false
|
self.enable_hold = false
|
||||||
self.next_queue_length = 1
|
self.next_queue_length = 1
|
||||||
end
|
end
|
||||||
@@ -103,6 +108,7 @@ end
|
|||||||
function MarathonA2Game:advanceOneFrame()
|
function MarathonA2Game:advanceOneFrame()
|
||||||
if self.clear then
|
if self.clear then
|
||||||
self.roll_frames = self.roll_frames + 1
|
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 > 3694 then
|
||||||
self.completed = true
|
self.completed = true
|
||||||
if self.grade == 32 then
|
if self.grade == 32 then
|
||||||
@@ -121,32 +127,33 @@ function MarathonA2Game:onPieceEnter()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MarathonA2Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
|
self:updateGrade(cleared_lines)
|
||||||
|
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 MarathonA2Game:onLineClear(cleared_row_count)
|
function MarathonA2Game:onLineClear(cleared_row_count)
|
||||||
self:updateSectionTimes(self.level, self.level + cleared_row_count)
|
|
||||||
self.level = math.min(self.level + cleared_row_count, 999)
|
self.level = math.min(self.level + cleared_row_count, 999)
|
||||||
if self.level == 999 and not self.clear then
|
if self.level == 999 and not self.clear then
|
||||||
self.clear = true
|
self.clear = true
|
||||||
if self:qualifiesForMRoll() then
|
|
||||||
self.grade = 32
|
|
||||||
end
|
|
||||||
self.grid:clear()
|
self.grid:clear()
|
||||||
|
if self:qualifiesForMRoll() then self.grade = 32 end
|
||||||
self.roll_frames = -150
|
self.roll_frames = -150
|
||||||
end
|
end
|
||||||
end
|
self.lock_drop = self.level >= 900
|
||||||
|
self.lock_hard_drop = self.level >= 900
|
||||||
function MarathonA2Game:updateScore(level, drop_bonus, cleared_lines)
|
|
||||||
self:updateGrade(cleared_lines)
|
|
||||||
if cleared_lines > 0 then
|
|
||||||
self.score = self.score + (
|
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
|
||||||
)
|
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function MarathonA2Game:updateSectionTimes(old_level, new_level)
|
function MarathonA2Game:updateSectionTimes(old_level, new_level)
|
||||||
@@ -246,7 +253,7 @@ function MarathonA2Game:updateGrade(cleared_lines)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tetris_requirements = { [0] = 2, 2, 2, 2, 2, 1, 1, 1, 1, 1 }
|
local tetris_requirements = { [0] = 2, 2, 2, 2, 2, 1, 1, 1, 1, 0 }
|
||||||
|
|
||||||
function MarathonA2Game:qualifiesForMRoll()
|
function MarathonA2Game:qualifiesForMRoll()
|
||||||
if not self.clear then return false end
|
if not self.clear then return false end
|
||||||
@@ -273,7 +280,7 @@ function MarathonA2Game:qualifiesForMRoll()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.grade < 17 or self.frames > frameTime(8,45) then
|
if self.grade < 31 or self.frames > frameTime(8,45) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@@ -331,12 +338,29 @@ function MarathonA2Game:drawScoringInfo()
|
|||||||
love.graphics.printf("GRADE", 240, 120, 40, "left")
|
love.graphics.printf("GRADE", 240, 120, 40, "left")
|
||||||
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
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)
|
||||||
|
else love.graphics.setColor(0, 1, 0, 1) end
|
||||||
|
else
|
||||||
|
if self.roll_frames > 3694 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||||
|
else love.graphics.setColor(0, 1, 0, 1) end
|
||||||
|
end
|
||||||
|
end
|
||||||
love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left")
|
love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left")
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.printf(self.score, 240, 220, 90, "left")
|
love.graphics.printf(self.score, 240, 220, 90, "left")
|
||||||
love.graphics.printf(self.level, 240, 340, 40, "right")
|
love.graphics.printf(self.level, 240, 340, 40, "right")
|
||||||
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_8x11)
|
love.graphics.setFont(font_8x11)
|
||||||
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
||||||
|
|||||||
@@ -29,13 +29,25 @@ function MarathonA3Game:new()
|
|||||||
self.section_start_time = 0
|
self.section_start_time = 0
|
||||||
self.section_70_times = { [0] = 0 }
|
self.section_70_times = { [0] = 0 }
|
||||||
self.section_times = { [0] = 0 }
|
self.section_times = { [0] = 0 }
|
||||||
|
self.section_cool = false
|
||||||
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = History6RollsRandomizer()
|
||||||
|
|
||||||
|
self.SGnames = {
|
||||||
|
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.lock_drop = true
|
self.lock_drop = true
|
||||||
self.lock_hard_drop = true
|
self.lock_hard_drop = true
|
||||||
self.enable_hold = true
|
self.enable_hold = true
|
||||||
self.next_queue_length = 3
|
self.next_queue_length = 3
|
||||||
|
|
||||||
|
self.coolregret_message = "COOL!!"
|
||||||
|
self.coolregret_timer = 0
|
||||||
|
|
||||||
|
self.torikan_passed = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function MarathonA3Game:getARE()
|
function MarathonA3Game:getARE()
|
||||||
@@ -140,6 +152,7 @@ function MarathonA3Game:onPieceEnter()
|
|||||||
self:updateSectionTimes(self.level, self.level + 1)
|
self:updateSectionTimes(self.level, self.level + 1)
|
||||||
self.level = self.level + 1
|
self.level = self.level + 1
|
||||||
self.speed_level = self.speed_level + 1
|
self.speed_level = self.speed_level + 1
|
||||||
|
self.torikan_passed = self.level >= 500 and true or false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -157,6 +170,10 @@ function MarathonA3Game:onLineClear(cleared_row_count)
|
|||||||
self.grid:clear()
|
self.grid:clear()
|
||||||
self.roll_frames = -150
|
self.roll_frames = -150
|
||||||
end
|
end
|
||||||
|
if not self.torikan_passed and self.level >= 500 and self.frames >= 25200 then
|
||||||
|
self.level = 500
|
||||||
|
self.game_over = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cool_cutoffs = {
|
local cool_cutoffs = {
|
||||||
@@ -179,43 +196,54 @@ function MarathonA3Game:updateSectionTimes(old_level, new_level)
|
|||||||
table.insert(self.section_times, section_time)
|
table.insert(self.section_times, section_time)
|
||||||
self.section_start_time = self.frames
|
self.section_start_time = self.frames
|
||||||
|
|
||||||
|
self.speed_level = self.section_cool and self.speed_level + 100 or self.speed_level
|
||||||
|
|
||||||
if section_time > regret_cutoffs[section] then
|
if section_time > regret_cutoffs[section] then
|
||||||
self.section_cool_grade = self.section_cool_grade - 1
|
self.section_cool_grade = self.section_cool_grade - 1
|
||||||
table.insert(self.section_status, "regret")
|
table.insert(self.section_status, "regret")
|
||||||
elseif section <= 9 and self.section_status[section - 1] == "cool" and
|
self.coolregret_message = "REGRET!!"
|
||||||
self.section_70_times[section] < self.section_70_times[section - 1] + 120 then
|
self.coolregret_timer = 300
|
||||||
|
elseif self.section_cool then
|
||||||
self.section_cool_grade = self.section_cool_grade + 1
|
self.section_cool_grade = self.section_cool_grade + 1
|
||||||
self.speed_level = self.speed_level + 100
|
|
||||||
table.insert(self.section_status, "cool")
|
|
||||||
elseif self.section_status[section - 1] == "cool" then
|
|
||||||
table.insert(self.section_status, "none")
|
|
||||||
elseif section <= 9 and self.section_70_times[section] < cool_cutoffs[section] then
|
|
||||||
self.section_cool_grade = self.section_cool_grade + 1
|
|
||||||
self.speed_level = self.speed_level + 100
|
|
||||||
table.insert(self.section_status, "cool")
|
table.insert(self.section_status, "cool")
|
||||||
else
|
else
|
||||||
table.insert(self.section_status, "none")
|
table.insert(self.section_status, "none")
|
||||||
end
|
end
|
||||||
elseif section <= 9 and old_level % 100 < 70 and new_level % 100 >= 70 then
|
|
||||||
|
self.section_cool = false
|
||||||
|
elseif old_level % 100 < 70 and new_level % 100 >= 70 then
|
||||||
-- record section 70 time
|
-- record section 70 time
|
||||||
section_70_time = self.frames - self.section_start_time
|
section_70_time = self.frames - self.section_start_time
|
||||||
table.insert(self.section_70_times, section_70_time)
|
table.insert(self.section_70_times, section_70_time)
|
||||||
|
|
||||||
|
if section <= 9 and self.section_status[section - 1] == "cool" and
|
||||||
|
self.section_70_times[section] < self.section_70_times[section - 1] + 120 then
|
||||||
|
self.section_cool = true
|
||||||
|
self.coolregret_message = "COOL!!"
|
||||||
|
self.coolregret_timer = 300
|
||||||
|
elseif self.section_status[section - 1] == "cool" then self.section_cool = false
|
||||||
|
elseif section <= 9 and self.section_70_times[section] < cool_cutoffs[section] then
|
||||||
|
self.section_cool = true
|
||||||
|
self.coolregret_message = "COOL!!"
|
||||||
|
self.coolregret_timer = 300
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MarathonA3Game:updateScore(level, drop_bonus, cleared_lines)
|
function MarathonA3Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
self:updateGrade(cleared_lines)
|
self:updateGrade(cleared_lines)
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
cleared_lines * self.combo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local grade_point_bonuses = {
|
local grade_point_bonuses = {
|
||||||
@@ -334,6 +362,8 @@ function MarathonA3Game:getLetterGrade()
|
|||||||
return "M" .. tostring(grade - 17)
|
return "M" .. tostring(grade - 17)
|
||||||
elseif grade < 32 then
|
elseif grade < 32 then
|
||||||
return master_grades[grade - 26]
|
return master_grades[grade - 26]
|
||||||
|
elseif grade >= 32 and self.roll_frames < 3238 then
|
||||||
|
return "MM"
|
||||||
else
|
else
|
||||||
return "GM"
|
return "GM"
|
||||||
end
|
end
|
||||||
@@ -378,6 +408,10 @@ function MarathonA3Game:drawScoringInfo()
|
|||||||
love.graphics.printf("GRADE", 240, 120, 40, "left")
|
love.graphics.printf("GRADE", 240, 120, 40, "left")
|
||||||
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
-- draw section time data
|
-- draw section time data
|
||||||
current_section = math.floor(self.level / 100) + 1
|
current_section = math.floor(self.level / 100) + 1
|
||||||
@@ -404,13 +438,24 @@ function MarathonA3Game:drawScoringInfo()
|
|||||||
current_x = section_70_x
|
current_x = section_70_x
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.printf(formatTime(self.frames - self.section_start_time), current_x, 40 + 20 * current_section, 90, "left")
|
if not self.clear then love.graphics.printf(formatTime(self.frames - self.section_start_time), current_x, 40 + 20 * current_section, 90, "left") end
|
||||||
|
|
||||||
|
if(self.coolregret_timer > 0) then
|
||||||
|
love.graphics.printf(self.coolregret_message, 64, 400, 160, "center")
|
||||||
|
self.coolregret_timer = self.coolregret_timer - 1
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(self.score, 240, 220, 90, "left")
|
love.graphics.printf(self.score, 240, 220, 90, "left")
|
||||||
|
if self.roll_frames > 3238 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||||
|
elseif self.clear then love.graphics.setColor(0, 1, 0, 1) end
|
||||||
love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left")
|
love.graphics.printf(self:getLetterGrade(), 240, 140, 90, "left")
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.printf(self.level, 240, 340, 40, "right")
|
love.graphics.printf(self.level, 240, 340, 40, "right")
|
||||||
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_8x11)
|
love.graphics.setFont(font_8x11)
|
||||||
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'funcs'
|
|||||||
local GameMode = require 'tetris.modes.gamemode'
|
local GameMode = require 'tetris.modes.gamemode'
|
||||||
local Piece = require 'tetris.components.piece'
|
local Piece = require 'tetris.components.piece'
|
||||||
|
|
||||||
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls'
|
local Bag7NoSZOStartRandomizer = require 'tetris.randomizers.bag7noSZOstart'
|
||||||
|
|
||||||
local MarathonAX4Game = GameMode:extend()
|
local MarathonAX4Game = GameMode:extend()
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ function MarathonAX4Game:new()
|
|||||||
MarathonAX4Game.super:new()
|
MarathonAX4Game.super:new()
|
||||||
|
|
||||||
self.roll_frames = 0
|
self.roll_frames = 0
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = Bag7NoSZOStartRandomizer()
|
||||||
|
|
||||||
self.section_time_limit = 3600
|
self.section_time_limit = 3600
|
||||||
self.section_start_time = 0
|
self.section_start_time = 0
|
||||||
@@ -24,6 +24,7 @@ function MarathonAX4Game:new()
|
|||||||
self.section_clear = false
|
self.section_clear = false
|
||||||
|
|
||||||
self.lock_drop = true
|
self.lock_drop = true
|
||||||
|
self.lock_hard_drop = true
|
||||||
self.enable_hold = true
|
self.enable_hold = true
|
||||||
self.next_queue_length = 3
|
self.next_queue_length = 3
|
||||||
end
|
end
|
||||||
@@ -98,6 +99,7 @@ function MarathonAX4Game:onLineClear(cleared_row_count)
|
|||||||
self:updateSectionTimes(self.lines, new_lines)
|
self:updateSectionTimes(self.lines, new_lines)
|
||||||
self.lines = math.min(new_lines, 150)
|
self.lines = math.min(new_lines, 150)
|
||||||
if self.lines == 150 then
|
if self.lines == 150 then
|
||||||
|
self.grid:clear()
|
||||||
self.clear = true
|
self.clear = true
|
||||||
self.roll_frames = -150
|
self.roll_frames = -150
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,185 +0,0 @@
|
|||||||
require 'funcs'
|
|
||||||
|
|
||||||
local GameMode = require 'tetris.modes.gamemode'
|
|
||||||
local Piece = require 'tetris.components.piece'
|
|
||||||
|
|
||||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
|
||||||
|
|
||||||
local MarathonC89Game = GameMode:extend()
|
|
||||||
|
|
||||||
MarathonC89Game.name = "Marathon C89"
|
|
||||||
MarathonC89Game.hash = "MarathonC89"
|
|
||||||
MarathonC89Game.tagline = "Can you play fast enough to reach the killscreen?"
|
|
||||||
|
|
||||||
|
|
||||||
function MarathonC89Game:new()
|
|
||||||
MarathonC89Game.super:new()
|
|
||||||
|
|
||||||
self.randomizer = Randomizer()
|
|
||||||
|
|
||||||
self.ready_frames = 1
|
|
||||||
self.waiting_frames = 72
|
|
||||||
|
|
||||||
self.start_level = 12
|
|
||||||
self.level = 12
|
|
||||||
|
|
||||||
self.lock_drop = true
|
|
||||||
self.enable_hard_drop = false
|
|
||||||
self.enable_hold = false
|
|
||||||
self.next_queue_length = 1
|
|
||||||
self.additive_gravity = false
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonC89Game:getDropSpeed() return 1/2 end
|
|
||||||
function MarathonC89Game:getDasLimit() return 16 end
|
|
||||||
function MarathonC89Game:getARR() return 6 end
|
|
||||||
|
|
||||||
function MarathonC89Game:getARE() return 6 end
|
|
||||||
function MarathonC89Game:getLineARE() return 6 end
|
|
||||||
function MarathonC89Game:getLineClearDelay() return 30 end
|
|
||||||
function MarathonC89Game:getLockDelay() return 0 end
|
|
||||||
|
|
||||||
function MarathonC89Game:chargeDAS(inputs)
|
|
||||||
if inputs[self.das.direction] == true and
|
|
||||||
self.prev_inputs[self.das.direction] == true and
|
|
||||||
not inputs["down"] and
|
|
||||||
self.piece ~= nil
|
|
||||||
then
|
|
||||||
local das_frames = self.das.frames + 1
|
|
||||||
if das_frames >= self:getDasLimit() then
|
|
||||||
if self.das.direction == "left" then
|
|
||||||
self.move = (self:getARR() == 0 and "speed" or "") .. "left"
|
|
||||||
self.das.frames = self:getDasLimit() - self:getARR()
|
|
||||||
elseif self.das.direction == "right" then
|
|
||||||
self.move = (self:getARR() == 0 and "speed" or "") .. "right"
|
|
||||||
self.das.frames = self:getDasLimit() - self:getARR()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.move = "none"
|
|
||||||
self.das.frames = das_frames
|
|
||||||
end
|
|
||||||
elseif inputs["right"] == true then
|
|
||||||
self.das.direction = "right"
|
|
||||||
if not inputs["down"] and self.piece ~= nil then
|
|
||||||
self.move = "right"
|
|
||||||
self.das.frames = 0
|
|
||||||
else
|
|
||||||
self.move = "none"
|
|
||||||
end
|
|
||||||
elseif inputs["left"] == true then
|
|
||||||
self.das.direction = "left"
|
|
||||||
if not inputs["down"] and self.piece ~= nil then
|
|
||||||
self.move = "left"
|
|
||||||
self.das.frames = 0
|
|
||||||
else
|
|
||||||
self.move = "none"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.move = "none"
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.das.direction == "left" and self.piece ~= nil and self.piece:isMoveBlocked(self.grid, {x=-1, y=0}) or
|
|
||||||
self.das.direction == "right" and self.piece ~= nil and self.piece:isMoveBlocked(self.grid, {x=1, y=0})
|
|
||||||
then
|
|
||||||
self.das.frames = self:getDasLimit()
|
|
||||||
end
|
|
||||||
|
|
||||||
if inputs["down"] == false and self.prev_inputs["down"] == true then
|
|
||||||
self.drop_bonus = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local gravity_table = {
|
|
||||||
[0] =
|
|
||||||
1366/65536, 1525/65536, 1725/65536, 1986/65536, 2341/65536,
|
|
||||||
2850/65536, 3641/65536, 5042/65536, 8192/65536, 10923/65536,
|
|
||||||
13108/65536, 13108/65536, 13108/65536, 16384/65536, 16384/65536,
|
|
||||||
16384/65536, 21846/65536, 21846/65536, 21846/65536
|
|
||||||
}
|
|
||||||
|
|
||||||
function MarathonC89Game:getGravity()
|
|
||||||
if self.waiting_frames > 0 then return 0 end
|
|
||||||
if self.level >= 29 then return 1
|
|
||||||
elseif self.level >= 19 then return 1/2
|
|
||||||
else return gravity_table[self.level] end
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonC89Game:advanceOneFrame()
|
|
||||||
if self.waiting_frames > 0 then
|
|
||||||
self.waiting_frames = self.waiting_frames - 1
|
|
||||||
else
|
|
||||||
self.frames = self.frames + 1
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonC89Game:onPieceLock()
|
|
||||||
self.score = self.score + self.drop_bonus
|
|
||||||
self.drop_bonus = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local cleared_line_scores = { 40, 100, 300, 1200 }
|
|
||||||
|
|
||||||
function MarathonC89Game:getLevelForLines()
|
|
||||||
if self.start_level < 10 then
|
|
||||||
return math.max(self.start_level, math.floor(self.lines / 10))
|
|
||||||
elseif self.start_level < 16 then
|
|
||||||
return math.max(self.start_level, self.start_level + math.floor((self.lines - 100) / 10))
|
|
||||||
else
|
|
||||||
return math.max(self.start_level, math.floor((self.lines - 60) / 10))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonC89Game:updateScore(level, drop_bonus, cleared_lines)
|
|
||||||
if cleared_lines > 0 then
|
|
||||||
self.score = self.score + cleared_line_scores[cleared_lines] * (self.level + 1)
|
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.level = self:getLevelForLines()
|
|
||||||
else
|
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonC89Game:drawGrid()
|
|
||||||
self.grid:draw()
|
|
||||||
if self.piece ~= nil and self.level < 100 then
|
|
||||||
self:drawGhostPiece(ruleset)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonC89Game:drawScoringInfo()
|
|
||||||
MarathonC89Game.super.drawScoringInfo(self)
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
|
||||||
love.graphics.print(
|
|
||||||
self.das.direction .. " " ..
|
|
||||||
self.das.frames .. " " ..
|
|
||||||
strTrueValues(self.prev_inputs)
|
|
||||||
)
|
|
||||||
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
||||||
love.graphics.printf("LINES", 240, 120, 40, "left")
|
|
||||||
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
|
||||||
love.graphics.printf(self.lines, 240, 140, 90, "left")
|
|
||||||
love.graphics.printf(self.score, 240, 220, 90, "left")
|
|
||||||
|
|
||||||
love.graphics.setFont(font_8x11)
|
|
||||||
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function MarathonC89Game:getBackground()
|
|
||||||
return math.min(self.level, 19)
|
|
||||||
end
|
|
||||||
|
|
||||||
function MarathonC89Game:getHighscoreData()
|
|
||||||
return {
|
|
||||||
score = self.score,
|
|
||||||
level = self.level,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return MarathonC89Game
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
require 'funcs'
|
|
||||||
|
|
||||||
local GameMode = require 'tetris.modes.gamemode'
|
|
||||||
local Piece = require 'tetris.components.piece'
|
|
||||||
|
|
||||||
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls'
|
|
||||||
|
|
||||||
local PacerTest = GameMode:extend()
|
|
||||||
|
|
||||||
PacerTest.name = "TetrisGram™ Pacer Test"
|
|
||||||
PacerTest.hash = "PacerTest"
|
|
||||||
PacerTest.tagline = ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function getLevelFrames(level)
|
|
||||||
if level == 1 then return 72 * 60 / 8.0
|
|
||||||
else return 72 * 60 / (8 + level * 0.5)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local level_end_sections = {
|
|
||||||
7, 15, 23, 32, 41, 51, 61, 72, 83, 94,
|
|
||||||
106, 118, 131, 144, 157, 171, 185, 200,
|
|
||||||
215, 231, 247
|
|
||||||
}
|
|
||||||
|
|
||||||
function PacerTest:new()
|
|
||||||
PacerTest.super:new()
|
|
||||||
|
|
||||||
self.ready_frames = 2430
|
|
||||||
self.clear_frames = 0
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
|
||||||
|
|
||||||
self.level = 1
|
|
||||||
self.section = 0
|
|
||||||
self.level_frames = 0
|
|
||||||
|
|
||||||
self.section_lines = 0
|
|
||||||
self.section_clear = false
|
|
||||||
self.strikes = 0
|
|
||||||
|
|
||||||
self.lock_drop = true
|
|
||||||
self.lock_hard_drop = true
|
|
||||||
self.enable_hold = true
|
|
||||||
self.instant_hard_drop = true
|
|
||||||
self.instant_soft_drop = false
|
|
||||||
self.next_queue_length = 3
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:initialize(ruleset)
|
|
||||||
for i = 1, 30 do
|
|
||||||
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
|
||||||
end
|
|
||||||
self.level_frames = getLevelFrames(1)
|
|
||||||
switchBGM("pacer_test")
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getARE()
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getLineARE()
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getDasLimit()
|
|
||||||
return 8
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getLineClearDelay()
|
|
||||||
return 6
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getLockDelay()
|
|
||||||
return 30
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getGravity()
|
|
||||||
return 1/64
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getSection()
|
|
||||||
return math.floor(level / 100) + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:advanceOneFrame()
|
|
||||||
if self.clear then
|
|
||||||
self.clear_frames = self.clear_frames + 1
|
|
||||||
if self.clear_frames > 600 then
|
|
||||||
self.completed = true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
elseif self.ready_frames == 0 then
|
|
||||||
self.frames = self.frames + 1
|
|
||||||
self.level_frames = self.level_frames - 1
|
|
||||||
if self.level_frames <= 0 then
|
|
||||||
self:checkSectionStatus()
|
|
||||||
self.section = self.section + 1
|
|
||||||
if self.section >= level_end_sections[self.level] then
|
|
||||||
self.level = self.level + 1
|
|
||||||
end
|
|
||||||
self.level_frames = self.level_frames + getLevelFrames(self.level)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:checkSectionStatus()
|
|
||||||
if self.section_clear then
|
|
||||||
self.strikes = 0
|
|
||||||
self.section_clear = false
|
|
||||||
else
|
|
||||||
self.strikes = self.strikes + 1
|
|
||||||
if self.strikes >= 2 then
|
|
||||||
self.game_over = true
|
|
||||||
fadeoutBGM(2.5)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.section_lines = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:onLineClear(cleared_row_count)
|
|
||||||
self.section_lines = self.section_lines + cleared_row_count
|
|
||||||
if self.section_lines >= 3 then
|
|
||||||
self.section_clear = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:drawGrid(ruleset)
|
|
||||||
self.grid:draw()
|
|
||||||
if self.piece ~= nil then
|
|
||||||
self:drawGhostPiece(ruleset)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getHighscoreData()
|
|
||||||
return {
|
|
||||||
level = self.level,
|
|
||||||
frames = self.frames,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:drawScoringInfo()
|
|
||||||
PacerTest.super.drawScoringInfo(self)
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
|
|
||||||
local text_x = config["side_next"] and 320 or 240
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
|
||||||
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
||||||
love.graphics.printf("LINES", text_x, 224, 70, "left")
|
|
||||||
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
|
||||||
|
|
||||||
for i = 1, math.min(self.strikes, 3) do
|
|
||||||
love.graphics.draw(misc_graphics["strike"], text_x + (i - 1) * 30, 280)
|
|
||||||
end
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
|
||||||
love.graphics.printf(self.section_lines .. "/3", text_x, 244, 40, "left")
|
|
||||||
love.graphics.printf(self.level, text_x, 340, 40, "right")
|
|
||||||
love.graphics.printf(self.section, text_x, 370, 40, "right")
|
|
||||||
end
|
|
||||||
|
|
||||||
function PacerTest:getBackground()
|
|
||||||
return math.min(self.level - 1, 19)
|
|
||||||
end
|
|
||||||
|
|
||||||
return PacerTest
|
|
||||||
@@ -15,8 +15,15 @@ function PhantomManiaGame:new()
|
|||||||
PhantomManiaGame.super:new()
|
PhantomManiaGame.super:new()
|
||||||
|
|
||||||
self.lock_drop = true
|
self.lock_drop = true
|
||||||
|
self.lock_hard_drop = true
|
||||||
self.next_queue_length = 1
|
self.next_queue_length = 1
|
||||||
|
|
||||||
|
self.SGnames = {
|
||||||
|
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.roll_frames = 0
|
self.roll_frames = 0
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = History6RollsRandomizer()
|
||||||
@@ -111,17 +118,18 @@ function PhantomManiaGame:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function PhantomManiaGame:updateScore(level, drop_bonus, cleared_lines)
|
function PhantomManiaGame:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
cleared_lines * self.combo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
PhantomManiaGame.rollOpacityFunction = function(age)
|
PhantomManiaGame.rollOpacityFunction = function(age)
|
||||||
@@ -161,12 +169,16 @@ function PhantomManiaGame:drawScoringInfo()
|
|||||||
local text_x = config["side_next"] and 320 or 240
|
local text_x = config["side_next"] and 320 or 240
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
love.graphics.setFont(font_3x5_2)
|
||||||
love.graphics.printf("GRADE", text_x, 120, 40, "left")
|
if getLetterGrade(self.level, self.clear) ~= "" then love.graphics.printf("GRADE", text_x, 120, 40, "left") end
|
||||||
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
||||||
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(getLetterGrade(self.level, self.clear), text_x, 140, 90, "left")
|
if getLetterGrade(self.level, self.clear) ~= "" then love.graphics.printf(getLetterGrade(self.level, self.clear), text_x, 140, 90, "left") end
|
||||||
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
||||||
love.graphics.printf(self.level, text_x, 340, 40, "right")
|
love.graphics.printf(self.level, text_x, 340, 40, "right")
|
||||||
if self.clear then
|
if self.clear then
|
||||||
@@ -175,6 +187,9 @@ function PhantomManiaGame:drawScoringInfo()
|
|||||||
love.graphics.printf(self:getSectionEndLevel(), text_x, 370, 40, "right")
|
love.graphics.printf(self:getSectionEndLevel(), text_x, 370, 40, "right")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function PhantomManiaGame:getSectionEndLevel()
|
function PhantomManiaGame:getSectionEndLevel()
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ PhantomMania2Game.tagline = "The blocks disappear even faster now! Can you make
|
|||||||
|
|
||||||
function PhantomMania2Game:new()
|
function PhantomMania2Game:new()
|
||||||
PhantomMania2Game.super:new()
|
PhantomMania2Game.super:new()
|
||||||
self.level = 0
|
|
||||||
self.grade = 0
|
self.grade = 0
|
||||||
self.garbage = 0
|
self.garbage = 0
|
||||||
self.clear = false
|
self.clear = false
|
||||||
@@ -27,11 +26,21 @@ function PhantomMania2Game:new()
|
|||||||
self.queue_age = 0
|
self.queue_age = 0
|
||||||
self.roll_points = 0
|
self.roll_points = 0
|
||||||
|
|
||||||
|
self.SGnames = {
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"m1", "m2", "m3", "m4", "m5", "m6", "m7", "m8", "m9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = History6RollsRandomizer()
|
||||||
|
|
||||||
self.lock_drop = true
|
self.lock_drop = true
|
||||||
|
self.lock_hard_drop = true
|
||||||
self.enable_hold = true
|
self.enable_hold = true
|
||||||
self.next_queue_length = 3
|
self.next_queue_length = 3
|
||||||
|
|
||||||
|
self.coolregret_message = ""
|
||||||
|
self.coolregret_timer = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function PhantomMania2Game:getARE()
|
function PhantomMania2Game:getARE()
|
||||||
@@ -116,6 +125,8 @@ function PhantomMania2Game:advanceOneFrame()
|
|||||||
return false
|
return false
|
||||||
elseif self.roll_frames > 3238 then
|
elseif self.roll_frames > 3238 then
|
||||||
switchBGM(nil)
|
switchBGM(nil)
|
||||||
|
self.roll_points = self.level >= 1300 and self.roll_points + 150 or self.roll_points
|
||||||
|
self.grade = self.grade + math.floor(self.roll_points / 100)
|
||||||
self.completed = true
|
self.completed = true
|
||||||
end
|
end
|
||||||
elseif self.ready_frames == 0 then
|
elseif self.ready_frames == 0 then
|
||||||
@@ -137,7 +148,8 @@ function PhantomMania2Game:onPieceEnter()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local cleared_row_levels = {1, 2, 4, 6}
|
local cleared_row_levels = {1, 2, 4, 6}
|
||||||
local cleared_row_points = {2, 6, 15, 40}
|
local torikan_roll_points = {10, 20, 30, 100}
|
||||||
|
local big_roll_points = {10, 20, 100, 200}
|
||||||
|
|
||||||
function PhantomMania2Game:onLineClear(cleared_row_count)
|
function PhantomMania2Game:onLineClear(cleared_row_count)
|
||||||
if not self.clear then
|
if not self.clear then
|
||||||
@@ -156,7 +168,8 @@ function PhantomMania2Game:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
self:advanceBottomRow(-cleared_row_count)
|
self:advanceBottomRow(-cleared_row_count)
|
||||||
else
|
else
|
||||||
self.roll_points = self.roll_points + cleared_row_points[cleared_row_count / 2]
|
if self.big_mode then self.roll_points = self.roll_points + big_roll_points[cleared_row_count / 2]
|
||||||
|
else self.roll_points = self.roll_points + torikan_roll_points[cleared_row_count] end
|
||||||
if self.roll_points >= 100 then
|
if self.roll_points >= 100 then
|
||||||
self.roll_points = self.roll_points - 100
|
self.roll_points = self.roll_points - 100
|
||||||
self.grade = self.grade + 1
|
self.grade = self.grade + 1
|
||||||
@@ -165,25 +178,28 @@ function PhantomMania2Game:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function PhantomMania2Game:onPieceLock(piece, cleared_row_count)
|
function PhantomMania2Game:onPieceLock(piece, cleared_row_count)
|
||||||
|
self.super:onPieceLock()
|
||||||
if cleared_row_count == 0 then self:advanceBottomRow(1) end
|
if cleared_row_count == 0 then self:advanceBottomRow(1) end
|
||||||
end
|
end
|
||||||
|
|
||||||
function PhantomMania2Game:onHold()
|
function PhantomMania2Game:onHold()
|
||||||
|
self.super.onHold()
|
||||||
self.hold_age = 0
|
self.hold_age = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function PhantomMania2Game:updateScore(level, drop_bonus, cleared_lines)
|
function PhantomMania2Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
cleared_lines * self.combo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -207,8 +223,13 @@ function PhantomMania2Game:updateSectionTimes(old_level, new_level)
|
|||||||
self.section_start_time = self.frames
|
self.section_start_time = self.frames
|
||||||
if section_time <= cool_cutoffs[section] then
|
if section_time <= cool_cutoffs[section] then
|
||||||
self.grade = self.grade + 2
|
self.grade = self.grade + 2
|
||||||
|
self.coolregret_message = "COOL!!"
|
||||||
|
self.coolregret_timer = 300
|
||||||
elseif section_time <= regret_cutoffs[section] then
|
elseif section_time <= regret_cutoffs[section] then
|
||||||
self.grade = self.grade + 1
|
self.grade = self.grade + 1
|
||||||
|
else
|
||||||
|
self.coolregret_message = "REGRET!!"
|
||||||
|
self.coolregret_timer = 300
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -285,6 +306,17 @@ function PhantomMania2Game:drawScoringInfo()
|
|||||||
love.graphics.printf("GRADE", text_x, 120, 40, "left")
|
love.graphics.printf("GRADE", text_x, 120, 40, "left")
|
||||||
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
||||||
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
|
self:drawSectionTimesWithSplits(math.floor(self.level / 100) + 1)
|
||||||
|
|
||||||
|
if(self.coolregret_timer > 0) then
|
||||||
|
love.graphics.printf(self.coolregret_message, 64, 400, 160, "center")
|
||||||
|
self.coolregret_timer = self.coolregret_timer - 1
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(getLetterGrade(math.floor(self.grade)), text_x, 140, 90, "left")
|
love.graphics.printf(getLetterGrade(math.floor(self.grade)), text_x, 140, 90, "left")
|
||||||
@@ -295,6 +327,10 @@ function PhantomMania2Game:drawScoringInfo()
|
|||||||
else
|
else
|
||||||
love.graphics.printf(math.floor(self.level / 100 + 1) * 100, text_x, 370, 50, "right")
|
love.graphics.printf(math.floor(self.level / 100 + 1) * 100, text_x, 370, 50, "right")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function PhantomMania2Game:getBackground()
|
function PhantomMania2Game:getBackground()
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
local PhantomManiaGame = require 'tetris.modes.phantom_mania'
|
|
||||||
|
|
||||||
local PhantomManiaNGame = PhantomManiaGame:extend()
|
|
||||||
|
|
||||||
PhantomManiaNGame.name = "Phantom Mania N"
|
|
||||||
PhantomManiaNGame.hash = "PhantomManiaN"
|
|
||||||
PhantomManiaNGame.tagline = "The old mode from Nullpomino, for Ti-ARS and SRS support."
|
|
||||||
|
|
||||||
function PhantomManiaNGame:new()
|
|
||||||
PhantomManiaNGame.super:new()
|
|
||||||
|
|
||||||
self.next_queue_length = 3
|
|
||||||
self.enable_hold = true
|
|
||||||
end
|
|
||||||
|
|
||||||
return PhantomManiaNGame
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
require 'funcs'
|
|
||||||
|
|
||||||
local GameMode = require 'tetris.modes.gamemode'
|
|
||||||
local Piece = require 'tetris.components.piece'
|
|
||||||
|
|
||||||
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls'
|
|
||||||
|
|
||||||
local Race40Game = GameMode:extend()
|
|
||||||
|
|
||||||
Race40Game.name = "Race 40"
|
|
||||||
Race40Game.hash = "Race40"
|
|
||||||
Race40Game.tagline = "How fast can you clear 40 lines?"
|
|
||||||
|
|
||||||
|
|
||||||
function Race40Game:new()
|
|
||||||
Race40Game.super:new()
|
|
||||||
|
|
||||||
self.lines = 0
|
|
||||||
self.line_goal = 40
|
|
||||||
self.pieces = 0
|
|
||||||
self.randomizer = History6RollsRandomizer()
|
|
||||||
|
|
||||||
self.roll_frames = 0
|
|
||||||
|
|
||||||
self.lock_drop = true
|
|
||||||
self.lock_hard_drop = true
|
|
||||||
self.instant_hard_drop = true
|
|
||||||
self.instant_soft_drop = false
|
|
||||||
self.enable_hold = true
|
|
||||||
self.next_queue_length = 3
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getDropSpeed()
|
|
||||||
return 20
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getARR()
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getARE()
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getLineARE()
|
|
||||||
return self:getARE()
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getDasLimit()
|
|
||||||
return 6
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getLineClearDelay()
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getLockDelay()
|
|
||||||
return 15
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getGravity()
|
|
||||||
return 1/64
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:advanceOneFrame()
|
|
||||||
if self.clear then
|
|
||||||
self.roll_frames = self.roll_frames + 1
|
|
||||||
if self.roll_frames > 150 then
|
|
||||||
self.completed = true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
elseif self.ready_frames == 0 then
|
|
||||||
self.frames = self.frames + 1
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:onPieceLock()
|
|
||||||
self.pieces = self.pieces + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:onLineClear(cleared_row_count)
|
|
||||||
if not self.clear then
|
|
||||||
self.lines = self.lines + cleared_row_count
|
|
||||||
if self.lines >= self.line_goal then
|
|
||||||
self.clear = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:drawGrid(ruleset)
|
|
||||||
self.grid:draw()
|
|
||||||
if self.piece ~= nil then
|
|
||||||
self:drawGhostPiece(ruleset)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getHighscoreData()
|
|
||||||
return {
|
|
||||||
level = self.level,
|
|
||||||
frames = self.frames,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:drawScoringInfo()
|
|
||||||
Race40Game.super.drawScoringInfo(self)
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
|
|
||||||
local text_x = config["side_next"] and 320 or 240
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
|
||||||
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
||||||
love.graphics.printf("LINES", text_x, 320, 40, "left")
|
|
||||||
love.graphics.printf("line/min", text_x, 160, 80, "left")
|
|
||||||
love.graphics.printf("piece/sec", text_x, 220, 80, "left")
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
|
||||||
love.graphics.printf(string.format("%.02f", self.lines / math.max(1, self.frames) * 3600), text_x, 180, 80, "left")
|
|
||||||
love.graphics.printf(string.format("%.04f", self.pieces / math.max(1, self.frames) * 60), text_x, 240, 80, "left")
|
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_4)
|
|
||||||
love.graphics.printf(math.max(0, self.line_goal - self.lines), text_x, 340, 40, "left")
|
|
||||||
end
|
|
||||||
|
|
||||||
function Race40Game:getBackground()
|
|
||||||
return 2
|
|
||||||
end
|
|
||||||
|
|
||||||
return Race40Game
|
|
||||||
@@ -16,7 +16,6 @@ StrategyGame.tagline = "You have lots of time to think! Can you use it to place
|
|||||||
|
|
||||||
function StrategyGame:new()
|
function StrategyGame:new()
|
||||||
StrategyGame.super:new()
|
StrategyGame.super:new()
|
||||||
self.level = 0
|
|
||||||
self.clear = false
|
self.clear = false
|
||||||
self.completed = false
|
self.completed = false
|
||||||
self.roll_frames = 0
|
self.roll_frames = 0
|
||||||
@@ -84,7 +83,7 @@ function StrategyGame:advanceOneFrame()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function StrategyGame:onPieceEnter()
|
function StrategyGame:onPieceEnter()
|
||||||
if (self.level % 100 ~= 99) and not self.clear and self.frames ~= 0 then
|
if (self.level % 100 ~= 99 and self.level ~= 998) and not self.clear and self.frames ~= 0 then
|
||||||
self.level = self.level + 1
|
self.level = self.level + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -99,17 +98,18 @@ function StrategyGame:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function StrategyGame:updateScore(level, drop_bonus, cleared_lines)
|
function StrategyGame:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
cleared_lines * self.combo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function StrategyGame:setNextOpacity(i)
|
function StrategyGame:setNextOpacity(i)
|
||||||
@@ -135,11 +135,11 @@ function StrategyGame:drawScoringInfo()
|
|||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
||||||
love.graphics.printf(self.level, text_x, 340, 50, "right")
|
love.graphics.printf(self.level, text_x, 340, 40, "right")
|
||||||
if self.clear then
|
if self.clear then
|
||||||
love.graphics.printf(self.level, text_x, 370, 50, "right")
|
love.graphics.printf(self.level, text_x, 370, 40, "right")
|
||||||
else
|
else
|
||||||
love.graphics.printf(math.floor(self.level / 100 + 1) * 100, text_x, 370, 50, "right")
|
love.graphics.printf(self.level < 900 and math.floor(self.level / 100 + 1) * 100 or 999, text_x, 370, 40, "right")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ function Survival2020Game:new()
|
|||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = History6RollsRandomizer()
|
||||||
|
|
||||||
self.lock_drop = true
|
self.lock_drop = true
|
||||||
|
self.lock_hard_drop = true
|
||||||
self.enable_hold = true
|
self.enable_hold = true
|
||||||
self.next_queue_length = 3
|
self.next_queue_length = 3
|
||||||
end
|
end
|
||||||
@@ -174,17 +175,18 @@ function Survival2020Game:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Survival2020Game:updateScore(level, drop_bonus, cleared_lines)
|
function Survival2020Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
cleared_lines * self.combo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Survival2020Game:updateSectionTimes(old_level, new_level)
|
function Survival2020Game:updateSectionTimes(old_level, new_level)
|
||||||
|
|||||||
@@ -19,12 +19,20 @@ function SurvivalA1Game:new()
|
|||||||
|
|
||||||
self.roll_frames = 0
|
self.roll_frames = 0
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
|
self.bravos = 0
|
||||||
|
|
||||||
self.gm_conditions = {
|
self.gm_conditions = {
|
||||||
level300 = false,
|
level300 = false,
|
||||||
level500 = false,
|
level500 = false,
|
||||||
level999 = false
|
level999 = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.SGnames = {
|
||||||
|
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.randomizer = History4RollsRandomizer()
|
self.randomizer = History4RollsRandomizer()
|
||||||
|
|
||||||
self.lock_drop = false
|
self.lock_drop = false
|
||||||
@@ -101,7 +109,7 @@ function SurvivalA1Game:onLineClear(cleared_row_count)
|
|||||||
self:checkGMRequirements(self.level, self.level + cleared_row_count)
|
self:checkGMRequirements(self.level, self.level + cleared_row_count)
|
||||||
if not self.clear then
|
if not self.clear then
|
||||||
local new_level = math.min(self.level + cleared_row_count, 999)
|
local new_level = math.min(self.level + cleared_row_count, 999)
|
||||||
if self.level == 999 then
|
if new_level == 999 then
|
||||||
self.clear = true
|
self.clear = true
|
||||||
else
|
else
|
||||||
self.level = new_level
|
self.level = new_level
|
||||||
@@ -110,31 +118,36 @@ function SurvivalA1Game:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA1Game:updateScore(level, drop_bonus, cleared_lines)
|
function SurvivalA1Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
|
if self.grid:checkForBravo(cleared_lines) then
|
||||||
|
self.bravo = 4
|
||||||
|
self.bravos = self.bravos + 1
|
||||||
|
else self.bravo = 1 end
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * self.combo
|
cleared_lines * self.combo * self.bravo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + (cleared_lines - 1) * 2
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA1Game:checkGMRequirements(old_level, new_level)
|
function SurvivalA1Game:checkGMRequirements(old_level, new_level)
|
||||||
if old_level < 300 and new_level >= 300 then
|
if old_level < 300 and new_level >= 300 then
|
||||||
if self.score > 12000 and self.frames <= frameTime(4,15) then
|
if self.score >= 12000 and self.frames <= frameTime(4,15) then
|
||||||
self.gm_conditions["level300"] = true
|
self.gm_conditions["level300"] = true
|
||||||
end
|
end
|
||||||
elseif old_level < 500 and new_level >= 500 then
|
elseif old_level < 500 and new_level >= 500 then
|
||||||
if self.score > 40000 and self.frames <= frameTime(7,30) then
|
if self.score >= 40000 and self.frames <= frameTime(7,30) then
|
||||||
self.gm_conditions["level500"] = true
|
self.gm_conditions["level500"] = true
|
||||||
end
|
end
|
||||||
elseif old_level < 999 and new_level >= 999 then
|
elseif old_level < 999 and new_level >= 999 then
|
||||||
if self.score > 126000 and self.frames <= frameTime(13,30) then
|
if self.score >= 126000 and self.frames <= frameTime(13,30) then
|
||||||
self.gm_conditions["level900"] = true
|
self.gm_conditions["level999"] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -158,10 +171,16 @@ function SurvivalA1Game:drawScoringInfo()
|
|||||||
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
love.graphics.printf("SCORE", 240, 200, 40, "left")
|
||||||
love.graphics.printf("NEXT RANK", 240, 260, 90, "left")
|
love.graphics.printf("NEXT RANK", 240, 260, 90, "left")
|
||||||
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
love.graphics.printf("LEVEL", 240, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.bravos > 0 then love.graphics.printf("BRAVO", 300, 120, 40, "left") end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(self.score, 240, 220, 90, "left")
|
love.graphics.printf(self.score, 240, 220, 90, "left")
|
||||||
if self.gm_conditions["level300"] and self.gm_conditions["level500"] and self.gm_conditions["level900"] then
|
if self.gm_conditions["level300"] and self.gm_conditions["level500"] and self.gm_conditions["level999"] then
|
||||||
love.graphics.printf("GM", 240, 140, 90, "left")
|
love.graphics.printf("GM", 240, 140, 90, "left")
|
||||||
else
|
else
|
||||||
love.graphics.printf(getRankForScore(self.score).rank, 240, 140, 90, "left")
|
love.graphics.printf(getRankForScore(self.score).rank, 240, 140, 90, "left")
|
||||||
@@ -169,6 +188,10 @@ function SurvivalA1Game:drawScoringInfo()
|
|||||||
love.graphics.printf(getRankForScore(self.score).next, 240, 280, 90, "left")
|
love.graphics.printf(getRankForScore(self.score).next, 240, 280, 90, "left")
|
||||||
love.graphics.printf(self.level, 240, 340, 40, "right")
|
love.graphics.printf(self.level, 240, 340, 40, "right")
|
||||||
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 40, "right")
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
|
if self.bravos > 0 then love.graphics.printf(self.bravos, 300, 140, 40, "left") end
|
||||||
|
|
||||||
love.graphics.setFont(font_8x11)
|
love.graphics.setFont(font_8x11)
|
||||||
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
|
||||||
|
|||||||
@@ -20,7 +20,14 @@ function SurvivalA2Game:new()
|
|||||||
self.combo = 1
|
self.combo = 1
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = History6RollsRandomizer()
|
||||||
|
|
||||||
|
self.SGnames = {
|
||||||
|
"9", "8", "7", "6", "5", "4", "3", "2", "1",
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.lock_drop = true
|
self.lock_drop = true
|
||||||
|
self.lock_hard_drop = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA2Game:getARE()
|
function SurvivalA2Game:getARE()
|
||||||
@@ -82,7 +89,7 @@ function SurvivalA2Game:advanceOneFrame()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA2Game:onPieceEnter()
|
function SurvivalA2Game:onPieceEnter()
|
||||||
if (self.level % 100 ~= 99 or self.level == 998) and not self.clear and self.frames ~= 0 then
|
if (self.level % 100 ~= 99 and self.level ~= 998) and not self.clear and self.frames ~= 0 then
|
||||||
self.level = self.level + 1
|
self.level = self.level + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -92,6 +99,9 @@ function SurvivalA2Game:onLineClear(cleared_row_count)
|
|||||||
local new_level = math.min(self.level + cleared_row_count, 999)
|
local new_level = math.min(self.level + cleared_row_count, 999)
|
||||||
if self.level == 999 or self:hitTorikan(self.level, new_level) then
|
if self.level == 999 or self:hitTorikan(self.level, new_level) then
|
||||||
self.clear = true
|
self.clear = true
|
||||||
|
if self.level < 999 then
|
||||||
|
self.game_over = true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self.level = new_level
|
self.level = new_level
|
||||||
end
|
end
|
||||||
@@ -99,22 +109,25 @@ function SurvivalA2Game:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA2Game:updateScore(level, drop_bonus, cleared_lines)
|
function SurvivalA2Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
|
if self.grid:checkForBravo(cleared_lines) then self.bravo = 4 else self.bravo = 1 end
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * self.combo
|
cleared_lines * self.combo * self.bravo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + (cleared_lines - 1) * 2
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA2Game:getLetterGrade()
|
function SurvivalA2Game:getLetterGrade()
|
||||||
if self.level >= 999 then return "GM"
|
if self.level >= 999 then return "GM"
|
||||||
elseif self.level >= 500 then return "M"
|
elseif self.level > 500 then return "M"
|
||||||
|
elseif self.level == 500 and not self.clear then return "M"
|
||||||
else return "" end
|
else return "" end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -135,15 +148,24 @@ function SurvivalA2Game:drawScoringInfo()
|
|||||||
strTrueValues(self.prev_inputs)
|
strTrueValues(self.prev_inputs)
|
||||||
)
|
)
|
||||||
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
||||||
love.graphics.printf("GRADE", text_x, 120, 40, "left")
|
if self:getLetterGrade() ~= "" then love.graphics.printf("GRADE", text_x, 120, 40, "left") end
|
||||||
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
||||||
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
||||||
love.graphics.printf(self:getLetterGrade(), text_x, 140, 90, "left")
|
if self.roll_frames > 2968 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||||
|
elseif self.clear then love.graphics.setColor(0, 1, 0, 1) end
|
||||||
|
if self:getLetterGrade() ~= "" then love.graphics.printf(self:getLetterGrade(), text_x, 140, 90, "left") end
|
||||||
love.graphics.printf(self.level, text_x, 340, 40, "right")
|
love.graphics.printf(self.level, text_x, 340, 40, "right")
|
||||||
love.graphics.printf(self:getSectionEndLevel(), text_x, 370, 40, "right")
|
love.graphics.printf(self:getSectionEndLevel(), text_x, 370, 40, "right")
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA2Game:getSectionEndLevel()
|
function SurvivalA2Game:getSectionEndLevel()
|
||||||
|
|||||||
@@ -12,11 +12,8 @@ SurvivalA3Game.hash = "SurvivalA3"
|
|||||||
SurvivalA3Game.tagline = "The blocks turn black and white! Can you make it to level 1300?"
|
SurvivalA3Game.tagline = "The blocks turn black and white! Can you make it to level 1300?"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function SurvivalA3Game:new()
|
function SurvivalA3Game:new()
|
||||||
SurvivalA3Game.super:new()
|
SurvivalA3Game.super:new()
|
||||||
self.level = 0
|
|
||||||
self.grade = 0
|
self.grade = 0
|
||||||
self.garbage = 0
|
self.garbage = 0
|
||||||
self.clear = false
|
self.clear = false
|
||||||
@@ -25,9 +22,27 @@ function SurvivalA3Game:new()
|
|||||||
self.combo = 1
|
self.combo = 1
|
||||||
self.randomizer = History6RollsRandomizer()
|
self.randomizer = History6RollsRandomizer()
|
||||||
|
|
||||||
|
self.SGnames = {
|
||||||
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
|
||||||
|
"m1", "m2", "m3", "m4", "m5", "m6", "m7", "m8", "m9",
|
||||||
|
"GM"
|
||||||
|
}
|
||||||
|
|
||||||
self.lock_drop = true
|
self.lock_drop = true
|
||||||
|
self.lock_hard_drop = true
|
||||||
self.enable_hold = true
|
self.enable_hold = true
|
||||||
self.next_queue_length = 3
|
self.next_queue_length = 3
|
||||||
|
|
||||||
|
self.coolregret_message = "COOL!!"
|
||||||
|
self.coolregret_timer = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function SurvivalA3Game:initialize(ruleset)
|
||||||
|
|
||||||
|
self.torikan_time = frameTime(2,28)
|
||||||
|
if ruleset.world then self.torikan_time = frameTime(3,03) end
|
||||||
|
self.super.initialize(self, ruleset)
|
||||||
|
-- ^ notice the . here instead of the :
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA3Game:getARE()
|
function SurvivalA3Game:getARE()
|
||||||
@@ -86,11 +101,11 @@ function SurvivalA3Game:getNextPiece(ruleset)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA3Game:hitTorikan(old_level, new_level)
|
function SurvivalA3Game:hitTorikan(old_level, new_level)
|
||||||
if old_level < 500 and new_level >= 500 and self.frames > frameTime(2,28) then
|
if old_level < 500 and new_level >= 500 and self.frames > self.torikan_time then
|
||||||
self.level = 500
|
self.level = 500
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if old_level < 1000 and new_level >= 1000 and self.frames > frameTime(4,56) then
|
if old_level < 1000 and new_level >= 1000 and self.frames > self.torikan_time*2 then
|
||||||
self.level = 1000
|
self.level = 1000
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -123,20 +138,21 @@ function SurvivalA3Game:onPieceEnter()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local cleared_row_levels = {1, 2, 4, 6}
|
local cleared_row_levels = {1, 2, 4, 6}
|
||||||
local cleared_row_points = {0.02, 0.05, 0.15, 0.6}
|
|
||||||
|
|
||||||
function SurvivalA3Game:onLineClear(cleared_row_count)
|
function SurvivalA3Game:onLineClear(cleared_row_count)
|
||||||
if not self.clear then
|
if not self.clear then
|
||||||
local new_level = self.level + cleared_row_levels[cleared_row_count]
|
local new_level = self.level + cleared_row_levels[cleared_row_count]
|
||||||
self:updateSectionTimes(self.level, new_level)
|
self:updateSectionTimes(self.level, new_level)
|
||||||
if new_level >= 1300 or self:hitTorikan(self.level, new_level) then
|
if new_level >= 1300 or self:hitTorikan(self.level, new_level) then
|
||||||
|
self.clear = true
|
||||||
if new_level >= 1300 then
|
if new_level >= 1300 then
|
||||||
self.level = 1300
|
self.level = 1300
|
||||||
end
|
|
||||||
self.clear = true
|
|
||||||
self.grid:clear()
|
self.grid:clear()
|
||||||
self.big_mode = true
|
self.big_mode = true
|
||||||
self.roll_frames = -150
|
self.roll_frames = -150
|
||||||
|
else
|
||||||
|
self.game_over = true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self.level = math.min(new_level, 1300)
|
self.level = math.min(new_level, 1300)
|
||||||
end
|
end
|
||||||
@@ -145,21 +161,23 @@ function SurvivalA3Game:onLineClear(cleared_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA3Game:onPieceLock(piece, cleared_row_count)
|
function SurvivalA3Game:onPieceLock(piece, cleared_row_count)
|
||||||
|
self.super:onPieceLock()
|
||||||
if cleared_row_count == 0 then self:advanceBottomRow(1) end
|
if cleared_row_count == 0 then self:advanceBottomRow(1) end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA3Game:updateScore(level, drop_bonus, cleared_lines)
|
function SurvivalA3Game:updateScore(level, drop_bonus, cleared_lines)
|
||||||
|
if not self.clear then
|
||||||
if cleared_lines > 0 then
|
if cleared_lines > 0 then
|
||||||
|
self.combo = self.combo + (cleared_lines - 1) * 2
|
||||||
self.score = self.score + (
|
self.score = self.score + (
|
||||||
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
|
||||||
cleared_lines * (cleared_lines * 2 - 1) * (self.combo * 2 - 1)
|
cleared_lines * self.combo
|
||||||
)
|
)
|
||||||
self.lines = self.lines + cleared_lines
|
|
||||||
self.combo = self.combo + cleared_lines - 1
|
|
||||||
else
|
else
|
||||||
self.drop_bonus = 0
|
|
||||||
self.combo = 1
|
self.combo = 1
|
||||||
end
|
end
|
||||||
|
self.drop_bonus = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA3Game:updateSectionTimes(old_level, new_level)
|
function SurvivalA3Game:updateSectionTimes(old_level, new_level)
|
||||||
@@ -170,6 +188,9 @@ function SurvivalA3Game:updateSectionTimes(old_level, new_level)
|
|||||||
self.section_start_time = self.frames
|
self.section_start_time = self.frames
|
||||||
if section_time <= frameTime(1,00) then
|
if section_time <= frameTime(1,00) then
|
||||||
self.grade = self.grade + 1
|
self.grade = self.grade + 1
|
||||||
|
else
|
||||||
|
self.coolregret_message = "REGRET!!"
|
||||||
|
self.coolregret_timer = 300
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -207,12 +228,24 @@ function SurvivalA3Game:drawScoringInfo()
|
|||||||
love.graphics.printf("GRADE", text_x, 120, 40, "left")
|
love.graphics.printf("GRADE", text_x, 120, 40, "left")
|
||||||
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
love.graphics.printf("SCORE", text_x, 200, 40, "left")
|
||||||
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
|
||||||
|
local sg = self.grid:checkSecretGrade()
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
|
||||||
|
end
|
||||||
|
|
||||||
|
if(self.coolregret_timer > 0) then
|
||||||
|
love.graphics.printf(self.coolregret_message, 64, 400, 160, "center")
|
||||||
|
self.coolregret_timer = self.coolregret_timer - 1
|
||||||
|
end
|
||||||
|
|
||||||
local current_section = math.floor(self.level / 100) + 1
|
local current_section = math.floor(self.level / 100) + 1
|
||||||
self:drawSectionTimesWithSplits(current_section)
|
self:drawSectionTimesWithSplits(current_section)
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
|
if self.roll_frames > 3238 then love.graphics.setColor(1, 0.5, 0, 1)
|
||||||
|
elseif self.clear then love.graphics.setColor(0, 1, 0, 1) end
|
||||||
love.graphics.printf(getLetterGrade(math.floor(self.grade)), text_x, 140, 90, "left")
|
love.graphics.printf(getLetterGrade(math.floor(self.grade)), text_x, 140, 90, "left")
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
love.graphics.printf(self.score, text_x, 220, 90, "left")
|
||||||
love.graphics.printf(self.level, text_x, 340, 50, "right")
|
love.graphics.printf(self.level, text_x, 340, 50, "right")
|
||||||
if self.clear then
|
if self.clear then
|
||||||
@@ -220,6 +253,9 @@ function SurvivalA3Game:drawScoringInfo()
|
|||||||
else
|
else
|
||||||
love.graphics.printf(math.floor(self.level / 100 + 1) * 100, text_x, 370, 50, "right")
|
love.graphics.printf(math.floor(self.level / 100 + 1) * 100, text_x, 370, 50, "right")
|
||||||
end
|
end
|
||||||
|
if sg >= 5 then
|
||||||
|
love.graphics.printf(self.SGnames[sg], 240, 450, 180, "left")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SurvivalA3Game:getBackground()
|
function SurvivalA3Game:getBackground()
|
||||||
|
|||||||
@@ -2,17 +2,8 @@ local Randomizer = require 'tetris.randomizers.randomizer'
|
|||||||
|
|
||||||
local AlwaysRandomizer = Randomizer:extend()
|
local AlwaysRandomizer = Randomizer:extend()
|
||||||
|
|
||||||
function AlwaysRandomizer:new(piece)
|
|
||||||
self.piece = piece
|
|
||||||
self:initialize()
|
|
||||||
self.next_queue = {}
|
|
||||||
for i = 1, 30 do
|
|
||||||
table.insert(self.next_queue, self:generatePiece())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function AlwaysRandomizer:generatePiece()
|
function AlwaysRandomizer:generatePiece()
|
||||||
return self.piece
|
return "I"
|
||||||
end
|
end
|
||||||
|
|
||||||
return AlwaysRandomizer
|
return AlwaysRandomizer
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
|
||||||
|
|
||||||
local Bag5Randomizer = Randomizer:extend()
|
|
||||||
|
|
||||||
function Bag5Randomizer:initialize()
|
|
||||||
self.bag = {"I", "J", "L", "O", "T"}
|
|
||||||
end
|
|
||||||
|
|
||||||
function Bag5Randomizer:generatePiece()
|
|
||||||
if next(self.bag) == nil then
|
|
||||||
self.bag = {"I", "J", "L", "O", "T"}
|
|
||||||
end
|
|
||||||
local x = math.random(table.getn(self.bag))
|
|
||||||
return table.remove(self.bag, x)
|
|
||||||
end
|
|
||||||
|
|
||||||
return Bag5Randomizer
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
|
||||||
|
|
||||||
local Bag5AltRandomizer = Randomizer:extend()
|
|
||||||
|
|
||||||
function Bag5AltRandomizer:initialize()
|
|
||||||
self.bag = {"I", "J", "L", "O", "T"}
|
|
||||||
self.prev = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function Bag5AltRandomizer:generatePiece()
|
|
||||||
if next(self.bag) == nil then
|
|
||||||
self.bag = {"I", "J", "L", "O", "T"}
|
|
||||||
end
|
|
||||||
local x = math.random(table.getn(self.bag))
|
|
||||||
local temp = table.remove(self.bag, x)
|
|
||||||
if temp == self.prev then
|
|
||||||
local y = math.random(table.getn(self.bag))
|
|
||||||
temp = table.remove(self.bag, y)
|
|
||||||
end
|
|
||||||
self.prev = temp
|
|
||||||
return temp
|
|
||||||
end
|
|
||||||
|
|
||||||
return Bag5AltRandomizer
|
|
||||||
31
tetris/randomizers/bag7noSZOstart.lua
Normal file
31
tetris/randomizers/bag7noSZOstart.lua
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||||
|
|
||||||
|
local Bag7NoSZOStartRandomizer = Randomizer:extend()
|
||||||
|
|
||||||
|
function Bag7NoSZOStartRandomizer:shuffleBag()
|
||||||
|
local b = self.bag
|
||||||
|
local ln = #b
|
||||||
|
for i = 1, ln do
|
||||||
|
local j = math.random(i, ln)
|
||||||
|
b[i], b[j] = b[j], b[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function isnotSZO(x) return not(x == "S" or x == "Z" or x == "O") end
|
||||||
|
|
||||||
|
function Bag7NoSZOStartRandomizer:initialize()
|
||||||
|
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
|
repeat
|
||||||
|
self:shuffleBag()
|
||||||
|
until isnotSZO(self.bag[7])
|
||||||
|
end
|
||||||
|
|
||||||
|
function Bag7NoSZOStartRandomizer:generatePiece()
|
||||||
|
if #self.bag == 0 then
|
||||||
|
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
|
self:shuffleBag()
|
||||||
|
end
|
||||||
|
return table.remove(self.bag)
|
||||||
|
end
|
||||||
|
|
||||||
|
return Bag7NoSZOStartRandomizer
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
|
||||||
|
|
||||||
local BagKonoha = Randomizer:extend()
|
|
||||||
|
|
||||||
function BagKonoha:initialize()
|
|
||||||
self.bag = {"I", "J", "L", "O", "T"}
|
|
||||||
self.prev = nil
|
|
||||||
self.allowrepeat = false
|
|
||||||
self.generated = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function BagKonoha:generatePiece()
|
|
||||||
self.generated = self.generated + 1
|
|
||||||
if #self.bag == 0 then
|
|
||||||
self.bag = {"I", "J", "L", "O", "T"}
|
|
||||||
end
|
|
||||||
local x = math.random(#self.bag)
|
|
||||||
local temp = table.remove(self.bag, x)
|
|
||||||
if temp == self.prev and not self.allowrepeat then
|
|
||||||
local y = math.random(#self.bag)
|
|
||||||
table.insert(self.bag, temp) -- should insert at the end of the bag, bag[y] doesnt change
|
|
||||||
temp = table.remove(self.bag, y)
|
|
||||||
end
|
|
||||||
self.prev = temp
|
|
||||||
return temp
|
|
||||||
end
|
|
||||||
|
|
||||||
return BagKonoha
|
|
||||||
@@ -3,10 +3,15 @@ local Randomizer = require 'tetris.randomizers.randomizer'
|
|||||||
local History4RollsRandomizer = Randomizer:extend()
|
local History4RollsRandomizer = Randomizer:extend()
|
||||||
|
|
||||||
function History4RollsRandomizer:initialize()
|
function History4RollsRandomizer:initialize()
|
||||||
self.history = {"Z", "S", "Z", "S"}
|
self.history = {"Z", "Z", "Z", "Z"}
|
||||||
|
self.first = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function History4RollsRandomizer:generatePiece()
|
function History4RollsRandomizer:generatePiece()
|
||||||
|
if self.first then
|
||||||
|
self.first = false
|
||||||
|
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
||||||
|
else
|
||||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
local x = math.random(7)
|
local x = math.random(7)
|
||||||
@@ -15,6 +20,7 @@ function History4RollsRandomizer:generatePiece()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function History4RollsRandomizer:updateHistory(shape)
|
function History4RollsRandomizer:updateHistory(shape)
|
||||||
table.remove(self.history, 1)
|
table.remove(self.history, 1)
|
||||||
|
|||||||
@@ -4,9 +4,14 @@ local History6RollsRandomizer = Randomizer:extend()
|
|||||||
|
|
||||||
function History6RollsRandomizer:initialize()
|
function History6RollsRandomizer:initialize()
|
||||||
self.history = {"Z", "S", "Z", "S"}
|
self.history = {"Z", "S", "Z", "S"}
|
||||||
|
self.first = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function History6RollsRandomizer:generatePiece()
|
function History6RollsRandomizer:generatePiece()
|
||||||
|
if self.first then
|
||||||
|
self.first = false
|
||||||
|
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
||||||
|
else
|
||||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
for i = 1, 6 do
|
for i = 1, 6 do
|
||||||
local x = math.random(7)
|
local x = math.random(7)
|
||||||
@@ -15,6 +20,7 @@ function History6RollsRandomizer:generatePiece()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function History6RollsRandomizer:updateHistory(shape)
|
function History6RollsRandomizer:updateHistory(shape)
|
||||||
table.remove(self.history, 1)
|
table.remove(self.history, 1)
|
||||||
|
|||||||
@@ -1,38 +1,70 @@
|
|||||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||||
|
|
||||||
local History6RollsRandomizer = Randomizer:extend()
|
local History6Rolls35PoolRandomizer = Randomizer:extend()
|
||||||
|
|
||||||
function History6RollsRandomizer:initialize()
|
function History6Rolls35PoolRandomizer:initialize()
|
||||||
|
self.first = true
|
||||||
self.history = {"Z", "S", "Z", "S"}
|
self.history = {"Z", "S", "Z", "S"}
|
||||||
self.bag_counts = {
|
self.pool = {
|
||||||
I = 5, J = 5, L = 5, O = 5, S = 3, T = 5, Z = 3
|
"I", "I", "I", "I", "I",
|
||||||
|
"T", "T", "T", "T", "T",
|
||||||
|
"L", "L", "L", "L", "L",
|
||||||
|
"J", "J", "J", "J", "J",
|
||||||
|
"S", "S", "S", "S", "S",
|
||||||
|
"Z", "Z", "Z", "Z", "Z",
|
||||||
|
"O", "O", "O", "O", "O",
|
||||||
|
}
|
||||||
|
self.droughts = {
|
||||||
|
I = 0,
|
||||||
|
T = 0,
|
||||||
|
L = 0,
|
||||||
|
J = 0,
|
||||||
|
S = 0,
|
||||||
|
Z = 0,
|
||||||
|
O = 0,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function History6RollsRandomizer:getBagPiece(n)
|
function History6Rolls35PoolRandomizer:generatePiece()
|
||||||
for shape, count in pairs(self.bag_counts) do
|
local index, x
|
||||||
n = n - count
|
if self.first then
|
||||||
if n <= 0 then
|
local prevent = {"S", "Z", "O"}
|
||||||
return shape
|
repeat
|
||||||
end
|
index = math.random(#self.pool)
|
||||||
end
|
x = self.pool[index]
|
||||||
end
|
until not inHistory(x, prevent)
|
||||||
|
self.first = false
|
||||||
function History6RollsRandomizer:generatePiece()
|
else
|
||||||
for i = 1, 6 do
|
for i = 1, 6 do
|
||||||
local x = self:getBagPiece(math.random(31))
|
index = math.random(#self.pool)
|
||||||
|
x = self.pool[index]
|
||||||
if not inHistory(x, self.history) or i == 6 then
|
if not inHistory(x, self.history) or i == 6 then
|
||||||
return self:updateHistory(x)
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.pool[index] = self:updateHistory(x)
|
||||||
|
return x
|
||||||
|
end
|
||||||
|
|
||||||
function History6RollsRandomizer:updateHistory(shape)
|
function History6Rolls35PoolRandomizer:updateHistory(shape)
|
||||||
self.bag_counts[shape] = self.bag_counts[shape] - 1
|
table.remove(self.history, 1)
|
||||||
local replaced_piece = table.remove(self.history, 1)
|
|
||||||
table.insert(self.history, shape)
|
table.insert(self.history, shape)
|
||||||
self.bag_counts[replaced_piece] = self.bag_counts[replaced_piece] + 1
|
|
||||||
return shape
|
local highdrought
|
||||||
|
local highdroughtcount = 0
|
||||||
|
for k, v in pairs(self.droughts) do
|
||||||
|
if k == shape then
|
||||||
|
self.droughts[k] = 0
|
||||||
|
else
|
||||||
|
self.droughts[k] = v + 1
|
||||||
|
if v >= highdroughtcount then
|
||||||
|
highdrought = k
|
||||||
|
highdroughtcount = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return highdrought
|
||||||
end
|
end
|
||||||
|
|
||||||
function inHistory(piece, history)
|
function inHistory(piece, history)
|
||||||
@@ -44,4 +76,4 @@ function inHistory(piece, history)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return History6RollsRandomizer
|
return History6Rolls35PoolRandomizer
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ ARS.spawn_positions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ARS.big_spawn_positions = {
|
ARS.big_spawn_positions = {
|
||||||
I = { x=2, y=2 },
|
I = { x=3, y=2 },
|
||||||
J = { x=2, y=3 },
|
J = { x=2, y=3 },
|
||||||
L = { x=2, y=3 },
|
L = { x=2, y=3 },
|
||||||
O = { x=2, y=3 },
|
O = { x=3, y=3 },
|
||||||
S = { x=2, y=3 },
|
S = { x=2, y=3 },
|
||||||
T = { x=2, y=3 },
|
T = { x=2, y=3 },
|
||||||
Z = { x=2, y=3 },
|
Z = { x=2, y=3 },
|
||||||
@@ -110,7 +110,14 @@ function ARS:onPieceDrop(piece, grid)
|
|||||||
piece.lock_delay = 0 -- step reset
|
piece.lock_delay = 0 -- step reset
|
||||||
end
|
end
|
||||||
|
|
||||||
function ARS:get180RotationValue() return config["reverse_rotate"] and 1 or 3 end
|
function ARS:get180RotationValue()
|
||||||
|
if config.gamesettings.world_reverse == 3 then
|
||||||
|
return 3
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
||||||
|
|
||||||
return ARS
|
return ARS
|
||||||
|
|||||||
@@ -6,6 +6,19 @@ local ARS = Ruleset:extend()
|
|||||||
ARS.name = "ACE-ARS"
|
ARS.name = "ACE-ARS"
|
||||||
ARS.hash = "ArikaACE"
|
ARS.hash = "ArikaACE"
|
||||||
|
|
||||||
|
ARS.colourscheme = {
|
||||||
|
I = "C",
|
||||||
|
L = "O",
|
||||||
|
J = "B",
|
||||||
|
S = "G",
|
||||||
|
Z = "R",
|
||||||
|
O = "Y",
|
||||||
|
T = "M",
|
||||||
|
}
|
||||||
|
|
||||||
|
ARS.softdrop_lock = false
|
||||||
|
ARS.harddrop_lock = true
|
||||||
|
|
||||||
ARS.spawn_positions = {
|
ARS.spawn_positions = {
|
||||||
I = { x=5, y=2 },
|
I = { x=5, y=2 },
|
||||||
J = { x=4, y=3 },
|
J = { x=4, y=3 },
|
||||||
@@ -17,10 +30,10 @@ ARS.spawn_positions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ARS.big_spawn_positions = {
|
ARS.big_spawn_positions = {
|
||||||
I = { x=2, y=0 },
|
I = { x=3, y=0 },
|
||||||
J = { x=2, y=1 },
|
J = { x=2, y=1 },
|
||||||
L = { x=2, y=1 },
|
L = { x=2, y=1 },
|
||||||
O = { x=2, y=1 },
|
O = { x=3, y=1 },
|
||||||
S = { x=2, y=1 },
|
S = { x=2, y=1 },
|
||||||
T = { x=2, y=1 },
|
T = { x=2, y=1 },
|
||||||
Z = { x=2, y=1 },
|
Z = { x=2, y=1 },
|
||||||
@@ -131,7 +144,7 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
|||||||
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
|
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
||||||
elseif piece.shape == "T"
|
elseif piece.shape == "T"
|
||||||
and new_piece.rotation == 1
|
and new_piece.rotation == 0
|
||||||
and piece.floorkick == 0
|
and piece.floorkick == 0
|
||||||
and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1}))
|
and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1}))
|
||||||
then
|
then
|
||||||
@@ -172,7 +185,14 @@ function ARS:onPieceRotate(piece, grid)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ARS:get180RotationValue() return config["reverse_rotate"] and 1 or 3 end
|
function ARS:get180RotationValue()
|
||||||
|
if config.gamesettings.world_reverse == 3 then
|
||||||
|
return 3
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
||||||
|
|
||||||
return ARS
|
return ARS
|
||||||
|
|||||||
185
tetris/rulesets/arika_ace2.lua
Normal file
185
tetris/rulesets/arika_ace2.lua
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
local Piece = require 'tetris.components.piece'
|
||||||
|
local Ruleset = require 'tetris.rulesets.ruleset'
|
||||||
|
|
||||||
|
local ARS = Ruleset:extend()
|
||||||
|
|
||||||
|
ARS.name = "ACE-ARS2"
|
||||||
|
ARS.hash = "ArikaACE2"
|
||||||
|
|
||||||
|
ARS.spawn_positions = {
|
||||||
|
I = { x=5, y=2 },
|
||||||
|
J = { x=4, y=3 },
|
||||||
|
L = { x=4, y=3 },
|
||||||
|
O = { x=5, y=3 },
|
||||||
|
S = { x=4, y=3 },
|
||||||
|
T = { x=4, y=3 },
|
||||||
|
Z = { x=4, y=3 },
|
||||||
|
}
|
||||||
|
|
||||||
|
ARS.big_spawn_positions = {
|
||||||
|
I = { x=3, y=0 },
|
||||||
|
J = { x=2, y=1 },
|
||||||
|
L = { x=2, y=1 },
|
||||||
|
O = { x=3, y=1 },
|
||||||
|
S = { x=2, y=1 },
|
||||||
|
T = { x=2, y=1 },
|
||||||
|
Z = { x=2, y=1 },
|
||||||
|
}
|
||||||
|
|
||||||
|
ARS.block_offsets = {
|
||||||
|
I={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
||||||
|
},
|
||||||
|
J={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
|
||||||
|
{ {x=0, y=-1}, {x=1, y=-2}, {x=0, y=-2}, {x=0, y=0} },
|
||||||
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=1, y=0} },
|
||||||
|
{ {x=0, y=-1}, {x=0, y=-2}, {x=0, y=0}, {x=-1, y=0} },
|
||||||
|
},
|
||||||
|
L={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
|
||||||
|
{ {x=0, y=-2}, {x=0, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
||||||
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=-1, y=0} },
|
||||||
|
{ {x=0, y=-1}, {x=-1, y=-2}, {x=0, y=-2}, {x=0, y=0} },
|
||||||
|
},
|
||||||
|
O={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
},
|
||||||
|
S={
|
||||||
|
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
||||||
|
{ {x=-1, y=-2}, {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0} },
|
||||||
|
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
||||||
|
{ {x=-1, y=-2}, {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0} },
|
||||||
|
},
|
||||||
|
T={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=-1}, {x=0, y=-2} },
|
||||||
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=-1}, {x=0, y=0} },
|
||||||
|
{ {x=0, y=-1}, {x=0, y=0}, {x=-1, y=-1}, {x=0, y=-2} },
|
||||||
|
},
|
||||||
|
Z={
|
||||||
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
||||||
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=-2}, {x=1, y=-1} },
|
||||||
|
{ {x=0, y=-1}, {x=-1, y=-1}, {x=1, y=0}, {x=0, y=0} },
|
||||||
|
{ {x=0, y=-1}, {x=0, y=0}, {x=1, y=-2}, {x=1, y=-1} },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- Component functions.
|
||||||
|
|
||||||
|
function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
|
|
||||||
|
-- O doesn't kick
|
||||||
|
if (piece.shape == "O") then return end
|
||||||
|
|
||||||
|
-- center column rule
|
||||||
|
if (
|
||||||
|
piece.shape == "J" or piece.shape == "T" or piece.shape == "L"
|
||||||
|
) and (
|
||||||
|
piece.rotation == 0 or piece.rotation == 2
|
||||||
|
) then
|
||||||
|
local offsets = new_piece:getBlockOffsets()
|
||||||
|
table.sort(offsets, function(A, B) return A.y < B.y or A.y == B.y and A.x < B.y end)
|
||||||
|
for index, offset in pairs(offsets) do
|
||||||
|
if grid:isOccupied(piece.position.x + offset.x, piece.position.y + offset.y) then
|
||||||
|
if offset.x == 0 then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if piece.shape == "I" then
|
||||||
|
-- special kick rules for I
|
||||||
|
if new_piece.rotation == 0 or new_piece.rotation == 2 then
|
||||||
|
-- kick right, right2, left
|
||||||
|
if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
elseif grid:canPlacePiece(new_piece:withOffset({x=2, y=0})) then
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=2, y=0})
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
end
|
||||||
|
elseif piece:isDropBlocked(grid) and (new_piece.rotation == 1 or new_piece.rotation == 3) and piece.floorkick == 0 then
|
||||||
|
-- kick up, up2
|
||||||
|
if grid:canPlacePiece(new_piece:withOffset({x=0, y=-1})) then
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1})
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
piece.floorkick = 1
|
||||||
|
elseif grid:canPlacePiece(new_piece:withOffset({x=0, y=-2})) then
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-2})
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
piece.floorkick = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- kick right, kick left
|
||||||
|
if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
|
||||||
|
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
||||||
|
elseif piece.shape == "T"
|
||||||
|
and new_piece.rotation == 0
|
||||||
|
and piece.floorkick == 0
|
||||||
|
and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1}))
|
||||||
|
then
|
||||||
|
-- T floorkick
|
||||||
|
piece.floorkick = piece.floorkick + 1
|
||||||
|
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:onPieceCreate(piece, grid)
|
||||||
|
piece.floorkick = 0
|
||||||
|
piece.manipulations = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:onPieceDrop(piece, grid)
|
||||||
|
piece.lock_delay = 0 -- step reset
|
||||||
|
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 >= 127 then
|
||||||
|
piece.locked = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:onPieceRotate(piece, grid)
|
||||||
|
piece.lock_delay = 0 -- rotate reset
|
||||||
|
if piece:isDropBlocked(grid) then
|
||||||
|
piece.manipulations = piece.manipulations + 1
|
||||||
|
if piece.manipulations >= 127 then
|
||||||
|
piece.locked = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:get180RotationValue()
|
||||||
|
if config.gamesettings.world_reverse == 3 then
|
||||||
|
return 3
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
||||||
|
|
||||||
|
return ARS
|
||||||
@@ -5,8 +5,18 @@ local SRS = Ruleset:extend()
|
|||||||
|
|
||||||
SRS.name = "ACE-SRS"
|
SRS.name = "ACE-SRS"
|
||||||
SRS.hash = "ACE Standard"
|
SRS.hash = "ACE Standard"
|
||||||
|
SRS.world = true
|
||||||
SRS.enable_IRS_wallkicks = true
|
SRS.colourscheme = {
|
||||||
|
I = "C",
|
||||||
|
L = "O",
|
||||||
|
J = "B",
|
||||||
|
S = "G",
|
||||||
|
Z = "R",
|
||||||
|
O = "Y",
|
||||||
|
T = "M",
|
||||||
|
}
|
||||||
|
SRS.softdrop_lock = false
|
||||||
|
SRS.harddrop_lock = true
|
||||||
|
|
||||||
SRS.spawn_positions = {
|
SRS.spawn_positions = {
|
||||||
I = { x=5, y=2 },
|
I = { x=5, y=2 },
|
||||||
@@ -19,10 +29,10 @@ SRS.spawn_positions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SRS.big_spawn_positions = {
|
SRS.big_spawn_positions = {
|
||||||
I = { x=2, y=0 },
|
I = { x=3, y=0 },
|
||||||
J = { x=2, y=1 },
|
J = { x=2, y=1 },
|
||||||
L = { x=2, y=1 },
|
L = { x=2, y=1 },
|
||||||
O = { x=2, y=1 },
|
O = { x=3, y=1 },
|
||||||
S = { x=2, y=1 },
|
S = { x=2, y=1 },
|
||||||
T = { x=2, y=1 },
|
T = { x=2, y=1 },
|
||||||
Z = { x=2, y=1 },
|
Z = { x=2, y=1 },
|
||||||
@@ -98,24 +108,24 @@ SRS.wallkicks_3x3 = {
|
|||||||
|
|
||||||
SRS.wallkicks_line = {
|
SRS.wallkicks_line = {
|
||||||
[0]={
|
[0]={
|
||||||
[1]={{x=-2, y=0}, {x=1, y=0}, {x=-2, y=1}, {x=1, y=-2}},
|
[1]={{x=-2, y= 0}, {x= 1, y= 0}, {x= 1, y=-2}, {x=-2, y= 1}},
|
||||||
[2]={},
|
[2]={},
|
||||||
[3]={{x=-1, y=0}, {x=2, y=0}, {x=-1, y=-2}, {x=2, y=1}},
|
[3]={{x= 2, y= 0}, {x=-1, y= 0}, {x=-1, y=-2}, {x= 2, y= 1}},
|
||||||
},
|
},
|
||||||
[1]={
|
[1]={
|
||||||
[0]={{x= 2, y= 0}, {x=-1, y= 0}, {x= 2, y=-1}, {x=-1, y= 2}},
|
[0]={{x= 2, y= 0}, {x=-1, y= 0}, {x= 2, y=-1}, {x=-1, y= 2}},
|
||||||
[2]={{x=-1, y= 0}, {x= 2, y= 0}, {x=-1, y=-2}, {x= 2, y= 1}},
|
[2]={{x=-1, y= 0}, {x= 2, y= 0}, {x=-1, y=-2}, {x= 2, y= 1}},
|
||||||
[3]={{x=0, y=1}, {x=0, y=-1}, {x=0, y=2}, {x=0, y=-2}},
|
[3]={},
|
||||||
},
|
},
|
||||||
[2]={
|
[2]={
|
||||||
[0]={},
|
[0]={},
|
||||||
[1]={{x=1, y=0}, {x=-2, y=0}, {x=1, y=2}, {x=-2, y=-1}},
|
[1]={{x=-2, y= 0}, {x= 1, y= 0}, {x=-2, y=-1}, {x= 1, y= 1}},
|
||||||
[3]={{x=2, y=0}, {x=-1, y=0}, {x=2, y=-1}, {x=-1, y=2}},
|
[3]={{x= 2, y= 0}, {x=-1, y= 0}, {x= 2, y=-1}, {x=-1, y= 1}},
|
||||||
},
|
},
|
||||||
[3]={
|
[3]={
|
||||||
[0]={{x=1, y=0}, {x=-2, y=0}, {x=1, y=2}, {x=-2, y=-1}},
|
[0]={{x=-2, y= 0}, {x= 1, y= 0}, {x=-2, y=-1}, {x= 1, y= 2}},
|
||||||
[1]={{x=0, y=1}, {x=0, y=-1}, {x=0, y=2}, {x=0, y=-2}},
|
[1]={},
|
||||||
[2]={{x=-2, y=0}, {x=1, y=0}, {x=-2, y=1}, {x=1, y=-2}},
|
[2]={{x= 1, y= 0}, {x=-2, y= 0}, {x= 1, y=-2}, {x=-2, y= 1}},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,4 +184,12 @@ function SRS:onPieceRotate(piece, grid)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function SRS:get180RotationValue()
|
||||||
|
if config.gamesettings.world_reverse == 1 then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return SRS
|
return SRS
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ ARS.spawn_positions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ARS.big_spawn_positions = {
|
ARS.big_spawn_positions = {
|
||||||
I = { x=2, y=2 },
|
I = { x=3, y=2 },
|
||||||
J = { x=2, y=3 },
|
J = { x=2, y=3 },
|
||||||
L = { x=2, y=3 },
|
L = { x=2, y=3 },
|
||||||
O = { x=2, y=3 },
|
O = { x=3, y=3 },
|
||||||
S = { x=2, y=3 },
|
S = { x=2, y=3 },
|
||||||
T = { x=2, y=3 },
|
T = { x=2, y=3 },
|
||||||
Z = { x=2, y=3 },
|
Z = { x=2, y=3 },
|
||||||
@@ -131,7 +131,7 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
|||||||
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
|
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
||||||
elseif piece.shape == "T"
|
elseif piece.shape == "T"
|
||||||
and new_piece.rotation == 1
|
and new_piece.rotation == 0
|
||||||
and piece.floorkick == 0
|
and piece.floorkick == 0
|
||||||
and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1}))
|
and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1}))
|
||||||
then
|
then
|
||||||
@@ -151,7 +151,14 @@ function ARS:onPieceDrop(piece, grid)
|
|||||||
piece.lock_delay = 0 -- step reset
|
piece.lock_delay = 0 -- step reset
|
||||||
end
|
end
|
||||||
|
|
||||||
function ARS:get180RotationValue() return config["reverse_rotate"] and 1 or 3 end
|
function ARS:get180RotationValue()
|
||||||
|
if config.gamesettings.world_reverse == 3 then
|
||||||
|
return 3
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
||||||
|
|
||||||
return ARS
|
return ARS
|
||||||
|
|||||||
@@ -5,25 +5,26 @@ local CRS = Ruleset:extend()
|
|||||||
|
|
||||||
CRS.name = "Cambridge"
|
CRS.name = "Cambridge"
|
||||||
CRS.hash = "Cambridge"
|
CRS.hash = "Cambridge"
|
||||||
|
CRS.world = true
|
||||||
|
|
||||||
CRS.spawn_positions = {
|
CRS.spawn_positions = {
|
||||||
I = { x=5, y=4 },
|
I = { x=5, y=4 },
|
||||||
J = { x=4, y=5 },
|
J = { x=4, y=5 },
|
||||||
L = { x=4, y=5 },
|
L = { x=4, y=5 },
|
||||||
O = { x=5, y=5 },
|
O = { x=5, y=5 },
|
||||||
S = { x=4, y=4 },
|
S = { x=4, y=5 },
|
||||||
T = { x=4, y=5 },
|
T = { x=4, y=5 },
|
||||||
Z = { x=4, y=4 },
|
Z = { x=4, y=5 },
|
||||||
}
|
}
|
||||||
|
|
||||||
CRS.big_spawn_positions = {
|
CRS.big_spawn_positions = {
|
||||||
I = { x=2, y=2 },
|
I = { x=3, y=2 },
|
||||||
J = { x=2, y=3 },
|
J = { x=2, y=3 },
|
||||||
L = { x=2, y=3 },
|
L = { x=2, y=3 },
|
||||||
O = { x=2, y=3 },
|
O = { x=3, y=3 },
|
||||||
S = { x=2, y=2 },
|
S = { x=2, y=3 },
|
||||||
T = { x=2, y=3 },
|
T = { x=2, y=3 },
|
||||||
Z = { x=2, y=2 },
|
Z = { x=2, y=3 },
|
||||||
}
|
}
|
||||||
|
|
||||||
CRS.block_offsets = {
|
CRS.block_offsets = {
|
||||||
@@ -52,10 +53,10 @@ CRS.block_offsets = {
|
|||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
},
|
},
|
||||||
S={
|
S={
|
||||||
{ {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} },
|
{ {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1}, {x=1, y=-1} },
|
||||||
{ {x=0, y=1}, {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1} },
|
{ {x=0, y=0}, {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2} },
|
||||||
{ {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} },
|
{ {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1}, {x=1, y=-1} },
|
||||||
{ {x=0, y=1}, {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1} },
|
{ {x=0, y=0}, {x=0, y=-1}, {x=-1, y=-1}, {x=-1, y=-2} },
|
||||||
},
|
},
|
||||||
T={
|
T={
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
||||||
@@ -64,10 +65,10 @@ CRS.block_offsets = {
|
|||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} },
|
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} },
|
||||||
},
|
},
|
||||||
Z={
|
Z={
|
||||||
{ {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} },
|
{ {x=1, y=0}, {x=0, y=0}, {x=0, y=-1}, {x=-1, y=-1} },
|
||||||
{ {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
{ {x=1, y=-2}, {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0} },
|
||||||
{ {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} },
|
{ {x=1, y=0}, {x=0, y=0}, {x=0, y=-1}, {x=-1, y=-1} },
|
||||||
{ {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
{ {x=1, y=-2}, {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0} },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +364,10 @@ function CRS:attemptRotate(new_inputs, piece, grid, initial)
|
|||||||
|
|
||||||
if rot_dir == 0 then return end
|
if rot_dir == 0 then return end
|
||||||
|
|
||||||
|
if self.world and config.gamesettings.world_reverse == 2 then
|
||||||
|
rot_dir = 4 - rot_dir
|
||||||
|
end
|
||||||
|
|
||||||
local new_piece = piece:withRelativeRotation(rot_dir)
|
local new_piece = piece:withRelativeRotation(rot_dir)
|
||||||
self:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
self:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,10 +6,78 @@ local Ruleset = Object:extend()
|
|||||||
Ruleset.name = ""
|
Ruleset.name = ""
|
||||||
Ruleset.hash = ""
|
Ruleset.hash = ""
|
||||||
|
|
||||||
|
-- Arika-type ruleset defaults
|
||||||
|
Ruleset.world = false
|
||||||
|
Ruleset.colourscheme = {
|
||||||
|
I = "R",
|
||||||
|
L = "O",
|
||||||
|
J = "B",
|
||||||
|
S = "M",
|
||||||
|
Z = "G",
|
||||||
|
O = "Y",
|
||||||
|
T = "C",
|
||||||
|
}
|
||||||
|
Ruleset.softdrop_lock = true
|
||||||
|
Ruleset.harddrop_lock = false
|
||||||
|
|
||||||
Ruleset.enable_IRS_wallkicks = false
|
Ruleset.enable_IRS_wallkicks = false
|
||||||
|
|
||||||
-- Component functions.
|
-- Component functions.
|
||||||
|
|
||||||
|
function Ruleset:new()
|
||||||
|
if config.gamesettings.piece_colour == 1 then
|
||||||
|
blocks["bone"] = (not self.world) and
|
||||||
|
{
|
||||||
|
R = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
O = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
Y = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
G = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
C = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
B = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
M = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
F = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
A = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
X = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
} or {
|
||||||
|
R = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
O = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
Y = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
G = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
C = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
B = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
M = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
F = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
A = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
X = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
}
|
||||||
|
else
|
||||||
|
blocks["bone"] = (config.gamesettings.piece_colour == 2) and
|
||||||
|
{
|
||||||
|
R = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
O = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
Y = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
G = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
C = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
B = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
M = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
F = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
A = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
X = love.graphics.newImage("res/img/bone.png"),
|
||||||
|
} or {
|
||||||
|
R = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
O = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
Y = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
G = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
C = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
B = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
M = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
F = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
A = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
X = love.graphics.newImage("res/img/bonew.png"),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Ruleset:rotatePiece(inputs, piece, grid, prev_inputs, initial)
|
function Ruleset:rotatePiece(inputs, piece, grid, prev_inputs, initial)
|
||||||
local new_inputs = {}
|
local new_inputs = {}
|
||||||
|
|
||||||
@@ -39,6 +107,9 @@ function Ruleset:attemptRotate(new_inputs, piece, grid, initial)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if rot_dir == 0 then return end
|
if rot_dir == 0 then return end
|
||||||
|
if config.gamesettings.world_reverse == 3 or (self.world and config.gamesettings.world_reverse == 2) then
|
||||||
|
rot_dir = 4 - rot_dir
|
||||||
|
end
|
||||||
|
|
||||||
local new_piece = piece:withRelativeRotation(rot_dir)
|
local new_piece = piece:withRelativeRotation(rot_dir)
|
||||||
|
|
||||||
@@ -117,10 +188,12 @@ function Ruleset:initializePiece(
|
|||||||
else
|
else
|
||||||
spawn_positions = self.spawn_positions
|
spawn_positions = self.spawn_positions
|
||||||
end
|
end
|
||||||
|
local colours = ({self.colourscheme, ColourSchemes.Arika, ColourSchemes.TTC})[config.gamesettings.piece_colour]
|
||||||
|
|
||||||
local piece = Piece(data.shape, data.orientation - 1, {
|
local piece = Piece(data.shape, data.orientation - 1, {
|
||||||
x = spawn_positions[data.shape].x,
|
x = spawn_positions[data.shape].x,
|
||||||
y = spawn_positions[data.shape].y
|
y = spawn_positions[data.shape].y
|
||||||
}, self.block_offsets, 0, 0, data.skin, big)
|
}, self.block_offsets, 0, 0, data.skin, colours[data.shape], big)
|
||||||
|
|
||||||
self:onPieceCreate(piece)
|
self:onPieceCreate(piece)
|
||||||
self:rotatePiece(inputs, piece, grid, {}, true)
|
self:rotatePiece(inputs, piece, grid, {}, true)
|
||||||
|
|||||||
@@ -5,6 +5,18 @@ local SRS = Ruleset:extend()
|
|||||||
|
|
||||||
SRS.name = "Guideline SRS"
|
SRS.name = "Guideline SRS"
|
||||||
SRS.hash = "Standard"
|
SRS.hash = "Standard"
|
||||||
|
SRS.world = true
|
||||||
|
SRS.colourscheme = {
|
||||||
|
I = "C",
|
||||||
|
L = "O",
|
||||||
|
J = "B",
|
||||||
|
S = "G",
|
||||||
|
Z = "R",
|
||||||
|
O = "Y",
|
||||||
|
T = "M",
|
||||||
|
}
|
||||||
|
SRS.softdrop_lock = false
|
||||||
|
SRS.harddrop_lock = true
|
||||||
|
|
||||||
SRS.enable_IRS_wallkicks = true
|
SRS.enable_IRS_wallkicks = true
|
||||||
|
|
||||||
@@ -19,10 +31,10 @@ SRS.spawn_positions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SRS.big_spawn_positions = {
|
SRS.big_spawn_positions = {
|
||||||
I = { x=2, y=0 },
|
I = { x=3, y=0 },
|
||||||
J = { x=2, y=1 },
|
J = { x=2, y=1 },
|
||||||
L = { x=2, y=1 },
|
L = { x=2, y=1 },
|
||||||
O = { x=2, y=1 },
|
O = { x=3, y=1 },
|
||||||
S = { x=2, y=1 },
|
S = { x=2, y=1 },
|
||||||
T = { x=2, y=1 },
|
T = { x=2, y=1 },
|
||||||
Z = { x=2, y=1 },
|
Z = { x=2, y=1 },
|
||||||
@@ -119,6 +131,16 @@ SRS.wallkicks_line = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function SRS:check_new_low(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.lowest_y = y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Component functions.
|
-- Component functions.
|
||||||
|
|
||||||
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
@@ -147,19 +169,24 @@ function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SRS:onPieceCreate(piece, grid)
|
function SRS:onPieceCreate(piece, grid)
|
||||||
piece.rotate_counter = 0
|
piece.manipulations = 0
|
||||||
piece.move_counter = 0
|
piece.lowest_y = -math.huge
|
||||||
end
|
end
|
||||||
|
|
||||||
function SRS:onPieceDrop(piece, grid)
|
function SRS:onPieceDrop(piece, grid)
|
||||||
|
self:check_new_low(piece)
|
||||||
|
if piece.manipulations >= 15 and piece:isDropBlocked(grid) then
|
||||||
|
piece.locked = true
|
||||||
|
else
|
||||||
piece.lock_delay = 0 -- step reset
|
piece.lock_delay = 0 -- step reset
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function SRS:onPieceMove(piece, grid)
|
function SRS:onPieceMove(piece, grid)
|
||||||
piece.lock_delay = 0 -- move reset
|
piece.lock_delay = 0 -- move reset
|
||||||
if piece:isDropBlocked(grid) then
|
if piece:isDropBlocked(grid) then
|
||||||
piece.move_counter = piece.move_counter + 1
|
piece.manipulations = piece.manipulations + 1
|
||||||
if piece.move_counter >= 24 then
|
if piece.manipulations >= 15 then
|
||||||
piece.locked = true
|
piece.locked = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -167,9 +194,10 @@ end
|
|||||||
|
|
||||||
function SRS:onPieceRotate(piece, grid)
|
function SRS:onPieceRotate(piece, grid)
|
||||||
piece.lock_delay = 0 -- rotate reset
|
piece.lock_delay = 0 -- rotate reset
|
||||||
|
self:check_new_low(piece)
|
||||||
|
piece.manipulations = piece.manipulations + 1
|
||||||
if piece:isDropBlocked(grid) then
|
if piece:isDropBlocked(grid) then
|
||||||
piece.rotate_counter = piece.rotate_counter + 1
|
if piece.manipulations >= 15 then
|
||||||
if piece.rotate_counter >= 12 then
|
|
||||||
piece.locked = true
|
piece.locked = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
196
tetris/rulesets/ti_srs.lua
Normal file
196
tetris/rulesets/ti_srs.lua
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
local Piece = require 'tetris.components.piece'
|
||||||
|
local Ruleset = require 'tetris.rulesets.ruleset'
|
||||||
|
|
||||||
|
local SRS = Ruleset:extend()
|
||||||
|
|
||||||
|
SRS.name = "Ti-World"
|
||||||
|
SRS.hash = "Bad I-kicks"
|
||||||
|
SRS.world = true
|
||||||
|
SRS.colourscheme = {
|
||||||
|
I = "C",
|
||||||
|
L = "O",
|
||||||
|
J = "B",
|
||||||
|
S = "G",
|
||||||
|
Z = "R",
|
||||||
|
O = "Y",
|
||||||
|
T = "M",
|
||||||
|
}
|
||||||
|
SRS.softdrop_lock = false
|
||||||
|
SRS.harddrop_lock = true
|
||||||
|
|
||||||
|
SRS.spawn_positions = {
|
||||||
|
I = { x=5, y=4 },
|
||||||
|
J = { x=4, y=5 },
|
||||||
|
L = { x=4, y=5 },
|
||||||
|
O = { x=5, y=5 },
|
||||||
|
S = { x=4, y=5 },
|
||||||
|
T = { x=4, y=5 },
|
||||||
|
Z = { x=4, y=5 },
|
||||||
|
}
|
||||||
|
|
||||||
|
SRS.big_spawn_positions = {
|
||||||
|
I = { x=3, y=2 },
|
||||||
|
J = { x=2, y=3 },
|
||||||
|
L = { x=2, y=3 },
|
||||||
|
O = { x=3, y=3 },
|
||||||
|
S = { x=2, y=3 },
|
||||||
|
T = { x=2, y=3 },
|
||||||
|
Z = { x=2, y=3 },
|
||||||
|
}
|
||||||
|
|
||||||
|
SRS.block_offsets = {
|
||||||
|
I={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
||||||
|
{ {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1} },
|
||||||
|
{ {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2} },
|
||||||
|
},
|
||||||
|
J={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1} , {x=1, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=1} },
|
||||||
|
},
|
||||||
|
L={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=1} },
|
||||||
|
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=-1, y=1} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=-1} },
|
||||||
|
},
|
||||||
|
O={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
||||||
|
},
|
||||||
|
S={
|
||||||
|
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
||||||
|
{ {x=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
||||||
|
{ {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} },
|
||||||
|
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
||||||
|
},
|
||||||
|
T={
|
||||||
|
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0} },
|
||||||
|
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1} },
|
||||||
|
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} },
|
||||||
|
},
|
||||||
|
Z={
|
||||||
|
{ {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} },
|
||||||
|
{ {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
||||||
|
{ {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} },
|
||||||
|
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SRS.wallkicks_3x3 = {
|
||||||
|
[0]={
|
||||||
|
[1]={{x=-1, y=0}, {x=-1, y=-1}, {x=0, y=2}, {x=-1, y=2}},
|
||||||
|
[2]={{x=0, y=1}, {x=0, y=-1}},
|
||||||
|
[3]={{x=1, y=0}, {x=1, y=-1}, {x=0, y=2}, {x=1, y=2}},
|
||||||
|
},
|
||||||
|
[1]={
|
||||||
|
[0]={{x=1, y=0}, {x=1, y=1}, {x=0, y=-2}, {x=1, y=-2}},
|
||||||
|
[2]={{x=1, y=0}, {x=1, y=1}, {x=0, y=-2}, {x=1, y=-2}},
|
||||||
|
[3]={{x=0, y=1}, {x=0, y=-1}},
|
||||||
|
},
|
||||||
|
[2]={
|
||||||
|
[0]={{x=0, y=1}, {x=0, y=-1}},
|
||||||
|
[1]={{x=-1, y=0}, {x=-1, y=-1}, {x=0, y=2}, {x=-1, y=2}},
|
||||||
|
[3]={{x=1, y=0}, {x=1, y=-1}, {x=0, y=2}, {x=1, y=2}},
|
||||||
|
},
|
||||||
|
[3]={
|
||||||
|
[0]={{x=-1, y=0}, {x=-1, y=1}, {x=0, y=-2}, {x=-1, y=-2}},
|
||||||
|
[1]={{x=0, y=1}, {x=0, y=-1}},
|
||||||
|
[2]={{x=-1, y=0}, {x=-1, y=1}, {x=0, y=-2}, {x=-1, y=-2}},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
SRS.wallkicks_line = {
|
||||||
|
[0]={
|
||||||
|
[1]={{x=-2, y= 0}, {x= 1, y= 0}, {x= 1, y=-2}, {x=-2, y= 1}},
|
||||||
|
[2]={},
|
||||||
|
[3]={{x= 2, y= 0}, {x=-1, y= 0}, {x=-1, y=-2}, {x= 2, y= 1}},
|
||||||
|
},
|
||||||
|
[1]={
|
||||||
|
[0]={{x= 2, y= 0}, {x=-1, y= 0}, {x= 2, y=-1}, {x=-1, y= 2}},
|
||||||
|
[2]={{x=-1, y= 0}, {x= 2, y= 0}, {x=-1, y=-2}, {x= 2, y= 1}},
|
||||||
|
[3]={},
|
||||||
|
},
|
||||||
|
[2]={
|
||||||
|
[0]={},
|
||||||
|
[1]={{x=-2, y= 0}, {x= 1, y= 0}, {x=-2, y=-1}, {x= 1, y= 1}},
|
||||||
|
[3]={{x= 2, y= 0}, {x=-1, y= 0}, {x= 2, y=-1}, {x=-1, y= 1}},
|
||||||
|
},
|
||||||
|
[3]={
|
||||||
|
[0]={{x=-2, y= 0}, {x= 1, y= 0}, {x=-2, y=-1}, {x= 1, y= 2}},
|
||||||
|
[1]={},
|
||||||
|
[2]={{x= 1, y= 0}, {x=-2, y= 0}, {x= 1, y=-2}, {x=-2, y= 1}},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
-- Component functions.
|
||||||
|
|
||||||
|
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
|
|
||||||
|
local kicks
|
||||||
|
if piece.shape == "O" then
|
||||||
|
return
|
||||||
|
elseif piece.shape == "I" then
|
||||||
|
kicks = SRS.wallkicks_line[piece.rotation][new_piece.rotation]
|
||||||
|
else
|
||||||
|
kicks = SRS.wallkicks_3x3[piece.rotation][new_piece.rotation]
|
||||||
|
end
|
||||||
|
|
||||||
|
assert(piece.rotation ~= new_piece.rotation)
|
||||||
|
|
||||||
|
for idx, offset in pairs(kicks) do
|
||||||
|
kicked_piece = new_piece:withOffset(offset)
|
||||||
|
if grid:canPlacePiece(kicked_piece) then
|
||||||
|
piece:setRelativeRotation(rot_dir)
|
||||||
|
piece:setOffset(offset)
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function SRS:onPieceCreate(piece, grid)
|
||||||
|
piece.manipulations = 0
|
||||||
|
piece.rotations = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function SRS:onPieceDrop(piece, grid)
|
||||||
|
piece.lock_delay = 0 -- step reset
|
||||||
|
end
|
||||||
|
|
||||||
|
function SRS:onPieceMove(piece, grid)
|
||||||
|
piece.lock_delay = 0 -- move reset
|
||||||
|
if piece:isDropBlocked(grid) then
|
||||||
|
piece.manipulations = piece.manipulations + 1
|
||||||
|
if piece.manipulations >= 10 then
|
||||||
|
piece.locked = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function SRS:onPieceRotate(piece, grid)
|
||||||
|
piece.lock_delay = 0 -- rotate reset
|
||||||
|
if piece:isDropBlocked(grid) then
|
||||||
|
piece.rotations = piece.rotations + 1
|
||||||
|
if piece.rotations >= 8 then
|
||||||
|
piece.locked = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function SRS:get180RotationValue()
|
||||||
|
if config.gamesettings.world_reverse == 1 then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return SRS
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
Piece = require("tetris.components.piece")
|
|
||||||
|
|
||||||
local BONKERS = {}
|
|
||||||
|
|
||||||
BONKERS.name = "B.O.N.K.E.R.S."
|
|
||||||
BONKERS.hash = "Bonkers"
|
|
||||||
|
|
||||||
BONKERS.spawn_positions = {
|
|
||||||
I = { x=5, y=4 },
|
|
||||||
J = { x=4, y=5 },
|
|
||||||
L = { x=4, y=5 },
|
|
||||||
O = { x=5, y=5 },
|
|
||||||
S = { x=4, y=5 },
|
|
||||||
T = { x=4, y=5 },
|
|
||||||
Z = { x=4, y=5 },
|
|
||||||
}
|
|
||||||
|
|
||||||
BONKERS.block_offsets = {
|
|
||||||
I={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
|
||||||
{ {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1} },
|
|
||||||
{ {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2} },
|
|
||||||
},
|
|
||||||
J={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1} , {x=1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=1} },
|
|
||||||
},
|
|
||||||
L={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=-1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=-1} },
|
|
||||||
},
|
|
||||||
O={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
},
|
|
||||||
S={
|
|
||||||
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
|
||||||
{ {x=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
|
||||||
{ {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
|
||||||
},
|
|
||||||
T={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} },
|
|
||||||
},
|
|
||||||
Z={
|
|
||||||
{ {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
|
||||||
{ {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} },
|
|
||||||
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Component functions.
|
|
||||||
|
|
||||||
function BONKERS:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
|
||||||
|
|
||||||
if piece.shape == "O" then
|
|
||||||
break
|
|
||||||
elseif piece.shape == "I" then
|
|
||||||
horizontal_kicks = {0, 1, -1, 2, -2}
|
|
||||||
else
|
|
||||||
horizontal_kicks = {0, 1, -1}
|
|
||||||
end
|
|
||||||
|
|
||||||
for y_offset = 20, new_piece.position.y - 24, -1 do
|
|
||||||
for idx, x_offset in pairs(horizontal_kicks) do
|
|
||||||
local offset = {x=x_offset, y=y_offset}
|
|
||||||
kicked_piece = new_piece:withOffset(offset)
|
|
||||||
if grid:canPlacePiece(kicked_piece) then
|
|
||||||
piece:setRelativeRotation(rot_dir)
|
|
||||||
piece:setOffset(offset)
|
|
||||||
piece.lock_delay = 0 -- rotate reset
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function BONKERS:onPieceDrop(piece, grid)
|
|
||||||
piece.lock_delay = 0 -- step reset
|
|
||||||
end
|
|
||||||
|
|
||||||
function BONKERS:onPieceMove(piece, grid)
|
|
||||||
piece.lock_delay = 0 -- move reset
|
|
||||||
end
|
|
||||||
|
|
||||||
function BONKERS:onPieceRotate(piece, grid)
|
|
||||||
piece.lock_delay = 0 -- rotate reset
|
|
||||||
end
|
|
||||||
|
|
||||||
return BONKERS
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
Piece = require("tetris.components.piece")
|
|
||||||
require("funcs")
|
|
||||||
|
|
||||||
local SRS = {}
|
|
||||||
|
|
||||||
SRS.name = "SHIRASE"
|
|
||||||
SRS.hash = "Shirase"
|
|
||||||
|
|
||||||
SRS.spawn_positions = {
|
|
||||||
I = { x=5, y=4 },
|
|
||||||
J = { x=4, y=5 },
|
|
||||||
L = { x=4, y=5 },
|
|
||||||
O = { x=5, y=5 },
|
|
||||||
S = { x=4, y=5 },
|
|
||||||
T = { x=4, y=5 },
|
|
||||||
Z = { x=4, y=5 },
|
|
||||||
}
|
|
||||||
|
|
||||||
SRS.block_offsets = {
|
|
||||||
I={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
|
||||||
{ {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1} },
|
|
||||||
{ {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2} },
|
|
||||||
},
|
|
||||||
J={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1} , {x=1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=1} },
|
|
||||||
},
|
|
||||||
L={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=-1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=-1} },
|
|
||||||
},
|
|
||||||
O={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
},
|
|
||||||
S={
|
|
||||||
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
|
||||||
{ {x=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
|
||||||
{ {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
|
||||||
},
|
|
||||||
T={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} },
|
|
||||||
},
|
|
||||||
Z={
|
|
||||||
{ {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
|
||||||
{ {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} },
|
|
||||||
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SRS.wallkicks_3x3 = {
|
|
||||||
[0]={
|
|
||||||
[1]={{x=-1, y=0}, {x=-1, y=-1}, {x=0, y=2}, {x=-1, y=2}},
|
|
||||||
[2]={{x=0, y=1}, {x=0, y=-1}},
|
|
||||||
[3]={{x=1, y=0}, {x=1, y=-1}, {x=0, y=2}, {x=1, y=2}},
|
|
||||||
},
|
|
||||||
[1]={
|
|
||||||
[0]={{x=1, y=0}, {x=1, y=1}, {x=0, y=-2}, {x=1, y=-2}},
|
|
||||||
[2]={{x=1, y=0}, {x=1, y=1}, {x=0, y=-2}, {x=1, y=-2}},
|
|
||||||
[3]={{x=0, y=1}, {x=0, y=-1}},
|
|
||||||
},
|
|
||||||
[2]={
|
|
||||||
[0]={{x=0, y=1}, {x=0, y=-1}},
|
|
||||||
[1]={{x=-1, y=0}, {x=-1, y=-1}, {x=0, y=2}, {x=-1, y=2}},
|
|
||||||
[3]={{x=1, y=0}, {x=1, y=-1}, {x=0, y=2}, {x=1, y=2}},
|
|
||||||
},
|
|
||||||
[3]={
|
|
||||||
[0]={{x=-1, y=0}, {x=-1, y=1}, {x=0, y=-2}, {x=-1, y=-2}},
|
|
||||||
[1]={{x=0, y=1}, {x=0, y=-1}},
|
|
||||||
[2]={{x=-1, y=0}, {x=-1, y=1}, {x=0, y=-2}, {x=-1, y=-2}},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
SRS.wallkicks_line = {
|
|
||||||
[0]={
|
|
||||||
[1]={{x=-2, y=0}, {x=1, y=0}, {x=-2, y=1}, {x=1, y=-2}},
|
|
||||||
[2]={},
|
|
||||||
[3]={{x=-1, y=0}, {x=2, y=0}, {x=-1, y=-2}, {x=2, y=1}},
|
|
||||||
},
|
|
||||||
[1]={
|
|
||||||
[0]={{x=2, y=0}, {x=-1, y=0}, {x=2, y=-1}, {x=-1, y=2}},
|
|
||||||
[2]={{x=-1, y=0}, {x=2, y=0}, {x=-1, y=-2}, {x=2, y=1}},
|
|
||||||
[3]={{x=0, y=1}, {x=0, y=-1}, {x=0, y=2}, {x=0, y=-2}},
|
|
||||||
},
|
|
||||||
[2]={
|
|
||||||
[0]={},
|
|
||||||
[1]={{x=1, y=0}, {x=-2, y=0}, {x=1, y=2}, {x=-2, y=-1}},
|
|
||||||
[3]={{x=2, y=0}, {x=-1, y=0}, {x=2, y=-1}, {x=-1, y=2}},
|
|
||||||
},
|
|
||||||
[3]={
|
|
||||||
[0]={{x=1, y=0}, {x=-2, y=0}, {x=1, y=2}, {x=-2, y=-1}},
|
|
||||||
[1]={{x=0, y=1}, {x=0, y=-1}, {x=0, y=2}, {x=0, y=-2}},
|
|
||||||
[2]={{x=-2, y=0}, {x=1, y=0}, {x=-2, y=1}, {x=1, y=-2}},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local basicOffsets = {
|
|
||||||
[0] = { x = 1, y = 0 },
|
|
||||||
[1] = { x = 0, y = 1 },
|
|
||||||
[2] = { x = -1, y = 0 },
|
|
||||||
[3] = { x = 0, y = -1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Component functions.
|
|
||||||
|
|
||||||
local function rotatePiece(inputs, piece, grid, prev_inputs)
|
|
||||||
local new_inputs = {}
|
|
||||||
|
|
||||||
for input, value in pairs(inputs) do
|
|
||||||
if value and not prev_inputs[input] then
|
|
||||||
new_inputs[input] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local rot_dir = 0
|
|
||||||
if (new_inputs["rotate_left"] or new_inputs["rotate_left2"]) then
|
|
||||||
rot_dir = 3
|
|
||||||
elseif (new_inputs["rotate_right"] or new_inputs["rotate_right2"]) then
|
|
||||||
rot_dir = 1
|
|
||||||
elseif (new_inputs["rotate_180"]) then
|
|
||||||
rot_dir = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
while rot_dir ~= 0 do
|
|
||||||
rotated_piece = piece:withRelativeRotation(rot_dir)
|
|
||||||
rotation_offset = vAdd(
|
|
||||||
basicOffsets[piece.rotation],
|
|
||||||
vNeg(basicOffsets[rotated_piece.rotation])
|
|
||||||
)
|
|
||||||
new_piece = rotated_piece:withOffset(rotation_offset)
|
|
||||||
|
|
||||||
if (grid:canPlacePiece(new_piece)) then
|
|
||||||
piece:setRelativeRotation(rot_dir)
|
|
||||||
piece:setOffset(rotation_offset)
|
|
||||||
piece.lock_delay = 0 -- rotate reset
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
if piece.shape == "I" then
|
|
||||||
kicks = SRS.wallkicks_line[piece.rotation][new_piece.rotation]
|
|
||||||
else
|
|
||||||
kicks = SRS.wallkicks_3x3[piece.rotation][new_piece.rotation]
|
|
||||||
end
|
|
||||||
|
|
||||||
for idx, offset in pairs(kicks) do
|
|
||||||
kicked_piece = new_piece:withOffset(offset)
|
|
||||||
if grid:canPlacePiece(kicked_piece) then
|
|
||||||
piece:setRelativeRotation(rot_dir)
|
|
||||||
piece:setOffset(vAdd(offset, rotation_offset))
|
|
||||||
piece.lock_delay = 0 -- rotate reset
|
|
||||||
rot_dir = 0
|
|
||||||
end
|
|
||||||
if rot_dir == 0 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
rot_dir = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
-- prev_inputs becomes the previous inputs
|
|
||||||
for input, value in pairs(inputs) do
|
|
||||||
prev_inputs[input] = inputs[input]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function movePiece(piece, grid, move)
|
|
||||||
if move == "left" then
|
|
||||||
if not piece:isMoveBlocked(grid, {x=-1, y=0}) then
|
|
||||||
piece.lock_delay = 0 -- move reset
|
|
||||||
end
|
|
||||||
piece:moveInGrid({x=-1, y=0}, 1, grid)
|
|
||||||
elseif move == "right" then
|
|
||||||
if not piece:isMoveBlocked(grid, {x=1, y=0}) then
|
|
||||||
piece.lock_delay = 0 -- move reset
|
|
||||||
end
|
|
||||||
piece:moveInGrid({x=1, y=0}, 1, grid)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked)
|
|
||||||
local y = piece.position.y
|
|
||||||
if inputs["down"] == true and drop_locked == false then
|
|
||||||
piece:addGravity(gravity + 1, grid):lockIfBottomed(grid)
|
|
||||||
elseif inputs["up"] == true then
|
|
||||||
if piece:isDropBlocked(grid) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
piece:dropToBottom(grid)
|
|
||||||
else
|
|
||||||
piece:addGravity(gravity, grid)
|
|
||||||
end
|
|
||||||
if piece.position.y ~= y then -- step reset
|
|
||||||
piece.lock_delay = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function lockPiece(piece, grid, lock_delay)
|
|
||||||
if piece:isDropBlocked(grid) and piece.lock_delay >= lock_delay then
|
|
||||||
piece.locked = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function SRS.initializePiece(inputs, data, grid, gravity, prev_inputs, move, lock_delay, drop_speed, drop_locked)
|
|
||||||
local piece = Piece(shape, 0, {
|
|
||||||
x = SRS.spawn_positions[shape].x,
|
|
||||||
y = SRS.spawn_positions[shape].y
|
|
||||||
}, SRS.block_offsets, 0, 0)
|
|
||||||
-- have to copy that object otherwise it gets referenced
|
|
||||||
rotatePiece(inputs, piece, grid, {})
|
|
||||||
dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked)
|
|
||||||
return piece
|
|
||||||
end
|
|
||||||
|
|
||||||
function SRS.processPiece(inputs, piece, grid, gravity, prev_inputs, move, lock_delay, drop_speed, drop_locked)
|
|
||||||
rotatePiece(inputs, piece, grid, prev_inputs)
|
|
||||||
movePiece(piece, grid, move)
|
|
||||||
dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked)
|
|
||||||
lockPiece(piece, grid, lock_delay)
|
|
||||||
end
|
|
||||||
|
|
||||||
return SRS
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
Piece = require("tetris.components.piece")
|
|
||||||
|
|
||||||
local BONKERS = {}
|
|
||||||
|
|
||||||
BONKERS.name = "SUPER302"
|
|
||||||
BONKERS.hash = "Super302"
|
|
||||||
|
|
||||||
BONKERS.spawn_positions = {
|
|
||||||
I = { x=5, y=4 },
|
|
||||||
J = { x=4, y=5 },
|
|
||||||
L = { x=4, y=5 },
|
|
||||||
O = { x=5, y=5 },
|
|
||||||
S = { x=4, y=5 },
|
|
||||||
T = { x=4, y=5 },
|
|
||||||
Z = { x=4, y=5 },
|
|
||||||
}
|
|
||||||
|
|
||||||
BONKERS.block_offsets = {
|
|
||||||
I={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} },
|
|
||||||
{ {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1} },
|
|
||||||
{ {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2} },
|
|
||||||
},
|
|
||||||
J={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1} , {x=1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=1} },
|
|
||||||
},
|
|
||||||
L={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=-1, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=-1} },
|
|
||||||
},
|
|
||||||
O={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} },
|
|
||||||
},
|
|
||||||
S={
|
|
||||||
{ {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} },
|
|
||||||
{ {x=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
|
||||||
{ {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
|
||||||
},
|
|
||||||
T={
|
|
||||||
{ {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} },
|
|
||||||
},
|
|
||||||
Z={
|
|
||||||
{ {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} },
|
|
||||||
{ {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} },
|
|
||||||
{ {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} },
|
|
||||||
{ {x=-1, y=1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1} },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Component functions.
|
|
||||||
|
|
||||||
local function rotatePiece(inputs, piece, grid, prev_inputs)
|
|
||||||
local new_inputs = {}
|
|
||||||
|
|
||||||
for input, value in pairs(inputs) do
|
|
||||||
if value and not prev_inputs[input] then
|
|
||||||
new_inputs[input] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local rot_dir = 0
|
|
||||||
if (new_inputs["rotate_left"] or new_inputs["rotate_left2"]) then
|
|
||||||
rot_dir = 3
|
|
||||||
elseif (new_inputs["rotate_right"] or new_inputs["rotate_right2"]) then
|
|
||||||
rot_dir = 1
|
|
||||||
elseif (new_inputs["rotate_180"]) then
|
|
||||||
rot_dir = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
while rot_dir ~= 0 do
|
|
||||||
if piece.filled then break end
|
|
||||||
|
|
||||||
new_piece = piece:withRelativeRotation(rot_dir)
|
|
||||||
|
|
||||||
if (grid:canPlacePiece(new_piece)) and piece.shape ~= "O" then
|
|
||||||
piece:setRelativeRotation(rot_dir)
|
|
||||||
piece.lock_delay = 0 -- rotate reset
|
|
||||||
else
|
|
||||||
-- set the piece to occupy the whole grid
|
|
||||||
piece.filled = true
|
|
||||||
unfilled_block_offsets = {}
|
|
||||||
for y = 4, 23 do
|
|
||||||
for x = 0, 9 do
|
|
||||||
if not grid:isOccupied(x, y) then
|
|
||||||
table.insert(unfilled_block_offsets, {x=x, y=y})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
piece.position = {x=0, y=0}
|
|
||||||
piece.getBlockOffsets = function(piece)
|
|
||||||
return unfilled_block_offsets
|
|
||||||
end
|
|
||||||
piece.isDropBlocked = function(piece)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rot_dir = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
-- prev_inputs becomes the previous inputs
|
|
||||||
for input, value in pairs(inputs) do
|
|
||||||
prev_inputs[input] = inputs[input]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function movePiece(piece, grid, move)
|
|
||||||
if move == "left" then
|
|
||||||
if not piece:isMoveBlocked(grid, {x=-1, y=0}) then
|
|
||||||
piece.lock_delay = 0 -- move reset
|
|
||||||
end
|
|
||||||
piece:moveInGrid({x=-1, y=0}, 1, grid)
|
|
||||||
elseif move == "right" then
|
|
||||||
if not piece:isMoveBlocked(grid, {x=1, y=0}) then
|
|
||||||
piece.lock_delay = 0 -- move reset
|
|
||||||
end
|
|
||||||
piece:moveInGrid({x=1, y=0}, 1, grid)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked)
|
|
||||||
local y = piece.position.y
|
|
||||||
if inputs["down"] == true and drop_locked == false then
|
|
||||||
piece:addGravity(gravity + 1, grid):lockIfBottomed(grid)
|
|
||||||
elseif inputs["up"] == true then
|
|
||||||
if piece:isDropBlocked(grid) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
piece:dropToBottom(grid)
|
|
||||||
else
|
|
||||||
piece:addGravity(gravity, grid)
|
|
||||||
end
|
|
||||||
if piece.position.y ~= y then -- step reset
|
|
||||||
piece.lock_delay = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function lockPiece(piece, grid, lock_delay)
|
|
||||||
if piece:isDropBlocked(grid) and piece.lock_delay >= lock_delay then
|
|
||||||
piece.locked = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BONKERS.initializePiece(inputs, data, grid, gravity, prev_inputs, move, lock_delay, drop_speed, drop_locked)
|
|
||||||
local piece = Piece(shape, 0, {
|
|
||||||
x = BONKERS.spawn_positions[shape].x,
|
|
||||||
y = BONKERS.spawn_positions[shape].y
|
|
||||||
}, BONKERS.block_offsets, 0, 0)
|
|
||||||
-- have to copy that object otherwise it gets referenced
|
|
||||||
rotatePiece(inputs, piece, grid, {})
|
|
||||||
dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked)
|
|
||||||
return piece
|
|
||||||
end
|
|
||||||
|
|
||||||
function BONKERS.processPiece(inputs, piece, grid, gravity, prev_inputs, move, lock_delay, drop_speed, drop_locked)
|
|
||||||
rotatePiece(inputs, piece, grid, prev_inputs)
|
|
||||||
movePiece(piece, grid, move)
|
|
||||||
dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked)
|
|
||||||
lockPiece(piece, grid, lock_delay)
|
|
||||||
end
|
|
||||||
|
|
||||||
return BONKERS
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
local Piece = require 'tetris.components.piece'
|
|
||||||
local Ruleset = require 'tetris.rulesets.ruleset'
|
|
||||||
|
|
||||||
local Tengen = Ruleset:extend()
|
|
||||||
|
|
||||||
Tengen.name = "Tengen"
|
|
||||||
Tengen.hash = "Tengen"
|
|
||||||
|
|
||||||
Tengen.spawn_positions = {
|
|
||||||
I = { x=3, y=4 },
|
|
||||||
J = { x=4, y=4 },
|
|
||||||
L = { x=4, y=4 },
|
|
||||||
O = { x=5, y=4 },
|
|
||||||
S = { x=4, y=4 },
|
|
||||||
T = { x=4, y=4 },
|
|
||||||
Z = { x=4, y=4 },
|
|
||||||
}
|
|
||||||
|
|
||||||
Tengen.block_offsets = {
|
|
||||||
I={
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
},
|
|
||||||
J={
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=2, y=1} },
|
|
||||||
{ {x=1, y=0}, {x=1, y=1}, {x=1, y=2}, {x=0, y=2} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=1, y=1}, {x=2, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=1, y=0} },
|
|
||||||
},
|
|
||||||
L={
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=0, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=1, y=2} },
|
|
||||||
{ {x=2, y=0}, {x=0, y=1}, {x=1, y=1}, {x=2, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=1, y=1}, {x=1, y=2} },
|
|
||||||
},
|
|
||||||
O={
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=1, y=1}, {x=0, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=1, y=1}, {x=0, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=1, y=1}, {x=0, y=1} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=1, y=1}, {x=0, y=1} },
|
|
||||||
},
|
|
||||||
-- up to here
|
|
||||||
S={
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
},
|
|
||||||
T={
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
},
|
|
||||||
Z={
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
{ {x=0, y=0}, {x=1, y=0}, {x=2, y=0}, {x=3, y=0} },
|
|
||||||
{ {x=0, y=0}, {x=0, y=1}, {x=0, y=2}, {x=0, y=3} },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-- Component functions.
|
|
||||||
|
|
||||||
function Tengen:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
|
||||||
|
|
||||||
-- O doesn't kick
|
|
||||||
if (piece.shape == "O") then return end
|
|
||||||
|
|
||||||
-- center column rule
|
|
||||||
if (
|
|
||||||
piece.shape == "J" or piece.shape == "T" or piece.shape == "L"
|
|
||||||
) and (
|
|
||||||
piece.rotation == 0 or piece.rotation == 2
|
|
||||||
) and (
|
|
||||||
grid:isOccupied(piece.position.x, piece.position.y) or
|
|
||||||
grid:isOccupied(piece.position.x, piece.position.y - 1) or
|
|
||||||
grid:isOccupied(piece.position.x, piece.position.y - 2)
|
|
||||||
) then return end
|
|
||||||
|
|
||||||
if piece.shape == "I" then
|
|
||||||
-- special kick rules for I
|
|
||||||
if new_piece.rotation == 0 or new_piece.rotation == 2 then
|
|
||||||
-- kick right, right2, left
|
|
||||||
if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
|
|
||||||
self:onPieceRotate(piece, grid)
|
|
||||||
elseif grid:canPlacePiece(new_piece:withOffset({x=2, y=0})) then
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=2, y=0})
|
|
||||||
self:onPieceRotate(piece, grid)
|
|
||||||
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
|
||||||
self:onPieceRotate(piece, grid)
|
|
||||||
end
|
|
||||||
elseif piece:isDropBlocked(grid) and (new_piece.rotation == 1 or new_piece.rotation == 3) and piece.floorkick == 0 then
|
|
||||||
-- kick up, up2
|
|
||||||
if grid:canPlacePiece(new_piece:withOffset({x=0, y=-1})) then
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1})
|
|
||||||
self:onPieceRotate(piece, grid)
|
|
||||||
piece.floorkick = 1
|
|
||||||
elseif grid:canPlacePiece(new_piece:withOffset({x=0, y=-2})) then
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-2})
|
|
||||||
self:onPieceRotate(piece, grid)
|
|
||||||
piece.floorkick = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif piece.shape ~= "I" then
|
|
||||||
-- kick right, kick left
|
|
||||||
if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
|
|
||||||
elseif (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function Tengen:onPieceCreate(piece, grid)
|
|
||||||
piece.floorkick = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function Tengen:onPieceDrop(piece, grid)
|
|
||||||
piece.lock_delay = 0 -- step reset
|
|
||||||
end
|
|
||||||
|
|
||||||
function Tengen:get180RotationValue() return config["reverse_rotate"] and 1 or 3 end
|
|
||||||
function Tengen:getDefaultOrientation() return 3 end -- downward facing pieces by default
|
|
||||||
|
|
||||||
return Tengen
|
|
||||||
Reference in New Issue
Block a user