Compare commits

..

138 Commits

Author SHA1 Message Date
Ishaan Bhardwaj
40a2e78280 Marathon 2020 section colour function fixed 2020-12-06 11:38:45 -05:00
Ishaan Bhardwaj
696da3fa3f Marathon 2020 colour function removed 2020-12-06 11:27:44 -05:00
Ishaan Bhardwaj
4afe9f2bd4 Major sound effect update (closes #7?)
Sound effects can still be changed, and #7 can still be reopened.
2020-12-05 20:30:59 -05:00
Ishaan Bhardwaj
1f686fb5d4 Ti-ARS: T can no longer floorkick the air 2020-12-05 18:32:06 -05:00
Ishaan Bhardwaj
f4779c9847 Added the ability to toggle next piece SFX 2020-12-05 17:32:15 -05:00
Ishaan Bhardwaj
06cbec4bc8 Guideline SRS kicks fixed 2020-12-05 17:15:28 -05:00
Ishaan Bhardwaj
668564ffb0 Revert "big a3! (but its buggy??)"
This reverts commit 513cd6ba90.
Hailey, please do not add modes.
2020-12-05 16:56:12 -05:00
Hailey
e6edeea3d1 Merge branch 'master' of https://github.com/SashLilac/cambridge 2020-12-05 12:50:45 +10:00
Hailey
513cd6ba90 big a3! (but its buggy??) 2020-12-05 12:49:57 +10:00
Ishaan Bhardwaj
1beef8f157 Guideline SRS has 180s now 2020-12-04 21:36:25 -05:00
Ishaan Bhardwaj
d3b2b4c2d9 Ruleset refactoring! 2020-12-04 20:36:11 -05:00
Ishaan Bhardwaj
2b8b9d5084 Reduced the sound volume a little bit. 2020-12-04 20:12:36 -05:00
Ishaan Bhardwaj
2728780c45 Raised the piece sound volume by a factor of 10. 2020-12-04 19:42:33 -05:00
Ishaan Bhardwaj
ca592a3bcf Changed piece sounds, added sound sources 2020-12-04 19:27:02 -05:00
Ishaan Bhardwaj
b6f4158d70 Fixed SRS infinity bug! 2020-12-04 16:51:53 -05:00
Ishaan Bhardwaj
e43f5c470a Renaming backgrounds 2020-12-04 16:32:29 -05:00
Ishaan Bhardwaj
7bcdc517c0 Revert "Merge pull request #11 from Rexxt/master"
Reverting this pull request for a few reasons:
The piece sounds were too quiet.
The piece landing sound was distasteful.
2020-12-04 16:22:22 -05:00
Ishaan Bhardwaj
1d30987f9a Merge pull request #11 from Rexxt/master
Uncopyrightening and making the game slightly friendlier to mod
2020-12-04 16:13:38 -05:00
Ishaan Bhardwaj
1dd46a11ef Fixed torikans giving you a green line 2020-12-04 15:41:44 -05:00
Ishaan Bhardwaj
935c7aa14c Default secret grade names 2020-12-04 15:16:13 -05:00
Ishaan Bhardwaj
aea115d953 ACE-SRS has correct number of resets 2020-12-04 11:22:32 -05:00
Ishaan Bhardwaj
3d5b33f41a Added ability to enable/disable synchroes
On by default in anything but world rulesets.
Gamemodes / rulesets can override this setting.
2020-12-04 10:57:43 -05:00
Mizu
29f07bb6ab Update piece sounds 2020-12-04 15:38:34 +01:00
Ishaan Bhardwaj
891f96e814 I broke the DAS switch functionality 2020-12-03 14:10:46 -05:00
Ishaan Bhardwaj
36837a3af5 Update main.lua 2020-12-03 13:45:23 -05:00
Ishaan Bhardwaj
01b0f9f618 DAS switch behavior implemented 2020-12-02 21:09:52 -05:00
Ishaan Bhardwaj
7c8c5bb11d Hide hold queue when hold is disabled 2020-12-02 13:41:47 -05:00
Ishaan Bhardwaj
acaa6bdbbf whoops forgot to not require socket 2020-12-01 11:58:29 -05:00
Ishaan Bhardwaj
c37757f592 Implement an axis timer (fixes #12) 2020-12-01 11:57:09 -05:00
Ishaan Bhardwaj
905e4bcc77 drawSectionTimesWithSecondary update 2020-12-01 11:56:44 -05:00
Ishaan Bhardwaj
d956647678 Core mode rebalancing 2020-12-01 11:56:28 -05:00
Ishaan Bhardwaj
10f032b49b Added more functionality to advanceOneFrame 2020-11-30 12:34:21 -05:00
Ishaan Bhardwaj
5590e6c89b Small DAS changes 2020-11-29 11:11:47 -05:00
Joe Z
0393396d74 Made instant DAS respect instant gravity. 2020-11-29 09:19:17 -05:00
Joe Zeng
8c1eaec1aa DAS priority reversal (#25)
* Reversed the priority of key presses when charging DAS.
* Made it an actual config option.
* Config should be false by default.
2020-11-28 23:29:46 -05:00
Ishaan Bhardwaj
957802a78e Fixed a minor bug in the scope of SA2's line 2020-11-27 23:21:59 -05:00
Ishaan Bhardwaj
169a4e4d2f AX4 no longer shows timer in the roll 2020-11-22 10:39:42 -05:00
Ishaan Bhardwaj
48aee18340 Fix I wallkicks in ARS rules 2020-11-21 23:29:06 -05:00
Ishaan Bhardwaj
7b496d9412 Ti and ACE floorkick fix 2020-11-21 21:48:45 -05:00
Ishaan Bhardwaj
7abb861446 Hard drop can ARE cancel now 2020-11-21 16:29:24 -05:00
Ishaan Bhardwaj
21f8769228 Made ARE canceling also cancel LCD 2020-11-20 11:29:46 -05:00
Ishaan Bhardwaj
44423fd2e8 Made ARE canceling less slippery (again) 2020-11-19 22:22:43 -05:00
Ishaan Bhardwaj
351fb4cfe9 Added the functionality to draw only an outline of the stack 2020-11-18 12:17:04 -05:00
Ishaan Bhardwaj
103f04ceaa added a misc function 2020-11-17 21:52:20 -05:00
Ishaan Bhardwaj
88d2f0d8d1 Made ARE canceling more consistent. 2020-11-17 13:50:38 -05:00
Ishaan Bhardwaj
e100289c82 Made ARE canceling less slippery 2020-11-16 22:23:05 -05:00
Ishaan Bhardwaj
e38da49180 ARE canceling 2020-11-16 21:16:59 -05:00
Ishaan Bhardwaj
b03473d2fe IRS fix 2020-11-16 12:51:21 -05:00
Ishaan Bhardwaj
cf6e0be4e7 New IRS and IHS settings 2020-11-16 12:48:28 -05:00
Ishaan Bhardwaj
2bc9dc179c Updated README with another contributor 2020-11-14 20:00:24 -05:00
Ishaan Bhardwaj
d626926d5a Fixed 180 rotation directions 2020-11-14 19:20:25 -05:00
Ishaan Bhardwaj
721acefea0 Cleaned up TAP M-roll 2020-11-14 09:35:16 -05:00
Ishaan Bhardwaj
b9b71e90bb Finished Marathon 2020 grading! 2020-11-12 17:01:28 -05:00
Ishaan Bhardwaj
9f61b139fd TAP M-roll created 2020-11-12 16:52:40 -05:00
Ishaan Bhardwaj
3b0fdba27d Updated README.md to have the updated mod pack 2020-11-12 09:45:48 -05:00
Ishaan Bhardwaj
d8fad3dc37 Added some more developer functions, to aid in building modes. 2020-11-11 22:30:30 -05:00
Mizu
6d326a142c Update some sounds (not the pieces 2020-11-11 18:38:45 +01:00
Mizu
b6f1072587 Merge branch 'master' of https://github.com/Rexxt/cambridge 2020-11-11 17:43:53 +01:00
Mizu
eef04ebf05 Update graphic names and SOURCES.md 2020-11-11 17:42:48 +01:00
Mizu
e24737a3b8 Merge pull request #1 from SashLilac/master
Update fork
2020-11-11 17:17:22 +01:00
Ishaan Bhardwaj
f9368fa806 Forgot to add a contributor, whoops... 2020-11-11 11:11:55 -05:00
Ishaan Bhardwaj
189feb1802 Fixed the last of the hard drop safelocks... 2020-11-10 23:13:25 -05:00
Ishaan Bhardwaj
dc09dabacb Fixed Phantom Mania safelock behaviors 2020-11-10 23:10:39 -05:00
Ishaan Bhardwaj
e13278c6a8 Fixed safelock behavior for hard drop modes 2020-11-10 22:34:48 -05:00
Ishaan Bhardwaj
f7f11b0e22 Updated README.md with new Windows instructions 2020-11-10 21:41:34 -05:00
Ishaan Bhardwaj
869a0f7ec5 Added more input failsafes 2020-11-10 21:26:19 -05:00
Ishaan Bhardwaj
10a9d97848 Removed modes from core game to create modpack. Check README 2020-11-10 21:16:17 -05:00
Ishaan Bhardwaj
a470b40def Refactored input handling, so that arrow keys will always work on menus. 2020-11-10 20:08:34 -05:00
nightmareci
fd739dcfdf Changed reserved keys (arrows are no longer reserved) and now F2 always gets to the input config except when in-game. 2020-11-10 14:37:59 -08:00
Ishaan Bhardwaj
e1dc01d0d0 Changed the rotation game setting to be less ambiguous 2020-11-10 16:10:10 -05:00
Ishaan Bhardwaj
7228707241 Changed the way color override works on bone blocks 2020-11-10 16:03:30 -05:00
Ishaan Bhardwaj
af86ce3a98 Updated README.md 2020-11-10 13:41:23 -05:00
Ishaan Bhardwaj
78ae0ae671 Fixed the piece lock SFX where applicable, in modes that had their own lock functions. 2020-11-09 23:22:28 -05:00
Ishaan Bhardwaj
c614e9c4cd Fixed safelock behavior on modes that needed it. 2020-11-09 23:16:28 -05:00
Ishaan Bhardwaj
b27ef0e9f4 Made it so that in TGM3, you can only get GM by clearing the roll, and fixed hold sound in Phantom Mania 2 2020-11-09 23:04:50 -05:00
Joe Zeng
843b1e108a Added safe-lock back to Survival CK. 2020-11-09 21:13:07 -05:00
Brandon McGriff
a8d697064c Merge branch 'master' of https://github.com/SashLilac/cambridge 2020-11-09 16:09:39 -08:00
Brandon McGriff
cf32474898 Fixed libs/discordRPC.lua so Discord RPC loads on Linux.
I changed how the library was loaded before, but turns out that way only
worked on Windows. Changed it back to how it was, so it works on Linux
for me, and presumably macOS.
2020-11-09 16:06:09 -08:00
Brandon McGriff
6a295cad59 Added Windows batch files for automated packaging of fused Windows packages.
They require the tar utility, but that's included in the latest versions of Windows 10. The utility is available for installation on other versions of Windows.

I also found out how to get the Discord RPC library to load with all ways of running the game, but that required changing libs/discordRPC.lua. Binary libraries can only be loaded from the filesystem, outside of a .love archive or fused executable.
2020-11-09 15:51:00 -08:00
Ishaan Bhardwaj
2d80e20c82 Updated README.md with more new contributors 2020-11-09 11:47:21 -05:00
Ishaan Bhardwaj
2279c24d11 Closed an if in the previous fix 2020-11-08 23:23:26 -05:00
Ishaan Bhardwaj
8510ad9bea Fixed Phantom Mania 2 roll grade points. 2020-11-08 23:19:21 -05:00
Joe Zeng
6b77ad8547 Merge pull request #8 from nightmareci/master
Implemented joystick input.
2020-11-08 17:17:30 -05:00
nightmareci
6834e92674 Changed indentation to hard tabs. 2020-11-08 13:19:01 -08:00
nightmareci
3479374686 Forgot that the code used "enter" instead of "return" in the input config scene before, so changed it back. 2020-11-08 13:06:29 -08:00
nightmareci
863c614a4c Implemented joystick input.
I had to redo how input is done entirely, so more than one source of input can be used for game inputs.

I added new inputs, menu_decide and menu_back. Return and escape still have their reserved status, sending menu_decide and menu_back, respectively. Other keys are reserved too, like arrows, to ensure users can always reconfigure input.
2020-11-08 12:55:06 -08:00
Joe Zeng
49e52c6a39 Merge pull request #4 from Rexxt/master
Small updates to visuals and sound
2020-11-07 14:31:17 -05:00
Joe Zeng
a105086ca6 Fixed the garbage pausing problem in Phantom Mania 2. 2020-11-07 01:31:09 -05:00
Joe Zeng
1b381c4bf3 Might as well add the dark square while I'm at it. 2020-11-07 01:29:44 -05:00
Joe Zeng
91a87fea73 Fixed the garbage pausing problem in Phantom Mania 2. 2020-11-07 01:12:13 -05:00
Ishaan Bhardwaj
28b455fcc0 Updated README.md with new contributors 2020-11-06 20:57:01 -05:00
Joe Zeng
2e3eff025f Replaced spaces with tabs.
Check CONTRIBUTING.md, guys!
2020-11-06 20:54:14 -05:00
Joe Zeng
4670cb7c15 Added the ability to _always_ reverse rotation. 2020-11-06 20:46:36 -05:00
Joe Zeng
9b04e14388 Added "Always reverse" option for rotation reversal. 2020-11-06 19:17:32 -05:00
Ishaan Bhardwaj
f52da36bf7 TGM3 cool system change 2020-11-06 14:01:28 -05:00
Ishaan Bhardwaj
76142c1dff More Green Orange line 2020-11-05 16:21:58 -05:00
Ishaan Bhardwaj
a3458e2413 Fix Arika SRS 2020-11-04 22:46:45 -05:00
Ishaan Bhardwaj
7eba9c012f Merge branch 'master' of https://github.com/sashlilac/cambridge 2020-11-04 16:58:11 -05:00
Ishaan Bhardwaj
4d2868b7b6 Small changes. 2020-11-04 16:57:44 -05:00
Ishaan Bhardwaj
2e6fcd232b Update README.md 2020-11-04 08:42:42 -05:00
Ishaan Bhardwaj
10833f2ec1 Score drain changes 2020-11-03 23:20:41 -05:00
Ishaan Bhardwaj
abb2b9491e Preparing for v0.2.1 2020-11-03 23:04:47 -05:00
Ishaan Bhardwaj
062ab2005e v0.2 release commit - hold piece darken 2020-11-03 16:56:08 -05:00
Ishaan Bhardwaj
468025fc80 last commit to core modes before release 2020-11-03 12:17:36 -05:00
Ishaan Bhardwaj
c8544975d6 Fix interval training 2020-11-03 11:55:30 -05:00
Ishaan Bhardwaj
6776229bfb Small push to Cambridge modes 2020-11-03 11:52:52 -05:00
Ishaan Bhardwaj
84b4dc5073 World Bone Blocks 2020-11-03 10:58:21 -05:00
Ishaan Bhardwaj
35dafb6615 keep leaving debug code in new commits 2020-11-02 22:51:16 -05:00
Ishaan Bhardwaj
3641d85fcb Major changes, including modpack support 2020-11-02 22:47:58 -05:00
Ishaan Bhardwaj
9b89c4d1de G/O line fix 2020-11-02 21:17:13 -05:00
Ishaan Bhardwaj
2dba120919 Green line and orange line for TAP Master 2020-11-02 20:43:10 -05:00
Ishaan Bhardwaj
9224f271b1 Hotfix for last 2020-11-02 16:20:22 -05:00
Ishaan Bhardwaj
febb5d546c Score overhauls 2020-11-02 16:12:05 -05:00
Ishaan Bhardwaj
c6482c423e 4w optimization and green/orange line adding for applicable modes 2020-11-02 13:46:16 -05:00
Ishaan Bhardwaj
6beb313c6b Debug fixes 2020-11-02 12:44:15 -05:00
Ishaan Bhardwaj
eb70f55b6e TGM2 fixes and cool fixes 2020-11-02 12:21:12 -05:00
Ishaan Bhardwaj
0badcde9ad Basset: the only person to leave debug code in a repo 2020-11-01 13:44:35 -05:00
Ishaan Bhardwaj
6f39b591d3 Hotfix for TGM+ 2020-11-01 13:28:13 -05:00
Ishaan Bhardwaj
129237f0b0 TGM+ 2020-11-01 13:24:52 -05:00
Ishaan Bhardwaj
741c246244 second lol 2020-11-01 12:04:07 -05:00
Ishaan Bhardwaj
b5937af8b2 lol 2020-11-01 12:01:26 -05:00
Ishaan Bhardwaj
33b8533d8e Fixes to TAP M-roll requirements 2020-11-01 11:06:43 -05:00
Ishaan Bhardwaj
69959ff687 TA Death level advance formula is very bugged 2020-10-30 21:36:05 -04:00
Ishaan Bhardwaj
f91cd99dfd Minor fixes to TGM modes 2020-10-30 21:28:39 -04:00
Ishaan Bhardwaj
be59727ca5 Some demon mode fixes 2020-10-30 13:09:49 -04:00
Ishaan Bhardwaj
cca295066c Fix. 2020-10-29 23:05:49 -04:00
Ishaan Bhardwaj
f2862b4d93 Some score fixes for core TGM modes 2020-10-29 23:03:54 -04:00
Ishaan Bhardwaj
2aafd30253 Fixed secret grade detection 2020-10-29 22:14:34 -04:00
Ishaan Bhardwaj
b27ba335ba Improved secret grade 2020-10-29 21:40:50 -04:00
Ishaan Bhardwaj
33244736b8 Secret grade for sprint? Also ARR and DAS change so remember to change it in the lua file 2020-10-29 20:56:18 -04:00
Mizu
a324e0015a Replace SFX and add hold 2020-10-27 12:17:00 +01:00
Ishaan Bhardwaj
285108ca08 ACTUALLY fixed TI Master torikan 2020-10-26 14:07:09 -04:00
Ishaan Bhardwaj
4b1fed727c Update marathon_a3.lua 2020-10-26 14:03:09 -04:00
Mizu
d38168ca00 Updated title screen background 2020-10-26 16:57:20 +01:00
Mizu
b0ce0f17f5 Add new sound effects to the game 2020-10-26 14:21:49 +01:00
Ishaan Bhardwaj
9fca272e8d Update ck.lua 2020-10-24 09:12:12 -04:00
Ishaan Bhardwaj
5a21c8244b Update README.md 2020-10-23 21:28:32 -04:00
Ishaan Bhardwaj
4923b2e2d4 Removed debug code 2020-10-23 21:23:45 -04:00
114 changed files with 1971 additions and 4107 deletions

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@
*.love *.love
dist/*.zip dist/*.zip
dist/**/cambridge.exe dist/**/cambridge.exe
dist/**/libs
dist/**/*.md

View File

@@ -5,47 +5,56 @@ 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 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!
- [Hailey](https://github.com/haileylgbt) for some miscellaneous assets.
- MarkGamed7794 for some miscellaneous contributions. The following people in no particular order also helped with the project:
- Mizu for the Cambridge logo and the [Cambridge launcher](https://github.com/rexxt/cambridge-launcher). - [Hailey](https://github.com/haileylgbt)
- MattMayuga for the Cambridge banner. - 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)
- [Dr Ocelot](https://github.com/Dr-Ocelot)
![Cambridge Logo](https://cdn.discordapp.com/attachments/625496179433668635/763363717730664458/Icon_2.png) ![Cambridge Logo](https://cdn.discordapp.com/attachments/625496179433668635/763363717730664458/Icon_2.png)
Installation instructions Playing the game
------------------------- ----------------
Pre-built releases are available on the releases page.
### 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
@@ -55,12 +64,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
------- -------

View File

@@ -8,7 +8,7 @@ Some of the assets are used without proper licenses. We aim to have fully licens
Backgrounds Backgrounds
----------- -----------
1. Title: "Motus Glacies." Contributed by Daniel "Explo" McCarthy. 1. Title: Original picrute found on the Wikipedia article for Cambridge
1. *Gameplay level 0: "Quantum foam." Alex Sukontsev. https://www.flickr.com/photos/control9/14957509814/ 1. *Gameplay level 0: "Quantum foam." Alex Sukontsev. https://www.flickr.com/photos/control9/14957509814/
2. *Gameplay level 1: No name. http://www.onekind.tv/univision-mqb/q5mqh5brlvuuj2nhdx7ch7eum183uu 2. *Gameplay level 1: No name. http://www.onekind.tv/univision-mqb/q5mqh5brlvuuj2nhdx7ch7eum183uu
@@ -34,6 +34,14 @@ Backgrounds
Backgrounds marked with a * are placeholders that will be replaced in later versions due to incompatible licenses. We are generally aiming for public domain background images, but will also accept backgrounds given proper licenses to be included within Cambridge. Backgrounds marked with a * are placeholders that will be replaced in later versions due to incompatible licenses. We are generally aiming for public domain background images, but will also accept backgrounds given proper licenses to be included within Cambridge.
Sounds
------
All piece sounds are (c) 2020 Damian Yerrick.
Other sounds from:
- NullpoMino
- DTET, (c) 2003 Mihys.
Music Music
----- -----

11
clean.bat Normal file
View 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

View File

@@ -5,12 +5,26 @@ local ffi = require "ffi"
local osname = love.system.getOS() local osname = love.system.getOS()
local discordRPClib = nil 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 if osname == "Linux" then
discordRPClib = ffi.load(love.filesystem.getSource().."/libs/discord-rpc.so") discordRPClib = ffi.load(source.."/libs/discord-rpc.so")
elseif osname == "OS X" then elseif osname == "OS X" then
discordRPClib = ffi.load(love.filesystem.getSource().."/libs/discord-rpc.dylib") discordRPClib = ffi.load(source.."/libs/discord-rpc.dylib")
elseif osname == "Windows" then elseif osname == "Windows" then
discordRPClib = ffi.load(love.filesystem.getSource().."/libs/discord-rpc.dll") discordRPClib = ffi.load(source.."/libs/discord-rpc.dll")
else else
-- Else it crashes later on -- Else it crashes later on
error(string.format("Discord rpc not supported on platform (%s)", osname)) error(string.format("Discord rpc not supported on platform (%s)", osname))

View File

@@ -1,27 +1,27 @@
backgrounds = { backgrounds = {
[0] = love.graphics.newImage("res/backgrounds/0-quantum-foam.png"), [0] = love.graphics.newImage("res/backgrounds/0.png"),
love.graphics.newImage("res/backgrounds/100-big-bang.png"), love.graphics.newImage("res/backgrounds/100.png"),
love.graphics.newImage("res/backgrounds/200-spiral-galaxy.png"), love.graphics.newImage("res/backgrounds/200.png"),
love.graphics.newImage("res/backgrounds/300-sun-and-dust.png"), love.graphics.newImage("res/backgrounds/300.png"),
love.graphics.newImage("res/backgrounds/400-earth-and-moon.png"), love.graphics.newImage("res/backgrounds/400.png"),
love.graphics.newImage("res/backgrounds/500-cambrian-explosion.png"), love.graphics.newImage("res/backgrounds/500.png"),
love.graphics.newImage("res/backgrounds/600-dinosaurs.png"), love.graphics.newImage("res/backgrounds/600.png"),
love.graphics.newImage("res/backgrounds/700-asteroid.png"), love.graphics.newImage("res/backgrounds/700.png"),
love.graphics.newImage("res/backgrounds/800-human-fire.png"), love.graphics.newImage("res/backgrounds/800.png"),
love.graphics.newImage("res/backgrounds/900-early-civilization.png"), love.graphics.newImage("res/backgrounds/900.png"),
love.graphics.newImage("res/backgrounds/1000-vikings.png"), love.graphics.newImage("res/backgrounds/1000.png"),
love.graphics.newImage("res/backgrounds/1100-crusades.png"), love.graphics.newImage("res/backgrounds/1100.png"),
love.graphics.newImage("res/backgrounds/1200-genghis-khan.png"), love.graphics.newImage("res/backgrounds/1200.png"),
love.graphics.newImage("res/backgrounds/1300-black-death.png"), love.graphics.newImage("res/backgrounds/1300.png"),
love.graphics.newImage("res/backgrounds/1400-columbus-discovery.png"), love.graphics.newImage("res/backgrounds/1400.png"),
love.graphics.newImage("res/backgrounds/1500-aztecas.png"), love.graphics.newImage("res/backgrounds/1500.png"),
love.graphics.newImage("res/backgrounds/1600-telescope.png"), love.graphics.newImage("res/backgrounds/1600.png"),
love.graphics.newImage("res/backgrounds/1700-american-revolution.png"), love.graphics.newImage("res/backgrounds/1700.png"),
love.graphics.newImage("res/backgrounds/1800-railways.png"), love.graphics.newImage("res/backgrounds/1800.png"),
love.graphics.newImage("res/backgrounds/1900-world-wide-web.png"), love.graphics.newImage("res/backgrounds/1900.png"),
title = love.graphics.newImage("res/backgrounds/title_v0.1.png"), title = love.graphics.newImage("res/backgrounds/title.png"),
input_config = love.graphics.newImage("res/backgrounds/options-pcb.png"), input_config = love.graphics.newImage("res/backgrounds/options-input.png"),
game_config = love.graphics.newImage("res/backgrounds/options-gears.png"), game_config = love.graphics.newImage("res/backgrounds/options-game.png"),
} }
blocks = { blocks = {
@@ -33,6 +33,8 @@ blocks = {
C = love.graphics.newImage("res/img/s2.png"), C = love.graphics.newImage("res/img/s2.png"),
B = love.graphics.newImage("res/img/s4.png"), B = love.graphics.newImage("res/img/s4.png"),
M = love.graphics.newImage("res/img/s5.png"), M = love.graphics.newImage("res/img/s5.png"),
F = 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"] = {
@@ -43,6 +45,8 @@ blocks = {
C = love.graphics.newImage("res/img/bone.png"), C = love.graphics.newImage("res/img/bone.png"),
B = love.graphics.newImage("res/img/bone.png"), B = love.graphics.newImage("res/img/bone.png"),
M = 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"),
} }
} }

View File

@@ -14,20 +14,44 @@ sounds = {
cursor_lr = love.audio.newSource("res/se/cursor_lr.wav", "static"), cursor_lr = love.audio.newSource("res/se/cursor_lr.wav", "static"),
main_decide = love.audio.newSource("res/se/main_decide.wav", "static"), main_decide = love.audio.newSource("res/se/main_decide.wav", "static"),
mode_decide = love.audio.newSource("res/se/mode_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"),
irs = love.audio.newSource("res/se/irs.wav", "static"),
ihs = love.audio.newSource("res/se/ihs.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
sounds[sound]:play() sounds[sound]:play()
else else
sounds[sound][subsound]:setVolume(0.1) sounds[sound][subsound]:setVolume(0.6)
if sounds[sound][subsound]:isPlaying() then if sounds[sound][subsound]:isPlaying() then
sounds[sound][subsound]:stop() sounds[sound][subsound]:stop()
end end
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

145
main.lua
View File

@@ -15,7 +15,12 @@ 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 if not config.gamesettings then
config.gamesettings = {}
config["das_last_key"] = false
else
config["das_last_key"] = config.gamesettings.das_last_key == 2
end
for _, option in ipairs(GameConfigScene.options) do for _, option in ipairs(GameConfigScene.options) do
if not config.gamesettings[option[1]] then if not config.gamesettings[option[1]] then
config.gamesettings[option[1]] = 1 config.gamesettings[option[1]] = 1
@@ -23,13 +28,34 @@ function love.load()
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
@@ -88,13 +114,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
View 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
View 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 ..\..

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 2.9 MiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 3.1 MiB

After

Width:  |  Height:  |  Size: 3.1 MiB

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 2.7 MiB

View File

Before

Width:  |  Height:  |  Size: 3.6 MiB

After

Width:  |  Height:  |  Size: 3.6 MiB

View File

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 2.9 MiB

View File

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 3.0 MiB

BIN
res/backgrounds/title.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

BIN
res/img/bonew.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
res/img/s8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
res/se/erase.wav Normal file

Binary file not shown.

BIN
res/se/fall.wav Normal file

Binary file not shown.

BIN
res/se/go.wav Normal file

Binary file not shown.

BIN
res/se/hold.wav Normal file

Binary file not shown.

BIN
res/se/ihs.wav Normal file

Binary file not shown.

BIN
res/se/irs.wav Normal file

Binary file not shown.

BIN
res/se/lock.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
res/se/ready.wav Normal file

Binary file not shown.

View File

@@ -5,7 +5,8 @@ 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" ExitScene = require "scene.exit"
GameScene = require "scene.game" GameScene = require "scene.game"

View File

@@ -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

View File

@@ -16,7 +16,7 @@ end
function ExitScene:changeOption(rel) function ExitScene:changeOption(rel)
end end
function ExitScene:onKeyPress(e) function ExitScene:onInputPress(e)
end end
return ExitScene return ExitScene

View File

@@ -1,10 +1,27 @@
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({ DiscordRPC:update({
details = self.game.rpc_details, details = self.game.rpc_details,
state = self.game.name, state = self.game.name,
@@ -13,18 +30,11 @@ 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()
@@ -49,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
@@ -59,23 +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" or e.scancode == "escape") 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.scancode == config.input.retry) then elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
-- fuck this, this is hacky but the way this codebase is setup prevents anything else self.inputs[e.input] = true
-- it seems like all the values that get touched in the child gamemode class end
-- stop being linked to the values of the GameMode superclass because of how `mt.__index` works end
-- not even sure this is the actual problem, but I don't want to have to rebuild everything about
-- the core organisation of everything. this hacky way will have to do until someone figures out something. function GameScene:onInputRelease(e)
love.keypressed("escape", "escape", false) if e.input and string.sub(e.input, 1, 5) ~= "menu_" then
love.keypressed("return", "return", false) self.inputs[e.input] = false
elseif e.scancode == "escape" then
scene = ModeSelectScene()
end end
end end

View File

@@ -8,7 +8,10 @@ ConfigScene.options = {
-- this serves as reference to what the options' values mean i guess? -- this serves as reference to what the options' values mean i guess?
{"manlock", "Manual locking",{"Per ruleset","Per gamemode","Harddrop", "Softdrop"}}, {"manlock", "Manual locking",{"Per ruleset","Per gamemode","Harddrop", "Softdrop"}},
{"piece_colour", "Piece Colours", {"Per ruleset","Arika" ,"TTC"}}, {"piece_colour", "Piece Colours", {"Per ruleset","Arika" ,"TTC"}},
{"world_reverse", "World Reverse", {"No", "Yes"}}, {"world_reverse","A Button Rotation", {"Left" ,"Auto" ,"Right"}},
{"next_se", "Next Piece SFX", {"On", "Off"}},
{"das_last_key", "DAS Switch", {"Default", "Instant"}},
{"synchroes_allowed", "Synchroes", {"Per ruleset", "On", "Off"}}
} }
local optioncount = #ConfigScene.options local optioncount = #ConfigScene.options
@@ -24,6 +27,7 @@ function ConfigScene:new()
end end
function ConfigScene:update() function ConfigScene:update()
config["das_last_key"] = config.gamesettings.das_last_key == 2
end end
function ConfigScene:render() function ConfigScene:render()
@@ -51,26 +55,26 @@ function ConfigScene:render()
end end
end end
function ConfigScene:onKeyPress(e) function ConfigScene:onInputPress(e)
if e.scancode == "return" and e.isRepeat == false then if e.input == "menu_decide" or e.scancode == "return" then
playSE("mode_decide") playSE("mode_decide")
saveConfig() saveConfig()
scene = TitleScene() scene = TitleScene()
elseif (e.scancode == config.input["up"] or e.scancode == "up") and e.isRepeat == false then elseif e.input == "up" or e.scancode == "up" then
playSE("cursor") playSE("cursor")
self.highlight = Mod1(self.highlight-1, optioncount) self.highlight = Mod1(self.highlight-1, optioncount)
elseif (e.scancode == config.input["down"] or e.scancode == "down") and e.isRepeat == false then elseif e.input == "down" or e.scancode == "down" then
playSE("cursor") playSE("cursor")
self.highlight = Mod1(self.highlight+1, optioncount) self.highlight = Mod1(self.highlight+1, optioncount)
elseif (e.scancode == config.input["left"] or e.scancode == "left") and e.isRepeat == false then elseif e.input == "left" or e.scancode == "left" then
playSE("cursor_lr") playSE("cursor_lr")
local option = ConfigScene.options[self.highlight] local option = ConfigScene.options[self.highlight]
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]-1, #option[3]) config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]-1, #option[3])
elseif (e.scancode == config.input["right"] or e.scancode == "right") and e.isRepeat == false then elseif e.input == "right" or e.scancode == "right" then
playSE("cursor_lr") playSE("cursor_lr")
local option = ConfigScene.options[self.highlight] local option = ConfigScene.options[self.highlight]
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[3]) config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[3])
elseif e.scancode == "escape" then elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
loadSave() loadSave()
scene = TitleScene() scene = TitleScene()
end end

View File

@@ -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",
@@ -18,10 +20,19 @@ local configurable_inputs = {
"retry", "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 = {}
self.axis_timer = 0
DiscordRPC:update({ DiscordRPC:update({
details = "In menus", details = "In menus",
@@ -41,38 +52,109 @@ function ConfigScene:render()
) )
love.graphics.setFont(font_3x5_2) love.graphics.setFont(font_3x5_2)
for i, input in pairs(configurable_inputs) do for i, input in ipairs(configurable_inputs) do
love.graphics.printf(input, 40, 50 + i * 20, 200, "left") love.graphics.printf(input, 40, 50 + i * 20, 200, "left")
if config.input[input] then if self.set_inputs[input] then
love.graphics.printf( love.graphics.printf(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
love.keyboard.getKeyFromScancode(config.input[input]) .. " (" .. config.input[input] .. ")",
240, 50 + i * 20, 200, "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
self.axis_timer = self.axis_timer + 1
end
local function addJoystick(input, name)
if not input.joysticks then
input.joysticks = {}
end
if not input.joysticks[name] then
input.joysticks[name] = {}
end end
end end
function ConfigScene:onKeyPress(e) function ConfigScene:onInputPress(e)
if self.input_state > table.getn(configurable_inputs) then 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
if e.scancode == "escape" then self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
loadSave()
scene = TitleScene()
else
config.input[configurable_inputs[self.input_state]] = e.scancode
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 (e.axis ~= self.last_axis or self.axis_timer > 30) and math.abs(e.value) >= 1 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 >= 1 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 >= 1 and "positive" or "negative"] = configurable_inputs[self.input_state]
self.input_state = self.input_state + 1
self.last_axis = e.axis
self.axis_timer = 0
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 end

View File

@@ -5,44 +5,6 @@ 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.ck',
--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.ti_srs',
require 'tetris.rulesets.arika_ace',
require 'tetris.rulesets.arika_ace2',
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,
@@ -70,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)
@@ -85,15 +47,19 @@ 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
@@ -101,17 +67,16 @@ function ModeSelectScene:onKeyPress(e)
playSE("mode_decide") 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)
playSE("cursor") playSE("cursor")
elseif (e.scancode == config.input["down"] or e.scancode == "down") and e.isRepeat == false then elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1) self:changeOption(1)
playSE("cursor") playSE("cursor")
elseif (e.scancode == config.input["left"] or e.scancode == "left") or elseif e.input == "left" or e.input == "right" or e.scancode == "left" or e.scancode == "right" then
(e.scancode == config.input["right"] or e.scancode == "right") then
self:switchSelect() self:switchSelect()
playSE("cursor_lr") playSE("cursor_lr")
elseif e.scancode == "escape" then elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
scene = TitleScene() scene = TitleScene()
end end
end end

View File

@@ -57,17 +57,17 @@ 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") 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)
playSE("cursor") playSE("cursor")
elseif (e.scancode == config.input["down"] or e.scancode == "down") and e.isRepeat == false then elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1) self:changeOption(1)
playSE("cursor") playSE("cursor")
elseif e.scancode == "escape" and e.isRepeat == false then elseif e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete" then
love.event.quit() love.event.quit()
end end
end end

View File

@@ -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 = "X"
}
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)
@@ -194,6 +230,15 @@ function Grid:checkForBravo(cleared_row_count)
return true return true
end end
function Grid:checkStackHeight()
for i = 0, 23 do
for j = 0, 9 do
if self:isOccupied(j, i) then return 24 - i end
end
end
return 0
end
function Grid:checkSecretGrade() function Grid:checkSecretGrade()
local sgrade = 0 local sgrade = 0
for i=23,5,-1 do for i=23,5,-1 do
@@ -216,7 +261,7 @@ function Grid:checkSecretGrade()
if(validLine) then if(validLine) then
sgrade = sgrade + 1 sgrade = sgrade + 1
else else
-- return sgrade return sgrade
end end
end end
--[[ --[[
@@ -239,14 +284,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
@@ -270,19 +319,45 @@ function Grid:draw()
end end
end end
function Grid:drawInvisible(opacity_function, garbage_opacity_function) function Grid:drawOutline()
for y = 1, 24 do for y = 5, 24 do
for x = 1, 10 do
if self.grid[y][x] ~= empty then
love.graphics.setColor(0.8, 0.8, 0.8, 1)
love.graphics.setLineWidth(1)
if y > 1 and self.grid[y-1][x] == empty then
love.graphics.line(48.0+x*16, -0.5+y*16, 64.0+x*16, -0.5+y*16)
end
if y < 24 and self.grid[y+1][x] == empty then
love.graphics.line(48.0+x*16, 16.5+y*16, 64.0+x*16, 16.5+y*16)
end
if x > 1 and self.grid[y][x-1] == empty then
love.graphics.line(47.5+x*16, -0.0+y*16, 47.5+x*16, 16.0+y*16)
end
if x < 10 and self.grid[y][x+1] == empty then
love.graphics.line(64.5+x*16, -0.0+y*16, 64.5+x*16, 16.0+y*16)
end
end
end
end
end
function Grid:drawInvisible(opacity_function, garbage_opacity_function, lock_flash, brightness)
lock_flash = lock_flash == nil and true or lock_flash
brightness = brightness == nil and 0.5 or brightness
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])
end end
love.graphics.setColor(0.5, 0.5, 0.5, opacity) love.graphics.setColor(brightness, brightness, brightness, opacity)
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)
if lock_flash then
if opacity > 0 and self.grid[y][x].colour ~= "X" then if opacity > 0 and self.grid[y][x].colour ~= "X" then
love.graphics.setColor(0.64, 0.64, 0.64) love.graphics.setColor(0.64, 0.64, 0.64)
love.graphics.setLineWidth(1) love.graphics.setLineWidth(1)
@@ -303,5 +378,6 @@ function Grid:drawInvisible(opacity_function, garbage_opacity_function)
end end
end end
end end
end
return Grid return Grid

View File

@@ -78,12 +78,15 @@ function Piece:setRelativeRotation(rot)
return self return self
end end
function Piece:moveInGrid(step, squares, grid) function Piece:moveInGrid(step, squares, grid, instant)
local moved = false local moved = false
for x = 1, squares do for x = 1, squares do
if grid:canPlacePiece(self:withOffset(step)) then if grid:canPlacePiece(self:withOffset(step)) then
moved = true moved = true
self:setOffset(step) self:setOffset(step)
if instant then
self:dropToBottom(grid)
end
else else
break break
end end
@@ -98,7 +101,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

View File

@@ -19,17 +19,15 @@ function MarathonA2Game: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,43 +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 self.grid:checkForBravo(cleared_lines) then self.bravo = 4 else self.bravo = 1 end 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) + 2 * drop_bonus) * (math.ceil((level + cleared_lines) / 4) + drop_bonus) *
cleared_lines * self.combo * self.bravo cleared_lines * self.combo * self.bravo
) )
self.lines = self.lines + cleared_lines
self.combo = self.combo + 2 * (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
@@ -224,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)
@@ -249,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
@@ -301,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.rollOpacityFunction, nil, false)
self.grid:drawInvisible(self.mRollOpacityFunction)
else
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
@@ -336,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")

View File

@@ -1,326 +0,0 @@
require 'funcs'
local GameMode = require 'tetris.modes.gamemode'
local Piece = require 'tetris.components.piece'
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls_35bag'
local SurvivalCKGame = GameMode:extend()
SurvivalCKGame.name = "Survival CK"
SurvivalCKGame.hash = "SurvivalCK"
SurvivalCKGame.tagline = "An endurance mode created by CylinderKnot! Watch out for the fading pieces..."
function SurvivalCKGame:new()
SurvivalCKGame.super:new()
self.garbage = 0
self.roll_frames = 0
self.combo = 1
self.grade = 0
self.level = 99
self.frames = 55 * 60
self.randomizer = History6RollsRandomizer()
self.enable_hold = true
self.next_queue_length = 3
self.coolregret_timer = 0
end
function SurvivalCKGame:getARE()
if self.level < 100 then return 15
elseif self.level < 200 then return 14
elseif self.level < 300 then return 13
elseif self.level < 400 then return 12
elseif self.level < 500 then return 11
elseif self.level < 600 then return 10
elseif self.level < 700 then return 9
elseif self.level < 800 then return 8
elseif self.level < 900 then return 7
elseif self.level < 1000 then return 6
elseif self.level < 2500 then return 5
else return 7 end
end
function SurvivalCKGame:getLineARE()
return SurvivalCKGame:getARE()
end
function SurvivalCKGame:getDasLimit()
if self.level < 700 then return 10
elseif self.level < 900 then return 9
elseif self.level < 1100 then return 8
elseif self.level < 1300 then return 7
elseif self.level < 1600 then return 6
else return 5 end
end
function SurvivalCKGame:getLineClearDelay()
if self.level < 100 then return 10
elseif self.level < 200 then return 8
elseif self.level < 300 then return 7
elseif self.level < 400 then return 6
else return 5 end
end
function SurvivalCKGame:getLockDelay()
if self.level < 600 then return 20
elseif self.level < 700 then return 19
elseif self.level < 800 then return 18
elseif self.level < 900 then return 17
elseif self.level < 1000 then return 16
elseif self.level < 1200 then return 15
elseif self.level < 1400 then return 14
elseif self.level < 1700 then return 13
elseif self.level < 2100 then return 12
elseif self.level < 2200 then return 11
elseif self.level < 2300 then return 10
elseif self.level < 2400 then return 9
elseif self.level < 2500 then return 8
else return 15 end
end
function SurvivalCKGame:getGravity()
return 20
end
function SurvivalCKGame:getGarbageLimit()
if self.level < 1000 then return 20
elseif self.level < 1100 then return 17
elseif self.level < 1200 then return 14
elseif self.level < 1300 then return 11
else return 8 end
end
function SurvivalCKGame:getRegretTime()
if self.level < 500 then return frameTime(0,55)
elseif self.level < 1000 then return frameTime(0,50)
elseif self.level < 1500 then return frameTime(0,40)
elseif self.level < 2000 then return frameTime(0,35)
else return frameTime(0,30) end
end
function SurvivalCKGame:getNextPiece(ruleset)
return {
skin = self.level >= 2000 and "bone" or "2tie",
shape = self.randomizer:nextPiece(),
orientation = ruleset:getDefaultOrientation(),
}
end
local torikan_times = {300, 330, 360, 390, 420, 450, 478, 504, 528, 550, 570}
function SurvivalCKGame:hitTorikan(old_level, new_level)
for i = 1, 11 do
if old_level < (900 + i * 100) and new_level >= (900 + i * 100) and self.frames > torikan_times[i] * 60 then
self.level = 900 + i * 100
return true
end
end
return false
end
function SurvivalCKGame:advanceOneFrame()
if self.clear then
self.roll_frames = self.roll_frames + 1
if self.roll_frames < 0 then
if self.roll_frames + 1 == 0 then
switchBGM("credit_roll", "gm3")
return true
end
return false
elseif self.roll_frames > 3238 then
switchBGM(nil)
if self.grade ~= 20 then self.grade = self.grade + 1 end
self.completed = true
end
elseif self.ready_frames == 0 then
self.frames = self.frames + 1
end
return true
end
function SurvivalCKGame:onPieceEnter()
if (self.level % 100 ~= 99) and not self.clear and self.frames ~= 0 then
self.level = self.level + 1
end
end
function SurvivalCKGame:onLineClear(cleared_row_count)
if not self.clear then
local new_level = self.level + cleared_row_count * 2
self:updateSectionTimes(self.level, new_level)
if new_level >= 2500 or self:hitTorikan(self.level, new_level) then
self.clear = true
if new_level >= 2500 then
self.level = 2500
self.grid:clear()
self.big_mode = true
self.roll_frames = -150
end
else
self.level = math.min(new_level, 2500)
end
self:advanceBottomRow(-cleared_row_count)
end
end
function SurvivalCKGame:onPieceLock(piece, cleared_row_count)
if cleared_row_count == 0 then self:advanceBottomRow(1) end
end
function SurvivalCKGame: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
function SurvivalCKGame:updateSectionTimes(old_level, new_level)
if math.floor(old_level / 100) < math.floor(new_level / 100) then
local section = math.floor(old_level / 100) + 1
section_time = self.frames - self.section_start_time
table.insert(self.section_times, section_time)
self.section_start_time = self.frames
if section_time <= self:getRegretTime(self.level) then
self.grade = self.grade + 1
else
self.coolregret_message = "REGRET!!"
self.coolregret_timer = 300
end
end
end
function SurvivalCKGame:advanceBottomRow(dx)
if self.level >= 1000 and self.level < 1500 then
self.garbage = math.max(self.garbage + dx, 0)
if self.garbage >= self:getGarbageLimit() then
self.grid:copyBottomRow()
self.garbage = 0
end
end
end
function SurvivalCKGame:drawGrid()
if self.level >= 1500 and self.level < 1600 then
self.grid:drawInvisible(self.rollOpacityFunction1)
elseif self.level >= 1600 and self.level < 1700 then
self.grid:drawInvisible(self.rollOpacityFunction2)
elseif self.level >= 1700 and self.level < 1800 then
self.grid:drawInvisible(self.rollOpacityFunction3)
elseif self.level >= 1800 and self.level < 1900 then
self.grid:drawInvisible(self.rollOpacityFunction4)
elseif self.level >= 1900 and self.level < 2000 then
self.grid:drawInvisible(self.rollOpacityFunction5)
else
self.grid:draw()
end
end
-- screw trying to make this work efficiently
-- lua function variables are so garbage
SurvivalCKGame.rollOpacityFunction1 = function(age)
if age < 420 then return 1
elseif age > 480 then return 0
else return 1 - (age - 420) / 60 end
end
SurvivalCKGame.rollOpacityFunction2 = function(age)
if age < 360 then return 1
elseif age > 420 then return 0
else return 1 - (age - 360) / 60 end
end
SurvivalCKGame.rollOpacityFunction3 = function(age)
if age < 300 then return 1
elseif age > 360 then return 0
else return 1 - (age - 300) / 60 end
end
SurvivalCKGame.rollOpacityFunction4 = function(age)
if age < 240 then return 1
elseif age > 300 then return 0
else return 1 - (age - 240) / 60 end
end
SurvivalCKGame.rollOpacityFunction5 = function(age)
if age < 180 then return 1
elseif age > 240 then return 0
else return 1 - (age - 180) / 60 end
end
local master_grades = { "M", "MK", "MV", "MO", "MM" }
function SurvivalCKGame:getLetterGrade()
if self.grade == 0 then
return "1"
elseif self.grade < 10 then
return "S" .. tostring(self.grade)
elseif self.grade < 21 then
return "m" .. tostring(self.grade - 9)
elseif self.grade < 26 then
return master_grades[self.grade - 20]
else
return "GM"
end
end
function SurvivalCKGame:drawScoringInfo()
SurvivalCKGame.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("GRADE", text_x, 120, 40, "left")
love.graphics.printf("SCORE", text_x, 200, 40, "left")
love.graphics.printf("LEVEL", text_x, 320, 40, "left")
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
self:drawSectionTimesWithSplits(current_section)
love.graphics.setFont(font_3x5_3)
love.graphics.printf(self:getLetterGrade(self.grade), text_x, 140, 90, "left")
love.graphics.printf(self.score, text_x, 220, 90, "left")
love.graphics.printf(self.level, text_x, 340, 50, "right")
if self.clear then
love.graphics.printf(self.level, text_x, 370, 50, "right")
else
love.graphics.printf(math.floor(self.level / 100 + 1) * 100, text_x, 370, 50, "right")
end
end
function SurvivalCKGame:getHighscoreData()
return {
grade = self:getLetterGrade(),
level = self.level,
frames = self.frames,
}
end
function SurvivalCKGame:getSectionEndLevel()
return math.floor(self.level / 100 + 1) * 100
end
function SurvivalCKGame:getBackground()
return math.min(math.floor(self.level / 100), 19)
end
return SurvivalCKGame

View File

@@ -1,265 +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
if math.random() < 1/6.66 then
self.rpc_details = "Suffering"
end
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)
self.skip_failed = true
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
else
self.level = math.min(new_level, 2500)
if self.skip_failed and new_level >= 500 then
self.level = 500
self.game_over = true
end
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")
if self.grade ~= 0 then love.graphics.printf("GRADE", 240, 120, 40, "left") end
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.min(math.floor(self.level / 100), 19)
end
return DemonModeGame

View File

@@ -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,7 +43,14 @@ 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.irs = true
self.ihs = true
self.rpc_details = "In game" self.rpc_details = "In game"
self.SGnames = {
"9", "8", "7", "6", "5", "4", "3", "2", "1",
"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
"GM"
}
-- 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
@@ -91,10 +101,20 @@ function GameMode:update(inputs, ruleset)
if self.completed then return end if self.completed then return end
-- advance one frame -- advance one frame
if self:advanceOneFrame(inputs) == false then return end if self:advanceOneFrame(inputs, ruleset) == false then return end
self:chargeDAS(inputs, self:getDasLimit(), self.getARR()) self:chargeDAS(inputs, self:getDasLimit(), self.getARR())
-- set attempt flags
if inputs["left"] or inputs["right"] then self:onAttemptPieceMove(self.piece) end
if
inputs["rotate_left"] or inputs["rotate_right"] or
inputs["rotate_left2"] or inputs["rotate_right2"] or
inputs["rotate_180"]
then
self:onAttemptPieceRotate(self.piece)
end
if self.piece == nil then if self.piece == nil then
self:processDelays(inputs, ruleset) self:processDelays(inputs, ruleset)
else else
@@ -102,7 +122,7 @@ function GameMode:update(inputs, ruleset)
self:whilePieceActive() self:whilePieceActive()
local gravity = self:getGravity() local gravity = self:getGravity()
if self.enable_hold and inputs["hold"] == true and self.held == false then if self.enable_hold and inputs["hold"] == true and self.held == false and self.prev_inputs["hold"] == false then
self:hold(inputs, ruleset) self:hold(inputs, ruleset)
self.prev_inputs = inputs self.prev_inputs = inputs
return return
@@ -161,6 +181,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
@@ -194,8 +215,14 @@ end
-- event functions -- event functions
function GameMode:whilePieceActive() end function GameMode:whilePieceActive() end
function GameMode:onPieceLock(piece, cleared_row_count) end function GameMode:onAttemptPieceMove(piece) end
function GameMode:onAttemptPieceRotate(piece) 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() end
@@ -211,8 +238,25 @@ function GameMode:onGameOver()
switchBGM(nil) switchBGM(nil)
end end
function GameMode:chargeDAS(inputs) -- DAS functions
if inputs[self.das.direction] == true then
function GameMode:startRightDAS()
self.move = "right"
self.das = { direction = "right", frames = 0 }
if self:getDasLimit() == 0 then
self:continueDAS()
end
end
function GameMode:startLeftDAS()
self.move = "left"
self.das = { direction = "left", frames = 0 }
if self:getDasLimit() == 0 then
self:continueDAS()
end
end
function GameMode:continueDAS()
local das_frames = self.das.frames + 1 local das_frames = self.das.frames + 1
if das_frames >= self:getDasLimit() then if das_frames >= self:getDasLimit() then
if self.das.direction == "left" then if self.das.direction == "left" then
@@ -226,34 +270,89 @@ function GameMode:chargeDAS(inputs)
self.move = "none" self.move = "none"
self.das.frames = das_frames self.das.frames = das_frames
end end
elseif inputs["right"] == true then end
self.move = "right"
self.das = { direction = "right", frames = 0 } function GameMode:stopDAS()
elseif inputs["left"] == true then
self.move = "left"
self.das = { direction = "left", frames = 0 }
else
self.move = "none" self.move = "none"
self.das = { direction = "none", frames = -1 } self.das = { direction = "none", frames = -1 }
end end
function GameMode:chargeDAS(inputs)
if config["das_last_key"] then
if inputs["right"] == true and self.das.direction ~= "right" and not self.prev_inputs["right"] then
self:startRightDAS()
elseif inputs["left"] == true and self.das.direction ~= "left" and not self.prev_inputs["left"] then
self:startLeftDAS()
elseif inputs[self.das.direction] == true then
self:continueDAS()
else
self:stopDAS()
end
else -- default behaviour, das first key pressed
if inputs[self.das.direction] == true then
self:continueDAS()
elseif inputs["right"] == true then
self:startRightDAS()
elseif inputs["left"] == true then
self:startLeftDAS()
else
self:stopDAS()
end
end
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
elseif self.lcd > 0 then elseif self.lcd > 0 then
self.lcd = self.lcd - 1 self.lcd = self.lcd - 1
if ruleset.are_cancel and
(self.move == "none" and not self.prev_inputs["up"] and
not self.prev_inputs["rotate_left"] and not self.prev_inputs["rotate_left2"] and
not self.prev_inputs["rotate_right"] and not self.prev_inputs["rotate_right2"] and
not self.prev_inputs["rotate_180"]) and
(inputs["left"] or inputs["right"] or inputs["up"] or
inputs["rotate_left"] or inputs["rotate_left2"] or
inputs["rotate_right"] or inputs["rotate_right2"] or
inputs["rotate_180"]) then
self.lcd = 0
self.are = 0
end
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
end end
elseif self.are > 0 then elseif self.are > 0 then
self.are = self.are - 1 self.are = self.are - 1
if ruleset.are_cancel and
(self.move == "none" and not self.prev_inputs["up"] and
not self.prev_inputs["rotate_left"] and not self.prev_inputs["rotate_left2"] and
not self.prev_inputs["rotate_right"] and not self.prev_inputs["rotate_right2"] and
not self.prev_inputs["rotate_180"]) and
(inputs["left"] or inputs["right"] or inputs["up"] or
inputs["rotate_left"] or inputs["rotate_left2"] or
inputs["rotate_right"] or inputs["rotate_right2"] or
inputs["rotate_180"]) then
self.are = 0
end
if self.are == 0 then if self.are == 0 then
self:initializeOrHold(inputs, ruleset) self:initializeOrHold(inputs, ruleset)
end end
@@ -261,8 +360,8 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
end end
function GameMode:initializeOrHold(inputs, ruleset) function GameMode:initializeOrHold(inputs, ruleset)
if self.enable_hold and inputs["hold"] == true then if self.ihs and self.enable_hold and inputs["hold"] == true then
self:hold(inputs, ruleset) self:hold(inputs, ruleset, true)
else else
self:initializeNextPiece(inputs, ruleset, self.next_queue[1]) self:initializeNextPiece(inputs, ruleset, self.next_queue[1])
end end
@@ -273,7 +372,7 @@ function GameMode:initializeOrHold(inputs, ruleset)
end end
end end
function GameMode:hold(inputs, ruleset) function GameMode:hold(inputs, ruleset, ihs)
local data = copy(self.hold_queue) local data = copy(self.hold_queue)
if self.piece == nil then if self.piece == nil then
self.hold_queue = self.next_queue[1] self.hold_queue = self.next_queue[1]
@@ -292,6 +391,8 @@ function GameMode:hold(inputs, ruleset)
self:initializeNextPiece(inputs, ruleset, data, false) self:initializeNextPiece(inputs, ruleset, data, false)
end end
self.held = true self.held = true
if ihs then playSE("ihs")
else playSE("hold") end
self:onHold() self:onHold()
end end
@@ -301,7 +402,8 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next
inputs, piece_data, self.grid, gravity, inputs, piece_data, self.grid, gravity,
self.prev_inputs, self.move, self.prev_inputs, self.move,
self:getLockDelay(), self:getDropSpeed(), self:getLockDelay(), self:getDropSpeed(),
self.lock_drop, self.lock_hard_drop, self.big_mode self.lock_drop, self.lock_hard_drop, self.big_mode,
self.irs
) )
if self.lock_drop then if self.lock_drop then
self.drop_locked = true self.drop_locked = true
@@ -313,7 +415,7 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next
table.remove(self.next_queue, 1) table.remove(self.next_queue, 1)
table.insert(self.next_queue, self:getNextPiece(ruleset)) table.insert(self.next_queue, self:getNextPiece(ruleset))
end end
self:playNextSound() if config.gamesettings.next_se == 1 then self:playNextSound() end
end end
function GameMode:playNextSound() function GameMode:playNextSound()
@@ -365,8 +467,9 @@ function GameMode:drawNextQueue(ruleset)
drawPiece(next_piece, skin, ruleset.block_offsets[next_piece][rotation], -16+i*80, -32) drawPiece(next_piece, skin, ruleset.block_offsets[next_piece][rotation], -16+i*80, -32)
end end
end end
if self.hold_queue ~= nil then if self.hold_queue ~= nil and self.enable_hold 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,
@@ -377,8 +480,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)
@@ -413,6 +524,10 @@ function GameMode:drawSectionTimes(current_section)
love.graphics.printf(formatTime(self.frames - self.section_start_time), section_x, 40 + 20 * current_section, 90, "left") love.graphics.printf(formatTime(self.frames - self.section_start_time), section_x, 40 + 20 * current_section, 90, "left")
end end
function GameMode:sectionColourFunction(section)
return { 1, 1, 1, 1 }
end
function GameMode:drawSectionTimesWithSecondary(current_section) function GameMode:drawSectionTimesWithSecondary(current_section)
local section_x = 530 local section_x = 530
local section_secondary_x = 440 local section_secondary_x = 440
@@ -424,9 +539,11 @@ function GameMode:drawSectionTimesWithSecondary(current_section)
end end
for section, time in pairs(self.secondary_section_times) do for section, time in pairs(self.secondary_section_times) do
love.graphics.setColor(self:sectionColourFunction(section))
if section > 0 then if section > 0 then
love.graphics.printf(formatTime(time), section_secondary_x, 40 + 20 * section, 90, "left") love.graphics.printf(formatTime(time), section_secondary_x, 40 + 20 * section, 90, "left")
end end
love.graphics.setColor(1, 1, 1, 1)
end end
local current_x local current_x

