Recent

Author Topic: Fairtris — a fair implementation of Classic Tetris®  (Read 3565 times)

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Fairtris — a fair implementation of Classic Tetris®
« on: September 08, 2021, 09:21:17 pm »
What is Fairtris?

Fairtris is a video game, a clone of the 32-year-old Tetris® game produced by Nintendo for the Famicom and NES consoles, designed for modern Windows systems. Fairtris is not an emulator — it is a full-fledged game, created from scratch in Free Pascal language and with OpenGL support via the SDL library. Thanks to this combination, it is super-fast and ultra-light. This project was initially created as a tool to test various RNG algorithms, but after some time it turned into a complete and rich video game that provides lots of fun.

You can download the game here — Fairtris 2.0.0.5 beta 2 (for Windows Vista, 7, 8, 8.1 and 10).

Also check out the project repository and the rich Fairtris wiki pages. If you want, you can also join a Discord server and take an active part in discussions and testing of the latest version of the game.


Important features:
  • implementation of gameplay mechanics compatible with the Nintendo Tetris® game,
  • extended mechanics with hard-drop and accumulation of soft-drop points,
  • support for EIGHT regional versions of the game, including original NTSC and PAL versions,
  • support for as many as SIX random piece generators, including the classic RNG,
  • the ability to start the game from any level up to the killscreen,
  • the ability to play on a keyboard or any USB controller (with input mapping support),
  • supports window mode and the low-resolution exclusive video mode,
  • support for additional meters, such as TRT, BRN or gain meter,
  • stores the best results for each game region and RNG type,
  • has a pause menu with the ability to quickly restart the game and change settings,
  • shows the game summary screen after each game,
  • support for two themes (minimalistic dark and classic skin),
  • possibility to use it with NestrisChamps and MaxoutClub,
  • it's light and very fast — should run smoothly even on a heavily loaded PC,
  • it is fully portable, no installation required,
  • and many more!

More detailed information on how to handle the game and its mechanics can be found on wiki pages. If you want, you can also check out the FAQ page where you will find answers to basic questions. Information on the license can be found in the LICENSE file. In short, it is entirely copylefted, so you can do what you want.

Considering the fact that the source code was not written from the beginning with the idea of creating a full-fledged game, its quality is not the best. It is true that I tried to write it so as not to get lost in it, but some things (especially menu operation) I solved using copy-paste. However, the most important thing is that the game works properly and, above all, very effectively.

If they are willing to test the current Windows version of the game, please give me some tests and feedback. If there is anyone here willing to fork the repository and prepare a port for Linux, FreeBSD, and macOS, I encourage you to do so. I'm not able to create them myself, because I don't know Linux and I don't have access to a device with macOS.

This game was created mainly to test various RNG algorithms and I didn't think about turning it into a full-fledged form, or about its continuous development. Therefore, please don't send pull requests to extend the game's functionality, only to fix bugs. If someone would like to port to other platforms, I suggest forking the repository and developing it separately. If it appears, I will put a link to the repository in the readme of my project.

So, have fun! 8)
« Last Edit: September 15, 2021, 11:23:48 pm by furious programming »
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

Seenkao

  • Full Member
  • ***
  • Posts: 249
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #1 on: September 08, 2021, 11:34:33 pm »
Игре Тетрис уже 37 лет.

translate: The Tetris game is already 37 years old.  8-)
Tetris eng или Tetris rus

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #2 on: September 09, 2021, 12:15:46 am »
translate: The Tetris game is already 37 years old.  8-)

The first version for Electronika 60 computer was created in 1984, not for NES consoles.

By the way, the NES version was created in 1989, so it has 32 years old. So it needs to be corrected anyway.  8)
« Last Edit: September 10, 2021, 03:34:45 pm by furious programming »
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #3 on: September 15, 2021, 11:21:39 pm »
Will I have people willing to test the game here?

Would you like to join and create a port to other platforms? It doesn't require a lot of work — the core game mechanics and all menus are not platform specific. All you have to do is to remove the code for updating the button on the taskbar, make a few small corrections and just check how the game works on e.g. Linux or macOS. The game is based on the base classes and SDL, and this one is cross-platform. I can help if something is not understood.
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

