フィルターのクリア

How to add smaller matrix into bigger matrix? (Tetris based idea)

1 回表示 (過去 30 日間)
Maddie Bredehoeft
Maddie Bredehoeft 2017 年 3 月 30 日
コメント済み: Maddie Bredehoeft 2017 年 3 月 30 日
We are creating a Tetris game for fun! & so far have blocks block{1} = [1 1; 1 1]; block{2} = [1 1; 0 1; 0 1]; block{3} = [1 1; 1 0; 1 0]; block{4} = [0 1 1; 1 1 0]; block{5} = [1 1 0; 0 1 1]; block{6} = [1 1 1 1]; block{7} = [0 1 0; 1 1 1];
and they get randomly chosen, but we then need to put the block on our game board
tetris = zeros(18, 10); %Gameboard and dimensions
we've tried a few things and they aren't working yet, any thoughts or input would be awesome! Thanks so much!
  2 件のコメント
KSSV
KSSV 2017 年 3 月 30 日
You want to add or place the block some where in the tetris?
Maddie Bredehoeft
Maddie Bredehoeft 2017 年 3 月 30 日
Yes! We want to place it at the top so that it seems to have just entered the matrix of the game

サインインしてコメントする。

採用された回答

Thorsten
Thorsten 2017 年 3 月 30 日
To add, for example, block 3 with the upper left corner at row i, column j:
b = block{3}; tetris(i:i+size(b,1)-1, j:j+size(b,2)-1) = b;
  1 件のコメント
Maddie Bredehoeft
Maddie Bredehoeft 2017 年 3 月 30 日
Thank you so much! You're the best! You're a Matlab genius

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVideo games についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by