View File

@@ -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

View File

@@ -1,190 +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]
if self.grid:checkForBravo(cleared_row_count) 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.floor(self.level / 100)
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")
love.graphics.setColor(1, 1, 1, 1)
if self.last_bonus_display_time > 0 then
love.graphics.printf("+"..formatTime(self.last_bonus_amount), 240, 160, 120, "right")
end
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

View File

@@ -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()
@@ -142,6 +144,7 @@ function Marathon2020Game:advanceOneFrame()
if self.roll_frames < 0 then if self.roll_frames < 0 then
return false return false
elseif self.roll_frames > 4000 then elseif self.roll_frames > 4000 then
if self.grade >= 30 and self.section_cool_count >= 20 then self.grade = 31 end
self.completed = true self.completed = true
end end
elseif self.ready_frames == 0 then elseif self.ready_frames == 0 then
@@ -246,6 +249,7 @@ function Marathon2020Game:updateGrade(cleared_lines)
end end
function Marathon2020Game:getTotalGrade() function Marathon2020Game:getTotalGrade()
if self.grade + self.section_cool_count > 50 then return "GM" end
return self.grade + self.section_cool_count return self.grade + self.section_cool_count
end end
@@ -323,10 +327,11 @@ function Marathon2020Game:checkClear(level)
end end
function Marathon2020Game:updateSectionTimes(old_level, new_level) function Marathon2020Game:updateSectionTimes(old_level, new_level)
function sectionCool() function sectionCool(section)
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") if section < 10 then table.insert(self.section_status, "cool") end
self.cool_timer = 300
end end
local section = getSectionForLevel(old_level) local section = getSectionForLevel(old_level)
@@ -343,7 +348,7 @@ function Marathon2020Game: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
if section > 4 then self.delay_level = math.min(20, self.delay_level + 1) end if section > 5 then self.delay_level = math.min(20, self.delay_level + 1) end
self:checkTorikan(section) self:checkTorikan(section)
self:checkClear(new_level) self:checkClear(new_level)
@@ -352,11 +357,11 @@ function Marathon2020Game:updateSectionTimes(old_level, new_level)
self.secondary_section_times[section] < self.secondary_section_times[section - 1] + 120 and self.secondary_section_times[section] < self.secondary_section_times[section - 1] + 120 and
self.secondary_section_times[section] < cool_cutoffs[section] self.secondary_section_times[section] < cool_cutoffs[section]
) then ) then
sectionCool() sectionCool(section)
elseif self.section_status[section - 1] == "cool" then elseif self.section_status[section - 1] == "cool" then
table.insert(self.section_status, "none") table.insert(self.section_status, "none")
elseif section <= 19 and self.secondary_section_times[section] < cool_cutoffs[section] then elseif section <= 19 and self.secondary_section_times[section] < cool_cutoffs[section] then
sectionCool() sectionCool(section)
else else
table.insert(self.section_status, "none") table.insert(self.section_status, "none")
end end
@@ -389,7 +394,6 @@ Marathon2020Game.mRollOpacityFunction = function(age)
end end
function Marathon2020Game:qualifiesForMRoll() function Marathon2020Game:qualifiesForMRoll()
return false -- until I actually have grading working
--[[ --[[
GM-roll requirements GM-roll requirements
@@ -400,6 +404,8 @@ You qualify for the GM roll if you:
- in less than 13:30.00 total. - in less than 13:30.00 total.
]]-- ]]--
return self.level >= 2020 and self:getTotalGrade() == 50 and self.frames <= frameTime(13,30)
end end
function Marathon2020Game:drawGrid() function Marathon2020Game:drawGrid()
@@ -417,6 +423,14 @@ function Marathon2020Game:drawGrid()
end end
end end
function Marathon2020Game:sectionColourFunction(section)
if self.section_status[section] == "cool" then
return { 0, 1, 0, 1 }
else
return { 1, 1, 1, 1 }
end
end
function Marathon2020Game:drawScoringInfo() function Marathon2020Game:drawScoringInfo()
Marathon2020Game.super.drawScoringInfo(self) Marathon2020Game.super.drawScoringInfo(self)
@@ -430,6 +444,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")