Soner

  • Sr. Member
  • ****
  • Posts: 253
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #4 on: September 15, 2021, 11:40:57 pm »

nice.

When I press help button then screen resolution change and fairtress is very small image on the top left edge. Look picture 1.
And when I press help button again then fairtress is going to windowed mode. Look picture 2.

Lazarus 2.0.11, fpc 3.2.1 Win64.

Blade

  • Full Member
  • ***
  • Posts: 142
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #5 on: September 16, 2021, 12:31:38 am »

...If there is anyone here willing to fork the repository and prepare a port for Linux, FreeBSD, and macOS, I encourage you to do so. I'm not able to create them myself, because I don't know Linux and I don't have access to a device with macOS...

...If someone would like to port to other platforms, I suggest forking the repository and developing it separately...

When it comes to forking, I think it would be more interesting and something different, if someone could port it to iOS/iPhone.  In theory, it should be possible to use the SDL Library and the Free Pascal compiler.  This is an area where Free Pascal/Lazarus has very few examples, especially anything recent.

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #6 on: September 16, 2021, 12:50:50 pm »
When I press help button then screen resolution change and fairtress is very small image on the top left edge. Look picture 1.

If you press the help button (i.e. F1 key) or select HELP from the main menu, the game window is minimized and the GitHub wiki opens in your browser. If video mode is active, after selecting HELP, video mode should be deactivated, resolution restored and the window minimized. It should look like the window shouldn't be visible, just a taskbar button.

The code that supports the help looks like this:

Code: Pascal  [Select][+][-]
  1. procedure TLogic.OpenHelp();
  2. begin
  3.   Sounds.PlaySound(SOUND_START);
  4.  
  5.   ShellExecute(0, 'open', 'https://github.com/furious-programming/fairtris/wiki', nil, nil, SW_SHOWNORMAL);
  6.   SDL_MinimizeWindow(Window.Window);
  7. end;

The last two instructions definitely need to be swapped, though on my computer the window always minimizes and restores properly. Although instead of minimizing the window, it is better to check if video mode is active and if so, turn on windowed mode, and if not, just open help in the browser (without any window manipulation). Video and windowed mode are quite hard to master. I'll try to fix it — thanks for tests.

How does the game behave after pressing F11? Video mode turns on and off well?


When it comes to forking, I think it would be more interesting and something different, if someone could port it to iOS/iPhone.

I can not see it. Even if technically possible, classic Tetris is too hard to play on a touchscreen. Note that, unlike modern, it doesn't support wall-kicks or sliding pieces when touch the stack. If the piece touches the stack, it's over — it sticks to it, and a new one appears at the top of the playing field. This is a clone of the console-only game, that's why today players only play it using the controllers (NES controles and emulators on PC), and who doesn't have controller, play on a keyboard. Precise control is very important in this case, especially at levels 18+.

On the other hand, I've played modern Tetris for smartphones a couple of times and don't get it. I don't understand how anyone can play by touching the screen instead of pressing physical buttons. For me, the touch screen is not a device intended for gaming, it is useless on this topic. But that's just my opinion, I grew up on NES myself, I always played using the controllers, and as a last resort the keyboard. 8)
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

Soner

  • Sr. Member
  • ****
  • Posts: 253
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #7 on: September 16, 2021, 06:02:28 pm »
F11 ist okay, It does what it is supposed to do, switching windowed mode and fullscreen.
I put SDL_MinimizeWindow above ShellExecute. Now, when I press first help button it is working normal. But when I press it again then you can see black small window on the top left edge.

Maybe you should use OpenURL instead of ShellExecute when you want to release it on other systems than Windows.

If you are a fan of classic arcade games then check out this page.

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #8 on: September 16, 2021, 09:08:09 pm »
I put SDL_MinimizeWindow above ShellExecute. Now, when I press first help button it is working normal. But when I press it again then you can see black small window on the top left edge.

