MinecraftU / 2021-computer-adventures

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

Add multiple tetrominos #23

Closed jamespeilunli closed 3 years ago

jamespeilunli commented 3 years ago

When a tetromino can't move anymore (square(s) are below it or it has reached the bottom of the gameboard), create a new tetromino at the top of the gameboard.

This PR is a draft so it will not be reviewed before the previous pull requests.

dealingwith commented 3 years ago

@jamespeilunli now that the other branches have merged, this branch has conflicts. You can probably figure out what needs to be updated on this branch so that it can be automatically merged. If not we can go over it on Wednesday.

Remind me on Wednesday to also show you how to chain branches in an attempt to avoid these kind of merge conflicts.

jamespeilunli commented 3 years ago

Can't I just do what we did when this happened before, since I just want my recent changes to be pushed? So:

git stash
git fetch origin
git checkout main
git stash pop
git commit -am "override main with multiple tetrominos code"
git push
dealingwith commented 3 years ago

You can try! :)

jamespeilunli commented 3 years ago

Ok, this worked:

cd ~/github_repos/2021-computer-adventures/
ls
git status
git stash
git status
ls
cd ..
cp 2021-computer-adventures/ ~/tmp
cp -r 2021-computer-adventures/ ~/tmp
cd 2021-computer-adventures/
ls
git status
git fetch
ls
git status
git fetch origin
git status
git checkout main
ls
git status
git pull
git status
cd ~/tmp
ls
mv * ~/github_repos/2021-computer-adventures/
cd ~/github_repos/2021-computer-adventures/
ls
git status
git commit -am "override main with multiple tetrominos code"
git status
git push

git stash told me No local changes to save so I just copied the directory into a temporary directory.

jamespeilunli commented 3 years ago

Oh also, on lines 80-86 in tetrominos.rb (in rotate method)

  def rotate
    put_tetromino(clear=true)
    @piece_data = Matrix[*(0...width).map {|i| piece_data.transpose.row(i).to_a.reverse}] # Matrix.transpose almost rotates, but we need to reverse each row. Asterix to prevent everything to be nested in one []
    @width = piece_data.row(0).to_a.length
    @height = piece_data.column(0).to_a.length
    put_tetromino
  end

I had to put @ in front of piece_data, width, and height for it to work. Why is that, and how do I fix it? I already tried putting them in attr_accessor to no avail.

jamespeilunli commented 3 years ago

Just realized something: pressing right arrow (or left) into blocks on the right (or left) of my tetromino sometimes makes my tetromino run through those blocks. I think this is because I only detect if there are blocks under the tetromino in is_dead, not to the left or right. Does this still count as closing Allow tetrominos to stack #24?