View File

@@ -137,15 +137,15 @@ 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 if self.grid:checkForBravo(cleared_lines) then
self.bravo = 4 self.bravo = 4
self.bravos = self.bravos + 1 self.bravos = self.bravos + 1
@@ -156,25 +156,25 @@ function MarathonA1Game:updateScore(level, drop_bonus, cleared_lines)
(math.ceil((level + cleared_lines) / 4) + drop_bonus) * (math.ceil((level + cleared_lines) / 4) + drop_bonus) *
cleared_lines * self.combo * self.bravo 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
@@ -210,7 +210,7 @@ function MarathonA1Game:drawScoringInfo()
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")

View File

@@ -33,9 +33,8 @@ function MarathonA2Game:new()
"GM" "GM"
} }
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
@@ -109,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
@@ -127,33 +127,33 @@ function MarathonA2Game:onPieceEnter()
end end
end end
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)
if self.level == 999 and not self.clear then
self.clear = true
if self:qualifiesForMRoll() then
self.grade = 32
end
self.grid:clear()
self.roll_frames = -150
end
end
function MarathonA2Game:updateScore(level, drop_bonus, cleared_lines) function MarathonA2Game:updateScore(level, drop_bonus, cleared_lines)
if not self.clear then
self:updateGrade(cleared_lines) self:updateGrade(cleared_lines)
if self.grid:checkForBravo(cleared_lines) then self.bravo = 4 else self.bravo = 1 end 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) + 2 * drop_bonus) * (math.ceil((level + cleared_lines) / 4) + drop_bonus) *
cleared_lines * self.combo * self.bravo 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
else self.lines = self.lines + cleared_lines end
end
function MarathonA2Game:onLineClear(cleared_row_count)
self.level = math.min(self.level + cleared_row_count, 999)
if self.level == 999 and not self.clear then
self.clear = true
self.grid:clear()
if self:qualifiesForMRoll() then self.grade = 32 end
self.roll_frames = -150
end
self.lock_drop = self.level >= 900
self.lock_hard_drop = self.level >= 900
end end
function MarathonA2Game:updateSectionTimes(old_level, new_level) function MarathonA2Game:updateSectionTimes(old_level, new_level)
@@ -253,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
@@ -280,7 +280,7 @@ function MarathonA2Game:qualifiesForMRoll()
return false return false
end end
end end
if self.grade < 17 or self.frames > frameTime(9,30) then if self.grade < 31 or self.frames > frameTime(8,45) then
return false return false
end end
return true return true
@@ -310,12 +310,12 @@ MarathonA2Game.mRollOpacityFunction = function(age)
else return 1 - age / 4 end else return 1 - age / 4 end
end end
function MarathonA2Game:drawGrid(ruleset) function MarathonA2Game:drawGrid()
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 if self:qualifiesForMRoll() then
self.grid:drawInvisible(self.mRollOpacityFunction) self.grid:drawInvisible(self.mRollOpacityFunction, nil, false)
else else
self.grid:drawInvisible(self.rollOpacityFunction) self.grid:drawInvisible(self.rollOpacityFunction, nil, false)
end end
else else
self.grid:draw() self.grid:draw()
@@ -344,7 +344,17 @@ function MarathonA2Game:drawScoringInfo()
end 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")

