I'm writing a game of Tetris, help me

0

I'm creating a Javascript Tetris using p5.js and I'm having a problem and the speed at which the parts fall ... I'm using the frameRate () function to regulate this ... Framerate changes the speed of execution of the game, not only the movement, so they fall slowly but when I give the command to change the rotation of the piece it runs slowly too. So I put it on forever as I give the command with the keyboard to rotate the piece it increases to 60 FPS and then when it draws back to 1 FPS but that is making the part fall faster every time I press ... I press the key very fast that makes the piece turn it will fall pretty fast, because the thousandths of a second that the game stays in 60FPS is enough to accelerate the piece before it returns to 1 FPS ...

function setup()
{
    createCanvas(600, 900)
    actualPiece = choosePiece()
    movingSpeed = 1
}

function draw()
{
    drawBG()
    frameRate(movingSpeed)
    movePiece(actualPiece)
    actualPiece.show()
    drawInfo()
}
function keyPressed()
{
    frameRate(60)
    if (keyCode === UP_ARROW)
    {
        if (actualPiece.selectShape == 3)
        {
            actualPiece.selectShape = -1
        }
        actualPiece.selectShape ++
    }
}

What can I do? I've tried using functions with setTimeout but they make the whole page in HTML take years to load ... Thanks for your help.

    
asked by anonymous 22.08.2018 / 21:43

0 answers