Skip to content

Commit

Permalink
refactor(tetris): modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-jerry-ye committed Jun 19, 2024
1 parent f9bd935 commit 10af202
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions examples/tetris/lib/utils.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,26 @@ pub fn check_collision(
if offset.1 + len_r > grid_row_count {
return true
}
fn go(l : @immut/list.List[Array[Int]], r : Int) -> Bool {
match l {
Cons(v, n) => {
if r < offset.1 {
return go(n, r + 1)
}
if r >= offset.1 + len_r {
return false
loop grid, 0 {
Cons(v, n), r => {
if r < offset.1 {
continue n, r + 1
}
if r >= offset.1 + len_r {
return false
}
for c = 0; c < len_c; c = c + 1 {
if shap[r - offset.1][c] == 0 {
continue c + 1
}
for c = 0; c < len_c; c = c + 1 {
if shap[r - offset.1][c] == 0 {
continue c + 1
}
if v[c + offset.0] != 0 {
return true
}
if v[c + offset.0] != 0 {
return true
}
return go(n, r + 1)
}
Nil => false
continue n, r + 1
}
Nil, _ => false
}

return go(grid, 0)
}

pub fn get_effective_height(
Expand Down

0 comments on commit 10af202

Please sign in to comment.