View File

@@ -29,6 +29,7 @@ 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()
@@ -45,6 +46,8 @@ self.SGnames = {
self.coolregret_message = "COOL!!" self.coolregret_message = "COOL!!"
self.coolregret_timer = 0 self.coolregret_timer = 0
self.torikan_passed = false
end end
function MarathonA3Game:getARE() function MarathonA3Game:getARE()
@@ -149,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
@@ -166,7 +170,7 @@ function MarathonA3Game:onLineClear(cleared_row_count)
self.grid:clear() self.grid:clear()
self.roll_frames = -150 self.roll_frames = -150
end end
if self.level >= 500 and self.frames >= 25200 then if not self.torikan_passed and self.level >= 500 and self.frames >= 25200 then
self.level = 500 self.level = 500
self.game_over = true self.game_over = true
end end
@@ -192,49 +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")
self.coolregret_message = "REGRET!!" self.coolregret_message = "REGRET!!"
self.coolregret_timer = 300 self.coolregret_timer = 300
elseif section <= 9 and self.section_status[section - 1] == "cool" and elseif self.section_cool then
self.section_70_times[section] < self.section_70_times[section - 1] + 120 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") table.insert(self.section_status, "cool")
self.coolregret_message = "COOL!!"
self.coolregret_timer = 300
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")
self.coolregret_message = "COOL!!"
self.coolregret_timer = 300
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)
self:updateGrade(cleared_lines) self:updateGrade(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
local grade_point_bonuses = { local grade_point_bonuses = {
@@ -353,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
@@ -427,7 +438,7 @@ 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 if(self.coolregret_timer > 0) then
love.graphics.printf(self.coolregret_message, 64, 400, 160, "center") love.graphics.printf(self.coolregret_message, 64, 400, 160, "center")
@@ -436,7 +447,10 @@ function MarathonA3Game:drawScoringInfo()
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.level >= 999 and 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 if sg >= 5 then

View File

@@ -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
@@ -144,7 +146,7 @@ function MarathonAX4Game: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("TIME LEFT", 240, 250, 80, "left") if self.lines < 150 then love.graphics.printf("TIME LEFT", 240, 250, 80, "left") end
love.graphics.printf("LINES", 240, 320, 40, "left") love.graphics.printf("LINES", 240, 320, 40, "left")
local current_section = math.floor(self.lines / 10) + 1 local current_section = math.floor(self.lines / 10) + 1
@@ -159,7 +161,7 @@ function MarathonAX4Game:drawScoringInfo()
if not self.game_over and not self.clear and time_left < frameTime(0,10) and time_left % 4 < 2 then 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) love.graphics.setColor(1, 0.3, 0.3, 1)
end end
love.graphics.printf(formatTime(time_left), 240, 270, 160, "left") if self.lines < 150 then love.graphics.printf(formatTime(time_left), 240, 270, 160, "left") end
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
end end

View File

@@ -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

View File

@@ -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

View File

@@ -15,6 +15,7 @@ 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 = { self.SGnames = {
@@ -117,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)
@@ -137,7 +139,7 @@ end
function PhantomManiaGame:drawGrid() function PhantomManiaGame:drawGrid()
if not (self.game_over or self.clear) then if not (self.game_over or self.clear) then
self.grid:drawInvisible(self.rollOpacityFunction) self.grid:drawInvisible(self.rollOpacityFunction, nil, false)
else else
self.grid:draw() self.grid:draw()
end end

View File

@@ -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
@@ -36,8 +35,12 @@ function PhantomMania2Game: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
self.coolregret_message = ""
self.coolregret_timer = 0
end end
function PhantomMania2Game:getARE() function PhantomMania2Game:getARE()
@@ -122,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
@@ -143,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
@@ -162,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
@@ -171,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
@@ -213,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
@@ -240,7 +255,7 @@ PhantomMania2Game.garbageOpacityFunction = function(age)
end end
function PhantomMania2Game:drawGrid() function PhantomMania2Game:drawGrid()
if not (self.game_over or (self.clear and self.level < 1300)) then if not (self.game_over) then
self.grid:drawInvisible(self.rollOpacityFunction, self.garbageOpacityFunction) self.grid:drawInvisible(self.rollOpacityFunction, self.garbageOpacityFunction)
else else
self.grid:draw() self.grid:draw()
@@ -276,7 +291,7 @@ function PhantomMania2Game:setHoldOpacity()
if self.level > 1000 and self.level < 1300 then if self.level > 1000 and self.level < 1300 then
love.graphics.setColor(1, 1, 1, 1 - math.min(1, self.hold_age / 15)) love.graphics.setColor(1, 1, 1, 1 - math.min(1, self.hold_age / 15))
else else
love.graphics.setColor(1, 1, 1, 1) self.super:setHoldOpacity(1, self.held and 0.6 or 1)
end end
end end
@@ -296,6 +311,13 @@ function PhantomMania2Game:drawScoringInfo()
love.graphics.printf("SECRET GRADE", 240, 430, 180, "left") love.graphics.printf("SECRET GRADE", 240, 430, 180, "left")
end 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")
love.graphics.printf(self.score, text_x, 220, 90, "left") love.graphics.printf(self.score, text_x, 220, 90, "left")

View File

@@ -1,129 +0,0 @@
require 'funcs'
local GameMode = require 'tetris.modes.gamemode'
local Piece = require 'tetris.components.piece'
local Bag7Randomiser = require 'tetris.randomizers.bag7noSZOstart'
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 = Bag7Randomiser()
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

View File

@@ -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

View File

@@ -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)

View File

@@ -109,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
@@ -118,35 +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 if self.grid:checkForBravo(cleared_lines) then
self.bravo = 4 self.bravo = 4
self.bravos = self.bravos + 1 self.bravos = self.bravos + 1
else self.bravo = 1 end 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 * self.bravo * 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
@@ -179,7 +180,7 @@ function SurvivalA1Game:drawScoringInfo()
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")

View File

@@ -27,6 +27,7 @@ function SurvivalA2Game:new()
} }
self.lock_drop = true self.lock_drop = true
self.lock_hard_drop = true
end end
function SurvivalA2Game:getARE() function SurvivalA2Game:getARE()
@@ -88,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
@@ -108,18 +109,19 @@ 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 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 * self.bravo * 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()
@@ -156,7 +158,10 @@ function SurvivalA2Game: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")
if self.roll_frames > 2968 then love.graphics.setColor(1, 0.5, 0, 1)
elseif self.level >= 999 and self.clear then love.graphics.setColor(0, 1, 0, 1) end
if self:getLetterGrade() ~= "" then love.graphics.printf(self:getLetterGrade(), text_x, 140, 90, "left") end if self:getLetterGrade() ~= "" then love.graphics.printf(self:getLetterGrade(), text_x, 140, 90, "left") end
love.graphics.setColor(1, 1, 1, 1)
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 if sg >= 5 then

