Advertisement
shywolf91

TETRIS C++ -ERRORS-

May 10th, 2012
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.88 KB | None | 0 0
  1. //Dark GDK - The Game Creators - www.thegamecreators.com
  2.  
  3. //the wizard has created a very simple project that uses Dark GDK
  4. //it contains the basic code for a GDK application
  5.  
  6. //whenever using Dark GDK you must ensure you include the header file
  7. #include "DarkGDK.h"
  8.  
  9.  
  10. //Global
  11. int Block_Size=20;
  12. const DWORD Red = dbRGB(255,0,0);
  13. const DWORD Green = dbRGB(0,255,0);
  14. const DWORD Blue = dbRGB(0,0,255);
  15. const DWORD Magenta = dbRGB(255,0,255);
  16. const DWORD Black = dbRGB(0,0,0);
  17. const DWORD White = dbRGB(255,255,255);
  18. const DWORD Yellow = dbRGB(255,255,0);
  19. const DWORD Cyan = dbRGB(0,255,255);
  20. const DWORD Orange = dbRGB(255,165,0);
  21. //end global
  22.  
  23. //Classes
  24.  
  25. class Block {
  26. private:
  27.     int x,y;
  28.     DWORD color;
  29. public:
  30.     Block();
  31.     Block(int, int, DWORD);
  32.     void draw();
  33.     void move(int, int);
  34.   void clear();
  35.  
  36. };
  37. Block::Block(){
  38. x = 0;
  39. y =0;
  40. color = White;
  41. }
  42. //Methods (Block)
  43.  
  44. Block::Block(int X, int Y, DWORD COLOR)
  45. {
  46.     x=X;
  47.     y=Y;
  48.     color=COLOR;
  49. }
  50.  
  51. void Block::draw()
  52. {
  53.     int x1, y1, x2, y2;
  54.     x1=x*Block_Size;
  55.     y1=y*Block_Size;
  56.     x2=x1+Block_Size;
  57.     y2=y1+Block_Size;
  58.  
  59. //  dbInk(color, Black);
  60.     dbBox(x1,y1,x2,y2);
  61. }
  62.  
  63. void Block::clear()
  64. {
  65.  
  66.     dbInk(Black, Black);
  67.     //dbBox(x1,y1,x2,y2);
  68.     draw();
  69. }
  70.  
  71. void Block::move(int dx, int dy)
  72. {
  73.     x=x+dx;
  74.     y=y+dy;
  75.     dbInk(color, Black);
  76.     draw();
  77. }
  78. //End Method (Block)
  79.  
  80. class Shape {
  81.  
  82. private:
  83.     Block blocks[4];
  84.     int pos[8];
  85. public:
  86.     Shape();
  87.     make_shape();
  88.     void move_shape(int,int);
  89.     void draw_shape();
  90. };
  91. //Methods (Shape)
  92. Shape::Shape() {
  93. blocks[0] = Block(0,0, Red);
  94. blocks[1] = Block(0,0, Red);
  95. blocks[2] = Block(0,0, Red);
  96. blocks[3] = Block(0,0, Red);
  97. }
  98. Shape::make_shape()
  99. {
  100.     blocks[0] = Block(pos[0],pos[1],color);
  101.     blocks[1] = Block(pos[2],pos[3],color);
  102.     blocks[2] = Block(pos[4],pos[5],color);
  103.     blocks[3] = Block(pos[6],pos[7],color);
  104. }
  105.  
  106. void Shape::draw_shape()
  107. {
  108.     for (int i=0; i<4; i++)
  109.     {
  110.         blocks[i].draw();
  111.     }
  112. }
  113.  
  114. void Shape::move_shape(int dx, int dy)
  115. {
  116.     for (int i=0; i<4; i++)
  117.     {
  118.         blocks[i].clear();
  119.     }
  120.     for (int i=0; i<4; i++)
  121.     {
  122.         blocks[i].move(dx,dy);
  123.     }
  124. }
  125.  
  126.  
  127. class I_Shape: public Shape{
  128. public:
  129.     I_Shape(int,int);
  130.    
  131. private:
  132.     DWORD color;
  133.     //int pos[8];
  134. };
  135.  
  136. //Methods (I_Shape)
  137.  
  138.  
  139. I_Shape::I_Shape(int x, int y):Shape()
  140. {
  141.     color=Blue;
  142.     pos[0]=x-1;
  143.     pos[1]=y;
  144.     pos[2]=x;
  145.     pos[3]=y;
  146.     pos[4]=x+1;
  147.     pos[5]=y;
  148.     pos[6]=x+2;
  149.     pos[7]=y;
  150.     make_shape(pos,color);
  151. }
  152.  
  153. // the main entry point for the application is this function
  154. void DarkGDK ( void )
  155. {
  156.     //Block NewBlock(0,0,Red);
  157.     I_Shape First(5,3);
  158.     // turn on sync rate and set maximum rate to 1 fps
  159.     dbSyncOn   ( );
  160.     dbSyncRate ( 1 );
  161.     First.draw_shape();
  162.     First.move_shape(5,5);
  163.  
  164.     //NewBlock.draw();
  165.     //  NewBlock.move(2,2);
  166.     // our main loop
  167.     while ( LoopGDK ( ) )
  168.     {
  169.         First.move_shape(0,1);
  170.  
  171.        
  172.         // update the screen
  173.         dbSync ( );
  174.     }
  175.  
  176.     // return back to windows
  177.     return;
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement