MinecraftU / 2021-computer-adventures

Repository for our 2021 Computer Adventures Ruby project!
0 stars 0 forks source link

Control tetromino #21

Closed jamespeilunli closed 3 years ago

jamespeilunli commented 3 years ago

Technically done, but these things are true:

any suggestions @dealingwith ?

jamespeilunli commented 3 years ago

oops, also forgot to change indentation. note to self: change indentation when complete

dealingwith commented 3 years ago

The lag is probably because of the redraw every time. I need to work on #19 :)

dealingwith commented 3 years ago

If you can clean up the indentation tonight we can merge and I can refactor to use moving existing tetrominoes instead of redrawing new ones every tick.

jamespeilunli commented 3 years ago

I don't think the lag is because of the squares. I shouldn't have used the word lag that meant input was delayed, because sometimes when I pressed the left and right arrows the pieces didn't move at all.

jamespeilunli commented 3 years ago

I just realized: in the actual game, you can move multiple times, so I don't need a moved variable. I think I should make :key_down into :key_held and check if input happened every 8 times a second? I also noticed I should move on :key_down do |event| outside of the update loop.

I'm also going to make a update helper method so less repetition in move and fall is used.

I forgot to comment this comment, so pretend I posted the comment below a few minutes after I posted this:

This:


t = 1
update do
    if t % 8 == 0
        game.tetromino.moved = false
    end

    if t % 30 == 0
        game.draw([0, 0], size)
        game.tetromino.fall
        game.gameboard = game.tetromino.gameboard
    end

    t += 1
end

on :key_held do |event|
    if !game.tetromino.moved
        game.tetromino.moved = game.tetromino.move(event.key)
        game.gameboard = game.tetromino.gameboard
        game.draw([0, 0], size)
    end
end

show

worked, but now the lag due to redraw every time is happening. I know this because my computer fan speed goes higher when I've moved my tetromino too much.

I'm gonna update the draft.

jamespeilunli commented 3 years ago

Technically #14 control tetromino is done, so I'll make it ready for review. @dealingwith, you can start working on #19 now, sorry for the wait.

dealingwith commented 3 years ago

I'm a little swamped at the moment but hopefully I'll get a chance to review and merge this before camp this afternoon!

jamespeilunli commented 3 years ago

That's fine, take your time 👍

jamespeilunli commented 3 years ago

When you get the time, review the PRs in this order: #21 #22 #23