View File

@@ -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
@@ -32,6 +29,7 @@ function SurvivalA3Game:new()
} }
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
@@ -140,7 +138,6 @@ 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
@@ -164,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)
@@ -243,7 +242,10 @@ function SurvivalA3Game:drawScoringInfo()
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.level >= 1300 and 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

View File

@@ -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

View File

@@ -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

View File

@@ -1,24 +0,0 @@
local Randomizer = require 'tetris.randomizers.randomizer'
local Bag7Randomizer = Randomizer:extend()
function Bag7Randomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
self.extra = {"I", "J", "L", "O", "S", "T", "Z"}
table.insert(self.bag, table.remove(self.extra, math.random(table.getn(self.extra))))
end
function Bag7Randomizer:generatePiece()
if next(self.extra) == nil then
self.extra = {"I", "J", "L", "O", "S", "T", "Z"}
end
if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
table.insert(self.bag, table.remove(self.extra, math.random(table.getn(self.extra))))
end
local x = math.random(table.getn(self.bag))
--print("Bag: "..table.concat(self.bag, ", ").." | Extra: "..table.concat(self.extra, ", "))
return table.remove(self.bag, x)
end
return Bag7Randomizer

View File

@@ -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

View File

@@ -1,30 +0,0 @@
local Randomizer = require 'tetris.randomizers.randomizer'
local RecursiveRandomizer = Randomizer:extend()
function RecursiveRandomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
end
function RecursiveRandomizer:generatePiece()
--if next(self.bag) == nil then
-- self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
--end
local x = math.random(table.getn(self.bag) + 1)
while x == table.getn(self.bag) + 1 do
--print("Refill piece pulled")
table.insert(self.bag, "I")
table.insert(self.bag, "J")
table.insert(self.bag, "L")
table.insert(self.bag, "O")
table.insert(self.bag, "S")
table.insert(self.bag, "T")
table.insert(self.bag, "Z")
x = math.random(table.getn(self.bag) + 1)
end
--print("Number of pieces in bag: "..table.getn(self.bag))
--print("Bag: "..table.concat(self.bag, ", "))
return table.remove(self.bag, x)
end
return RecursiveRandomizer

View File

@@ -1,19 +0,0 @@
local Randomizer = require 'tetris.randomizers.randomizer'
local SegaRandomizer = Randomizer:extend()
function SegaRandomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
self.sequence = {}
for i = 1, 1000 do
self.sequence[i] = self.bag[math.random(table.getn(self.bag))]
end
self.counter = 0
end
function SegaRandomizer:generatePiece()
self.counter = self.counter + 1
return self.sequence[self.counter % 1000 + 1]
end
return SegaRandomizer

View File

@@ -97,11 +97,11 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid)
-- kick right, kick left -- kick right, kick left
if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
self:onPieceRotate(piece, 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})
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
end end
end end
@@ -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 3 end function ARS:get180RotationValue()
if config.gamesettings.world_reverse == 3 then
return 1
else
return 3
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

View File

@@ -1,5 +1,5 @@
local Piece = require 'tetris.components.piece' local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.ruleset' local Ruleset = require 'tetris.rulesets.arika_ti'
local ARS = Ruleset:extend() local ARS = Ruleset:extend()
@@ -39,137 +39,16 @@ ARS.big_spawn_positions = {
Z = { 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) function ARS:onPieceCreate(piece, grid)
piece.floorkick = 0 piece.floorkick = 0
piece.manipulations = 0 piece.manipulations = 0
end end
function ARS:onPieceDrop(piece, grid)
piece.lock_delay = 0 -- step reset
end
function ARS:onPieceMove(piece, grid) function ARS: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.manipulations = piece.manipulations + 1 piece.manipulations = piece.manipulations + 1
if piece.manipulations >= 127 then if piece.manipulations >= 128 then
piece.locked = true piece.locked = true
end end
end end
@@ -179,13 +58,13 @@ function ARS:onPieceRotate(piece, grid)
piece.lock_delay = 0 -- rotate reset piece.lock_delay = 0 -- rotate reset
if piece:isDropBlocked(grid) then if piece:isDropBlocked(grid) then
piece.manipulations = piece.manipulations + 1 piece.manipulations = piece.manipulations + 1
if piece.manipulations >= 127 then if piece.manipulations >= 128 then
piece.locked = true piece.locked = true
end end
end end
if piece.floorkick >= 1 then
piece.floorkick = piece.floorkick + 1
end
end end
function ARS:get180RotationValue() return 3 end
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
return ARS return ARS

View File

@@ -1,5 +1,5 @@
local Piece = require 'tetris.components.piece' local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.ruleset' local Ruleset = require 'tetris.rulesets.arika_ti'
local ARS = Ruleset:extend() local ARS = Ruleset:extend()
@@ -26,137 +26,16 @@ ARS.big_spawn_positions = {
Z = { 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) function ARS:onPieceCreate(piece, grid)
piece.floorkick = 0 piece.floorkick = 0
piece.manipulations = 0 piece.manipulations = 0
end end
function ARS:onPieceDrop(piece, grid)
piece.lock_delay = 0 -- step reset
end
function ARS:onPieceMove(piece, grid) function ARS: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.manipulations = piece.manipulations + 1 piece.manipulations = piece.manipulations + 1
if piece.manipulations >= 127 then if piece.manipulations >= 128 then
piece.locked = true piece.locked = true
end end
end end
@@ -166,13 +45,13 @@ function ARS:onPieceRotate(piece, grid)
piece.lock_delay = 0 -- rotate reset piece.lock_delay = 0 -- rotate reset
if piece:isDropBlocked(grid) then if piece:isDropBlocked(grid) then
piece.manipulations = piece.manipulations + 1 piece.manipulations = piece.manipulations + 1
if piece.manipulations >= 127 then if piece.manipulations >= 128 then
piece.locked = true piece.locked = true
end end
end end
if piece.floorkick >= 1 then
piece.floorkick = piece.floorkick + 1
end
end end
function ARS:get180RotationValue() return 3 end
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default
return ARS return ARS

View File

@@ -1,24 +1,10 @@
local Piece = require 'tetris.components.piece' local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.ruleset' local Ruleset = require 'tetris.rulesets.ti_srs'
local SRS = Ruleset:extend() local SRS = Ruleset:extend()
SRS.name = "ACE-SRS" SRS.name = "ACE-SRS"
SRS.hash = "ACE Standard" SRS.hash = "ACE 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.spawn_positions = { SRS.spawn_positions = {
I = { x=5, y=2 }, I = { x=5, y=2 },
@@ -40,137 +26,11 @@ SRS.big_spawn_positions = {
Z = { x=2, y=1 }, Z = { x=2, y=1 },
} }
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
end
function SRS:onPieceDrop(piece, grid)
piece.lock_delay = 0 -- step reset
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.manipulations = piece.manipulations + 1 piece.manipulations = piece.manipulations + 1
if piece.manipulations >= 127 then if piece.manipulations >= 128 then
piece.locked = true piece.locked = true
end end
end end
@@ -180,11 +40,10 @@ function SRS:onPieceRotate(piece, grid)
piece.lock_delay = 0 -- rotate reset piece.lock_delay = 0 -- rotate reset
if piece:isDropBlocked(grid) then if piece:isDropBlocked(grid) then
piece.manipulations = piece.manipulations + 1 piece.manipulations = piece.manipulations + 1
if piece.manipulations >= 127 then if piece.manipulations >= 128 then
piece.locked = true piece.locked = true
end end
end end
end end
function SRS:get180RotationValue() return 3 end
return SRS return SRS

View File

@@ -1,77 +1,11 @@
local Piece = require 'tetris.components.piece' local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.ruleset' local Ruleset = require 'tetris.rulesets.arika'
local ARS = Ruleset:extend() local ARS = Ruleset:extend()
ARS.name = "Ti-ARS" ARS.name = "Ti-ARS"
ARS.hash = "ArikaTI" ARS.hash = "ArikaTI"
ARS.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 },
}
ARS.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 },
}
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. -- Component functions.
function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid) function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid)
@@ -100,43 +34,48 @@ function ARS:attemptWallkicks(piece, new_piece, rot_dir, grid)
if piece.shape == "I" then if piece.shape == "I" then
-- special kick rules for I -- special kick rules for I
if new_piece.rotation == 0 or new_piece.rotation == 2 then if (new_piece.rotation == 0 or new_piece.rotation == 2) and
(piece:isMoveBlocked(grid, {x=-1, y=0}) or piece:isMoveBlocked(grid, {x=1, y=0})) then
-- kick right, right2, left -- kick right, right2, left
if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
self:onPieceRotate(piece, grid)
elseif grid:canPlacePiece(new_piece:withOffset({x=2, y=0})) then elseif grid:canPlacePiece(new_piece:withOffset({x=2, y=0})) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=2, y=0}) piece:setRelativeRotation(rot_dir):setOffset({x=2, y=0})
self:onPieceRotate(piece, 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})
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
end end
elseif piece:isDropBlocked(grid) and (new_piece.rotation == 1 or new_piece.rotation == 3) and piece.floorkick == 0 then elseif piece:isDropBlocked(grid) and (new_piece.rotation == 1 or new_piece.rotation == 3) and piece.floorkick == 0 then
-- kick up, up2 -- kick up, up2
if grid:canPlacePiece(new_piece:withOffset({x=0, y=-1})) then if grid:canPlacePiece(new_piece:withOffset({x=0, y=-1})) then
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1})
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1})
piece.floorkick = 1 piece.floorkick = 1
elseif grid:canPlacePiece(new_piece:withOffset({x=0, y=-2})) then elseif grid:canPlacePiece(new_piece:withOffset({x=0, y=-2})) then
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-2})
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-2})
piece.floorkick = 1 piece.floorkick = 1
end end
end end
else else
-- kick right, kick left -- kick right, kick left
if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then if grid:canPlacePiece(new_piece:withOffset({x=1, y=0})) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0}) piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then elseif grid:canPlacePiece(new_piece:withOffset({x=-1, y=0})) then
self:onPieceRotate(piece, grid)
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 == 0 and new_piece.rotation == 0
and piece.floorkick == 0 and piece.floorkick == 0
and piece:isDropBlocked(grid)
and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1})) and grid:canPlacePiece(new_piece:withOffset({x=0, y=-1}))
then then
-- T floorkick -- T floorkick
piece.floorkick = piece.floorkick + 1 piece.floorkick = piece.floorkick + 1
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1}) piece:setRelativeRotation(rot_dir):setOffset({x=0, y=-1})
end end
end end
@@ -149,9 +88,15 @@ end
function ARS:onPieceDrop(piece, grid) function ARS:onPieceDrop(piece, grid)
piece.lock_delay = 0 -- step reset piece.lock_delay = 0 -- step reset
if piece.floorkick >= 2 and piece:isDropBlocked(grid) then
piece.locked = true
end
end end
function ARS:get180RotationValue() return 3 end function ARS:onPieceRotate(piece, grid)
function ARS:getDefaultOrientation() return 3 end -- downward facing pieces by default if piece.floorkick >= 1 then
piece.floorkick = piece.floorkick + 1
end
end
return ARS return ARS

