10 五月 2008

puyo-魔法泡泡-部分源代码下载

收到上海优酷的面试题,实现魔法泡泡的游戏。以下是试题内容:

Purpose:
----------

The goal of this exercise is to develop a JAVA or C/C++ version of Puyo-Puyo, a variation of the Tetris game.

We are interested in seeing your code writing skills, style and logic.
Don't hesitate to comment on your code in order to make it as clear as possible.

Please do not browse the web (or any other source of information) to find the code of this program already developed.

anyway feel free to browse the web to find a playable version of the game for reference.

The purpose of this exercise is purely a skill assessment, and gameplay implementation ability.

Rules of Game:
---------------

* Spheres come down from the top of the game board in pairs. A player can rotate them on their way down.

* Spheres come in 4 different colors: red, blue, green, and yellow

* Linking four spheres of the same color (horizontally, vertically or both(as in tetris)) removes them from the game board, allowing any sphere remaining to drop and fill the vacated space.
This may lead to several possible "chain combos" if additional colors match.

* The game board can be any size you want (we recommend 6x12)

* Note that the pair of spheres are not linked to each other. If one sphere is blocked because there is something underneath, the other one will continue falling (with no player control over it) until it reaches something.

The Zip Files Contain:
* 4 pictures of the spheres
* A screenshot of the game as it should look

as stated before, feel free to browse the web to find a playable version of the game for reference if some rules are unclear.

To Submit:
------------

Please submit a java or C/C++ console application that will open a window and start the game.
You may attach a separate text file that documents player controls and any other comments (as gameplay improvements, bugs not corrected, any comment that will help evaluate your submission...)

important:
- use Eclipse or Visual C++ as your IDE if you need one, DO NONT use JBuilder or C++ Builder
- java or C/C++ console application MUST be available
- it will be better to attach your project files and source code files
- ALL COMMENTS IN ENGLISH

这是我实现的界面:

puyo

因为白天上班,还得备课,所以挤时间,现在基本实现了随机产生一对泡泡,通过多线程键盘控制移动和变形以及自动下落,泡泡的移动全部用二维数组存储,并且每一次移动,下落或者变形都会产生对应的二维数组元素的变换。全部界面通过代码实现,没有借助其他设计工具。
接下来要解决的问题:
1、通过线程实现泡泡对的连续产生,临界条件的判断(即泡泡下落时,什么时候终止下落)
2、因为已经将泡泡和二维数组对应,所以当泡泡达到临界条件式,调用扫描算法进行泡泡的清除(这个过程需要扫描二维数组)。
3、一旦扫描完成,需要从二维数组重新读取图像信息,然后显示到窗体面板中。
4、一些计分规则的实现。
5、代码和工程结构的优化。

这是部分源代码: puyo.7z

puyo.zip

没有评论: