Teris Game(俄罗斯方块) on Windows Mobile

The purpose of the project is to train to design, test and code for a small project for a shot period of time, like say 3 days.

I am using the xp and protoyping iteration for this project to keep updating new feature and making the code to run on Windows, WM5 and WM6.

Feature list
Like most of the teris, there are some common features here:
1, have couple of different shape of teris elements.
2, teris element can tranformed
3, teris element will fall down during certain period of time
4, the player can move the teris element to left, right, down but not up.
5, if there is any fulllines in the game panel, the lines will be disappear.
6, if there is any teris element reach the top of the game panel, the game is over.
7, except the ordinary movement feature, I added "touch" feature in Windows Mobile to control the movement of the teris element.
8, autocale to addjust the screen orientation.

Brief Design

1, As a typical MVC pattern design, I splitted the teris app to Model(deal with the teris data),  View(deal with the drawing of the game panel and the changing of the teris element), Controller(make the game runs smoothly with proper logic).

2, Model. Every Teris Shape type is store in a three dimentional array, whose first dimention is to store the number of various transformed type and the last two dimentions are to store the shape by number in array. I decide to use a class wrapper to mark down the status of the transform and the teris data. When initializing the game, I only need to init num-of-types teris array. When new shape pop up in screen, the mechanism will return the corresponding type of teris element with certian status.

3, Controller. Write down the hard-core logic of the game, like the collision dection when the element touching the left, right and bottom of the game panel. Actually, the game panel is just an 2d array fill with zero with border in a Fixed value. We add the teris element in current position with the corresponding game panel position value, the result is collided if the addition value is more than fixed value. And I refered the similar approuch of Merge operation in Merge sort to do the array copying when there is any fulllines in the game panel.

4, View. Originally, the program is desgined to run on windows. Later of today, I implanted it to run on my cell phone, which is based on Windows Mobile 6. And I surpisingly found out that the only thing I need to change is just the drawing canvas because in compact framework only the sub-classed of System.Windows.Forms.Form can support CreateGraphic(). However, that's it. I can made my code run on WM5 and WM6 with the same code based on .net compact framework 2.0 with no problem.

Screenshot and Excutions:

Image of Windows Mobile 6:
Teris on WM6
teris landscape

Excution Package:
TerisWM6.rar
Screenshot of WM5:
Teris on WM5
Excution Package:
TerisWM5.rar

Hope you can enjoy it and have fun. And I will add the code to keep compatible if the screen is rotated with 90 degrees later.

posted on 2007-11-22 00:01  SigEric  阅读(611)  评论(0)    收藏  举报

导航