ML Tetris (mltetris.mo)

Started by petabyte, May 26, 2021, 02:46:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

petabyte


theBilalFakhouri

Cool, thanks for sharing

petabyte

Update:
Will eventually be merged into magiclantern_simplified. https://github.com/petabyt/magiclantern_simplified/tree/tetris
Some notes:
- menu_redraw_blocked is set to 1 to prevent flickering as menu is being drawn.
- task_create is called to keep the ML menus in place after the game is quit.
- Code is based on my project, ptetris (https://github.com/petabyt/ptetris/), which can be compiled and run with X11/rawdraw

dpjpandone

Does not work on EOSM. The game starts but none of the buttons work.

petabyte

Should work if you compile it yourself. MODULE_KEY_PRESS macros might be different.

dpjpandone

I did compile myself, Where to change MODULE_KEY_PRESS macros? you use same format as arkanoid (working) what else could be the problem? Is it because EOSM has "Q" "Set" combined? so game does not start?


switch(key)
    {
    case MODULE_KEY_Q:
        running = 0;
        return 1;


game does not start until "Q" ?
The blocks fall, just cannot move or flip them and cannot exit until level fills up and Game Over

petabyte

Quote from: dpjpandone on November 25, 2022, 05:21:17 PM
Is it because EOSM has "Q" "Set" combined? so game does not start?
Maybe? I don't know, I've never used an EOS M and I'm not familiar with the button macros.
Are you compiling https://github.com/petabyt/magiclantern_simplified/tree/tetris/modules/tetris or https://github.com/petabyt/mltetris?
Wouldn't make sense if none of the buttons work, I assume it must be some kind of major bug. Maybe try in Qemu?


dpjpandone

OK!

I picked up a 5D3 last week and the game works on this camera. I would like to suggest some small improvements:

-I think the speed should start off slower and increase over time
-pressing a direction and holding it should be read as multiple button presses in that direction. This would improve playability and reduce wear and tear on the hardware
- The game should be the highest level priority for drawing graphics, as it stands the audio meters conflict with the top of the screen.

I will do some homework on my end to try to implement some of these proposals and see if you like them.. In the meantime if any of these ideas appeal to you and you have suggestions I would love to discuss further!

Thanks for such a neat module!

petabyte

QuoteI think the speed should start off slower and increase over time
Good idea! I'll implement this when I have the time.

Currently I haven't touched the tetris code since August, so I'll have to find the time to re-read the source code and fix a few things.
Eventually, it should end up in the magiclantern_simplified repository or other forks as it has a compatible license.

dpjpandone

I found myself failing to align the blocks perfectly on the tiny screen and one down press makes it permanent. This small change makes it more playable (IMO):

case MODULE_KEY_PRESS_DOWN:
    testfield.currBlockY++;
if (fieldIsPossible(&testfield))
        {
            fieldDup(&field, &testfield);
        }


        //mustFixBlock = 1; //This stobs the block on the current row (not needed if we don't want block to drop instantly
        break;
    }

dpjpandone

Quote from: petabyte on December 28, 2022, 04:55:13 AM
Good idea! I'll implement this when I have the time.


this might be helpful (from Pong lua script)

game_speed = 3
    counter = 0

    ball_dx = game_speed
    ball_dy = math.random(-game_speed, game_speed)

    AI_maxspeed = game_speed

    while menu.visible do
        --gradually increase speed
        counter = counter + 1
        if counter == 1000 then
            counter = 0
            game_speed = game_speed + 1
            AI_maxspeed = game_speed
        end


so in the case of tetris a higher (speed) number slows the game down since MSLEEP uses this variable, so maybe start with a speed of 300 and decrement by 5 each time a line is cleared?

petabyte

I've abandoned the archived tetris module (https://github.com/petabyt/mltetris) but the last one I've worked on is https://github.com/petabyt/magiclantern_simplified/tree/tetris/modules/tetris (complete rewrite)
It's been a while since I've touched the two, but the more recent one is much better at rendering, but has slight game logic issues. Can't remember exactly what.