File Exchange

image thumbnail

Tetris for Dummies

version (13.8 KB) by Husam Aldahiyat
Tetris with easy code layout and extensive comments.


Updated 09 Feb 2009

View Version History

View License

Tetris game code with sounds, high scores and gravity. It is intended as a learning tool with its extensive comments and laid out code with easy getarounds and simple functions. The code explores things such as loops and if statements, patch, save/load, GUI techniques, callbacks and sound generation.

It can be easily edited to suit one's needs and/or to make it more modular, and I hope at least some people will learn new things from it :)

Cite As

Husam Aldahiyat (2021). Tetris for Dummies (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

Chow Meng Leong

Hello!!! there I currently taking this subject which is called COMPUTER VISION AND IMAGE PROCESSING and this subject has linking to implement a game. So i required to implement a tetris game and i also new to matlab. Is there anyone there can teach me how to implement tetris game step by step because i want to what happen on each of function is being created instead of just copy and paste people code to the matlab. I hope to get reply as soon as possible. Thank You

mohammad Al-Kayyali

mohammad Al-Kayyali

Just want to say thank you cause you are the one who helped me not to lose faith in MATLAB ...

Good Day Mr. Husam.will you pls send me the figure of this game?because i don't know how to create a tetris like this.i want to know the basic.plsssss.i really need it...and i need your help to make another game cause i'm just surfing this matlab and i can't really understand the whole program...God bless




Kenneth Eaton

@Niye: As John D'Errico (a well-respected and trusted individual on this site) has already stated, this submission is not a copy of Pascal's. Granted, it is the same game, but written and designed in a different way. If you have specific arguments why the other is better, then by all means make them. But simply implying plagiarism is inappropriate.

John D'Errico

Husam Aldahiyat

Thanks for the comment it means a lot.

Most of the files I've submitted have no H1 line and proper help, but I'm updating them soon.

John D'Errico

Unfortunately, the help on this code gives no help. Apparently, the help function does not recognize %{ and %} blocks.

>> help play2


Regardless, this is obviously NOT plagiarized code. I've done a careful comparison between the codes and found no evidence of any such behavior. The comment (made by Patricia Castro) is a false accusation.

Husam Aldahiyat

I posted this to help people and in return got an ill-conceived accusation of being a plagiarist. Great.

Husam Aldahiyat

Please elaborate on that accusation.

By the way, and this is completely unrelated, I had tried twice to give that particular file an acknowledgment, but the update wouldn't go through.

Mohannad Omari

Dania Adwan

John D'Errico

I'll admit that I'm impressed. The author has given us interesting insights into their thoughts as they wrote the code. LOTS of comments, that really try to explain why specific things are done, and what a code fragment does in the code. This is to be highly commended.

Yes, there are a few things that I'd disagree with. The use of globals to pass information around is generally a poor choice, and unnecessary, since nested functions are already employed. Also, the author uses preallocation (not prelocation) but appears to be unsure what it truly does for the code, and thus why to use it.

Well done, for the effort that went into this code, the comments, and the honesty they show. While there is room for improvement in their work, this author has earned my respect.

Must I pick a numerical rating? Nope.

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux


Community Treasure Hunt

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

Start Hunting!