Currently, there is no condition in the code to check if the video mode is active, or if the window is already minimized. This code must be secured anyway so that it doesn't try to minimize twice. But the window does not have to be minimized - it is enough to deactivate the video mode, because the browser should appear above the game window anyway.

I checked this, added a condition to disable video mode instead of minimizing, but the window appears in the top left corner of the screen instead of in the middle of it (or where it was before). Once again, there is a problem with setting the size and position of the window — SDL ignores these instructions and doesn't change anything, so the window is in a corner and has the wrong size.

Handling the help with modifications should look like this:

Code: Pascal  [Select][+][-]
  1. procedure TLogic.OpenHelp();
  2. begin
  3.   Sounds.PlaySound(SOUND_START);
  4.  
  5.   if Placement.VideoEnabled then
  6.     Placement.ToggleVideoMode();
  7.  
  8.   ShellExecute(0, 'open', 'https://github.com/furious-programming/fairtris/wiki', nil, nil, SW_SHOWNORMAL);
  9. end;

This works as it is supposed to, which is to disable video mode and open help in the browser. But damn it doesn't want to change the size and position of the window. It doesn't want to do this even though the Placement.ToggleVideoMode method is being used for the F11 key and always works fine. And here it does half the job.

ShellExecute is the problem here — when I comment it out, everything works fine. WTF.
« Last Edit: September 16, 2021, 09:09:56 pm by furious programming »
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #9 on: September 16, 2021, 09:20:50 pm »
Ok, I found a temporary solution — call ShellExecute in a separate thread. In this case, the video mode deactivates correctly, the window receives the correct dimensions and position, and the browser help opens. Stupid, but it works. So not stupid.

@Soner: if you have a minute, please test the fresh sources and let me know how it works now.
« Last Edit: September 16, 2021, 09:39:50 pm by furious programming »
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

Soner

  • Sr. Member
  • ****
  • Posts: 253
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #10 on: September 19, 2021, 09:25:19 am »
It is okay now. It is doing what you describe abow.

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #11 on: September 19, 2021, 02:56:32 pm »
Ok, thank you very much for testing and feedback. Anyone else found any problems?
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #12 on: September 23, 2021, 05:47:43 pm »
New version available for download — Fairtris 2.0.0.6 beta 3

There were no big changes — only slight fixes for several menu screens, making it easier, for example, to resume and restart the game. I also changed the behavior after pressing the help button. Previously, the window would minimize and the browser help would open, but for some users, the window would not minimize properly when exclusive video mode was active. Therefore, I gave up minimization in favor of switching to windowed mode. I've also added code to open a specific wiki page based on the current scene, so you can get helpful information faster.
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

furious programming

  • Hero Member
  • *****
  • Posts: 516
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: Fairtris — a fair implementation of Classic Tetris®
« Reply #13 on: October 14, 2021, 06:16:12 pm »
The final, stable version has been released — Fairtris 2.0.0.7

Final and stable version, implementing all fixes and improvements from the three previous beta versions. The last modification is the rendering of the window just after waiting for the next frame, which better imitates the NMI of the NES console (get input, handle logic, wait for the interrupt and then display the image on the screen).

This release is designed for 64-bit Windows only (Vista, 7, 8, 8.1, 10 and further).

If there is anyone willing to port the project to platforms other than Windows, I still encourage you.

End of development

Fairtris was created mainly to test, in conditions similar to the original NES console, whether the classic Tetris® could be better by implementing a different and better RNG, as well as introducing changes to the gravity system in the PAL region. In one sentence, it allows you to check different variations of the same game and choose what's best for it. Considering the job is done, the development of this game is complete — all plans have been fully realized.

If there is ever a demand for a PC version to replace the NES consoles, the code for this project can be used to create a worthy successor. In this case, the only need will be to select one or invent fair but challenging RNG and select NTSC region (possibly additionally PAL, if players care about it), implement the correct transition calculation and avoid any bugs in the game mechanics that exist in the original.
Lazarus 2.0.12 with FPC 3.2.0 (SVN Revision 64642), Windows 10 — all 64-bit

 

TinyPortal © 2005-2018