A
A
Arti-Jack2017-10-22 19:30:37
JavaScript
Arti-Jack, 2017-10-22 19:30:37

How to make a collision in Tetris?

Hello.
In general, I continue to play around with JavaScript (I write Tetris). I ran into a problem: I don’t know how best to make a collision for Tetris. The blocks themselves consist of a matrix, and I can also represent the playing field in the form of a matrix using:

const arena = createMatrix(12, 20);
console.log(arena);
console.table(arena);

And, accordingly, those elements that are equal to 1 in this large matrix must be solid (collision must work on them).
In general, how can I do this better?
PS: All code is still available in this form.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2017-10-22
@Stalker_RED

The second 4x4 matrix in which the falling figure is placed. On each "tick" or user action, add the values ​​from the cells of the matrix and the corresponding piece of the arena, and check if there is a deuce.
PS: You forgot the "stick". It is important :)

A
Antowa Kartowa, 2019-09-30
@AntowaKartowa

Is this not your course on Udemy? The names of functions, variables and the whole structure are very similar.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question