《C写的俄罗斯方块源代码开发文档》由会员分享,可在线阅读,更多相关《C写的俄罗斯方块源代码开发文档(12页珍藏版)》请在金锄头文库上搜索。
1、0 20 40 60 20 40 60 每一点取的是左上角坐标 20,60, 20,40, 20,20, 40,60, RED, 1, 0,60, 20,60, 40,40, 40,60, RED, 2, 20,20, 40,20, 40,40, 40,60, RED, 3, 0,60, 0,40, 20,40, 40,40, RED, 0, 20,60, 20,40, 20,20, 40,20, YELLOW,1, 0,40, 0,60, 20,60, 40,60, YELLOW,2, 20,60, 40,60, 40,40, 40,20, YELLOW,3, 0,40, 20,40, 40
2、,40, 40,60, YELLOW,0, 0,60, 20,60, 20,40, 40,60, GREEN,1, 0,40, 20,60, 20,40, 20,20, GREEN,2, 0,40, 20,40, 20,60, 40,40, GREEN,3, 20,20, 20,40, 20,60, 40,40, GREEN,0, 0,60, 20,60, 20,40, 40,40, WHITE,1, 0,40, 0,20, 20,40, 20,60, WHITE,0, 20,0, 20,20, 20,40, 20,60, LIGHTGRAY,1, 0,40, 20,40, 40,40, 60
3、,40, LIGHTGRAY,0, 20,20, 20,40, 20,60, 20,80, LIGHTGRAY,1, 0,60, 20,60, 40,60, 60,60, LIGHTGRAY,0, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN,1以下是源代码:Game.h 文件#include #include #include #include #define UP w#define DOWN s#define LEFT a#define RIGHT d#define Esc 27int key=NULL;int a=0;struct Shapeint xy8
4、; int color;struct full /记?录?每?个?方?块的?信?息 bool isfull;int color;Shape shape74= /7种?基本?形?状 四?种?变?形?(不?够?四?种?变?化的?用?相同?的?来填?充?)? 20,60, 20,40, 20,20, 40,60, RED, 0,60, 20,60, 40,40, 40,60, RED, 20,20, 40,20, 40,40, 40,60, RED, 0,60, 0,40, 20,40, 40,40, RED, 20,60, 20,40, 20,20, 40,20, YELLOW, 0,40, 0,
5、60, 20,60, 40,60, YELLOW, 20,60, 40,60, 40,40, 40,20, YELLOW, 0,40, 20,40, 40,40, 40,60, YELLOW, , 0,60, 20,60, 20,40, 40,60, GREEN, 0,40, 20,60, 20,40, 20,20, GREEN, 0,40, 20,40, 20,60, 40,40, GREEN, 20,20, 20,40, 20,60, 40,40, GREEN, , 0,60, 20,60, 20,40, 40,40, WHITE, 0,40, 0,20, 20,40, 20,60, WH
6、ITE, 0,60, 20,60, 20,40, 40,40, WHITE, 0,40, 0,20, 20,40, 20,60, WHITE , 0,40, 20,40, 20,60, 40,60 , BLUE, 0,40, 0,60, 20,40, 20,20 , BLUE, 0,40, 20,40, 20,60, 40,60 , BLUE, 0,40, 0,60, 20,40, 20,20 , BLUE, 20,0, 20,20, 20,40, 20,60, LIGHTGRAY, 0,40, 20,40, 40,40, 60,40, LIGHTGRAY, 20,0, 20,20, 20,4
7、0, 20,60, LIGHTGRAY, 0,40, 20,40, 40,40, 60,40, LIGHTGRAY, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, ;class Gameint x,y; /x y 表示?方?块的?相对?坐?标int dir; /方?块移?动方?向int _shape; /七?种?形?状int
8、 change_shape; /四?种?变?换?int old_shape; /记?录?未变?形?方?块的?形?状int old_change_shape;bool is_fullline20; /标记?是?否?满行Dfull isfull2010; /标记?是?否?有D方?块 20行D10列D public :Game();int shapeX(int i)return (shape_shapechange_shape.xyi+x); /返回?shape形?状第i个?方?块的?的?实际X坐?标int shapeY(int i)return (shape_shapechange_shape.x
9、yi+1+y); /返回?shape形?状第i个?方?块的?的?实际Y坐?标int rowX(int i)return i*20+100; /返回?第i列D的?X坐?标int columnY(int i)return i*20+50; /返回?第i行D的?Y坐?标void drawinterface(); /画-界?面?void drawshape(); /画-方?块void clearshape(); /清?除y方?块void drawshowshape( ); /画-在预览框中D的?方?块void clearshowshape(); /清?除y在预览框中D的?方?块void getdir(
10、); /取?得?方?块移?动方?向bool is_move_leftX(); /方?块是?否?能向左移?bool is_move_rightX(); /方?块是?否?能向右移?bool is_moveY(); /方?块是?否?能在 Y 轴方?向移?动bool is_change(); /是?否?能变?形? (近边?界?时变?形?后不?能出?界?)?void shapemove(); /方?块移?动void newshape(); /出?新?的?方?块 void fullline(); /扫描满行Dvoid clearfullline(); /清?除y满行Dvoid repaint(); /重?画-(实现?消?行D下?移?)?bool isgameover(); /游?戏是?否?结束?;Game:Game