View File

@@ -384,9 +384,9 @@ function CRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
for idx, offset in pairs(kicks) do for idx, offset in pairs(kicks) do
kicked_piece = new_piece:withOffset(offset) kicked_piece = new_piece:withOffset(offset)
if grid:canPlacePiece(kicked_piece) then if grid:canPlacePiece(kicked_piece) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir) piece:setRelativeRotation(rot_dir)
piece:setOffset(offset) piece:setOffset(offset)
self:onPieceRotate(piece, grid)
return return
end end
end end

View File

@@ -21,9 +21,64 @@ Ruleset.softdrop_lock = true
Ruleset.harddrop_lock = false Ruleset.harddrop_lock = false
Ruleset.enable_IRS_wallkicks = false Ruleset.enable_IRS_wallkicks = false
Ruleset.are_cancel = 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 = {}
@@ -53,15 +108,15 @@ 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 self.world and config.gamesettings.world_reverse == 2 then if config.gamesettings.world_reverse == 3 or (self.world and config.gamesettings.world_reverse == 2) then
rot_dir = 4 - rot_dir rot_dir = 4 - rot_dir
end end
local new_piece = piece:withRelativeRotation(rot_dir) local new_piece = piece:withRelativeRotation(rot_dir)
if (grid:canPlacePiece(new_piece)) then if (grid:canPlacePiece(new_piece)) then
piece:setRelativeRotation(rot_dir)
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir)
else else
if not(initial and self.enable_IRS_wallkicks == false) then if not(initial and self.enable_IRS_wallkicks == false) then
self:attemptWallkicks(piece, new_piece, rot_dir, grid) self:attemptWallkicks(piece, new_piece, rot_dir, grid)
@@ -73,16 +128,16 @@ function Ruleset:attemptWallkicks(piece, new_piece, rot_dir, grid)
-- do nothing in default ruleset -- do nothing in default ruleset
end end
function Ruleset:movePiece(piece, grid, move) function Ruleset:movePiece(piece, grid, move, instant)
local x = piece.position.x local x = piece.position.x
if move == "left" then if move == "left" then
piece:moveInGrid({x=-1, y=0}, 1, grid) piece:moveInGrid({x=-1, y=0}, 1, grid, false)
elseif move == "speedleft" then
piece:moveInGrid({x=-1, y=0}, 10, grid)
elseif move == "right" then elseif move == "right" then
piece:moveInGrid({x=1, y=0}, 1, grid) piece:moveInGrid({x=1, y=0}, 1, grid, false)
elseif move == "speedleft" then
piece:moveInGrid({x=-1, y=0}, 10, grid, instant)
elseif move == "speedright" then elseif move == "speedright" then
piece:moveInGrid({x=1, y=0}, 10, grid) piece:moveInGrid({x=1, y=0}, 10, grid, instant)
end end
if piece.position.x ~= x then if piece.position.x ~= x then
self:onPieceMove(piece, grid) self:onPieceMove(piece, grid)
@@ -126,7 +181,7 @@ function Ruleset:getDefaultOrientation() return 1 end
function Ruleset:initializePiece( function Ruleset:initializePiece(
inputs, data, grid, gravity, prev_inputs, inputs, data, grid, gravity, prev_inputs,
move, lock_delay, drop_speed, move, lock_delay, drop_speed,
drop_locked, hard_drop_locked, big drop_locked, hard_drop_locked, big, irs
) )
local spawn_positions local spawn_positions
if big then if big then
@@ -142,7 +197,14 @@ function Ruleset:initializePiece(
}, self.block_offsets, 0, 0, data.skin, colours[data.shape], big) }, self.block_offsets, 0, 0, data.skin, colours[data.shape], big)
self:onPieceCreate(piece) self:onPieceCreate(piece)
if irs then
if inputs.rotate_left or inputs.rotate_left2 or
inputs.rotate_right or inputs.rotate_right2 or
inputs.rotate_180 then
playSE("irs")
end
self:rotatePiece(inputs, piece, grid, {}, true) self:rotatePiece(inputs, piece, grid, {}, true)
end
self:dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked) self:dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked)
return piece return piece
end end
@@ -156,8 +218,16 @@ function Ruleset:processPiece(
drop_locked, hard_drop_locked, drop_locked, hard_drop_locked,
hard_drop_enabled, additive_gravity hard_drop_enabled, additive_gravity
) )
local synchroes_allowed = ({not self.world, true, false})[config.gamesettings.synchroes_allowed]
if synchroes_allowed then
self:rotatePiece(inputs, piece, grid, prev_inputs, false) self:rotatePiece(inputs, piece, grid, prev_inputs, false)
self:movePiece(piece, grid, move) self:movePiece(piece, grid, move, gravity >= 20)
else
self:movePiece(piece, grid, move, gravity >= 20)
self:rotatePiece(inputs, piece, grid, prev_inputs, false)
end
self:dropPiece( self:dropPiece(
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked, inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
hard_drop_enabled, additive_gravity hard_drop_enabled, additive_gravity

Some files were not shown because too many files have changed in this diff Show More