# jminos

Modern stacker game with every polyominoes from size 1 to 15, made in C++ with [SFML 3](https://www.sfml-dev.org/)!

- [Download](#download)
- [How to play](#how-to-play)
- [Features](#features)
- [Manual build](#manual-build)
- [Benchmarks](#benchmarks)
- [Credits](#credits)

## Download

You can download the latest release [here](https://git.ale-pri.com/TetrisNerd/jminos/releases)!  
This game has been tested on Windows 11 and Linux, and releases are provided for theses two systems.  
If your OS isn't compatible, you can try [manually building the project](#manual-build).  

## How to play

Choose which pieces you want to play with and stack them up until you either win or top out!  
Make full lines to make them dissapear.  
Use the different spins to kick the pieces in spot you couldn't imagine were attaignable!  
Each gamemode has its own objective, but you can play as you wish.  

You can see and change in-game keybinds in the **SETTINGS** section of the main menu!  
All of in-menu navigation is done with the **arrow keys**, the **Enter key** and the **Escape key**. Theses are unchangeable keybinds.  
You will find more infos about the Rotation System, the scoring system, or the different pieces type in the **INFO** section of the main menu.  

## Features

- Every polyominoes up to pentedecaminoes!
- 7bag with proportionnality for each polyomino size!
- AutoRS as the Rotation System!
- 0° rotations!
- All spin!
- IRS, IHS, infinite hold, and other leniency mechanics!
- Customizable board size!
- Customizable keybinds!
- Very bland interface!! (i'm not a designer)

### Available gamemodes

- SPRINT : clear 40 lines as fast as possible!
- MARATHON : clear 200 lines with increasing gravity!
- ULTRA : scores as much as possible in only 2 minutes!
- MASTER : clear 200 lines at levels higher than maximum gravity!
- INVISIBLE : get 1000 grade while not being able to see the board!
- ZEN : practice indefinitely in this mode with no gravity!

### Screenshots

Pentedecamino jumpscare

![Screenshot1](./doc/readme/big_piece.png)

Pieces select screen

![Screenshot2](./doc/readme/pieces_selection.png)

AutoRS demonstration

![Video1](./doc/readme/rotations.gif)

0° spins demonstration

![Video2](./doc/readme/rotation_0.gif)

## Manual build

This project uses xmake for compiling, xmake is cross-platform and works in most OS, xmake also automatically install supported librairies.  
To be able to build this project, you need to [have xmake installed](https://xmake.io) and have a compiler with C++20 compatibility.  

If you want to contribute or are simply curious, you can check the [wiki](https://git.ale-pri.com/TetrisNerd/jminos/wiki)!  

### Build the project

``cd jminos``

``xmake``

If you need to change the toolchain (for example using gcc):  
``xmake f --toolchain=gcc``

If you want to build for another platform (for example with mingw):  
``xmake f -p mingw``

### Run the project

``xmake run``  

The program will generate the polyomino files for you if you don't have them.
As this is a lengthy process, debug mode limits pieces size to 10.
To switch between debug and release mode:  
``xmake f -m debug``  
``xmake f -m release``

If for some reasons you wanna run the command line version:  
``xmake build text``  
``xmake run text``  
The command line version is **not** updated.

### Package the project

To package the executable manually properly, follow theses steps:  

1. Clone the project into a new folder.
2. If you already have all 15 pieces files, copy them over to the ``data/pieces`` folder, else you will be generating them at the next step.
3. Go into release mode (``xmake f -m release``) and run the project once (``xmake`` and ``xmake run``). This is to generate the default config files, close the game immediately after it started.
4. Make a new folder named ``jminos`` and copy the executable (should be located somewhere like ``build/linux/x86_64/release/graph``) as well as the ``data/pieces`` and ``data/config`` folders.
5. Zip the newly created ``jminos`` folder into a file named ``jminos_{platform}``.

## Benchmarks

### One-sided n-polyominoes

| n | Number | Generation | File storing | File retrieving | File size |
| -: | -: | :-: | :-: | :-: | -: |
| 1 | 1 | 0s 0.006496ms | 0s 0.18186ms | 0s 0.064298ms | 3 bytes |
| 2 | 1 | 0s 0.003848ms | 0s 0.167537ms | 0s 0.013054ms | 3 bytes |
| 3 | 2 | 0s 0.010133ms | 0s 0.076844ms | 0s 0.011991ms | 6 bytes |
| 4 | 7 | 0s 0.027356ms | 0s 0.050884ms | 0s 0.016362ms | 22 bytes |
| 5 | 18 | 0s 0.082079ms | 0s 0.088215ms | 0s 0.015016ms | 63 bytes |
| 6 | 60 | 0s 0.292599ms | 0s 0.254024ms | 0s 0.034325ms | 201 bytes |
| 7 | 196 | 0s 1.15671ms | 0s 0.424141ms | 0s 0.061736ms | 538 bytes |
| 8 | 704 | 0s 7.32448ms | 0s 2.00197ms | 0s 0.161199ms | 1803 bytes |
| 9 | 2500 | 0s 23.1679ms | 0s 4.30285ms | 0s 0.496256ms | 6291 bytes |
| 10 | 9189 | 0s 76.8277ms | 0s 20.5346ms | 0s 1.99335ms | 22396 bytes |
| 11 | 33896 | 0s 292.303ms | 0s 84.7814ms | 0s 7.11621ms | 79040 bytes |
| 12 | 126759 | 1s 368.505ms | 0s 407.837ms | 0s 33.5164ms | 279497 bytes |
| 13 | 476270 | 5s 963.297ms | 1s 709.14ms | 0s 171.402ms | 1010672 bytes |
| 14 | 1802312 | 25s 319.931ms | 3s 853.451ms | 0s 580.736ms | 3750531 bytes |
| 15 | 6849777 | 102s 886.385ms | 21s 198.445ms | 1s 973.051ms | 14162217 bytes |

_File storing includes type checking and sorting all polyominoes before writing them to the file._  
The files are compressed, they used to be about 5x as large.  

Run it yourself by typing:  
``xmake f -m release``  
``xmake build bmark``  
``xmake run bmark``  

## Credits

Library used: [SFML 3](https://www.sfml-dev.org/).  
Font used: [Press Start](https://www.zone38.net/font/#pressstart).  

Inspired by other modern stacker games such as Techmino, jstris, tetr.io, etc.  
This game isn't affiliated with any of them.  

Special thanks to my friend [Simon](https://git.ale-pri.com/Persson-dev) who did most of the outside stuff (github actions, files compression, asset manager, xmake).  
All the code in src/Common/, src/Utils/ and xmake/ comes from him.  
