All there but errors need fixing

Dependencies:   mbed

Overview:

Rookie Tetris is a jigsaw style game based on the classic Tetris.

A block will appear at the top of the screen, you must move it (your options for movement are left, right and down - you cannot move up the board). The block will stop when it if placed either on the floor of the board or on-top of another block.

Your goal is to fill a complete row of the board with the blocks; when you do so the row will delete and the pattern above it will drop down. The game is over when your pattern is tall enough to reach to the top of the board!

Controls:

Use the joystick to move your block! Your block cannot move out of the parameters of the board.

Pot 2 controls the contrast of the screen.

Revision:
4:7ddd287a5d28
Parent:
3:522c6f850e91
Child:
6:39cbec524483
--- a/Tetromino/Tetromino.cpp	Sun May 24 11:18:33 2020 +0000
+++ b/Tetromino/Tetromino.cpp	Sun May 31 17:01:53 2020 +0000
@@ -1,52 +1,22 @@
 #include "Tetromino.h"
 
-const int ISprite[4][4] = {
-  {0,0,1,0,},
-  {0,0,1,0,},
-  {0,0,1,0,},
-  {0,0,1,0,},
-};
-
-const int L0Sprite[4][4] = {
-  {0,1,0,0,},
-  {0,1,0,0,},
-  {0,1,1,0,},
-  {0,0,0,0,},
-};
-
-const int Z0Sprite[4][4] = {
-  {0,1,0,0,},
-  {0,1,1,0,},
-  {0,0,1,0,},
-  {0,0,0,0,},
-};
-
-const int OSprite[4][4] = {
-  {0,0,0,0,},
-  {0,1,1,0,},
-  {0,1,1,0,},
-  {0,0,0,0,},
-};
-
-const int TSprite[4][4] = {
-  {0,1,0,0,},
-  {0,1,1,0,},
-  {0,1,0,0,},
-  {0,0,0,0,},
-};
-
-const int L1Sprite[4][4] = {
-  {0,0,1,0,},
-  {0,0,1,0,},
-  {0,1,1,0,},
-  {0,0,0,0,},
-};
-
-const int Z1Sprite[4][4] = {
-  {0,0,1,0,},
-  {0,1,1,0,},
-  {0,1,0,0,},
-  {0,0,0,0,},
+int tetromino[3][4][4] = {
+{
+  {1,1,1,1},
+  {1,1,1,1},
+  {1,1,1,1},
+  {1,1,1,1}
+}, {
+  {1,1,1,1},
+  {1,1,1,1},
+  {1,1,1,1},
+  {1,1,1,1}
+}, {
+  {1,1,1,1},
+  {1,1,1,1},
+  {1,1,1,1},
+  {1,1,1,1}
+}
 };
 
 Tetromino::Tetromino()
@@ -59,43 +29,21 @@
     
 }
 
-void Tetromino::init(int x, int height, int width)
+void Tetromino::init(int number, int x, int y, int speed)
 {
     _x = x;
-    _y = HEIGHT/2 - height/2;
-    _height = height;
-    _width = width;
-    _speed = 1;
-    
-}
+    _y = y;
+    _speed = speed;
+    _number = blockArray[blocknumber];
 
-
-
-void Tetromino::draw(N5110 &lcd, int x)
-{
-    int shape = rand() % 6;
     
-    if (shape == 0) {
-        lcd.drawSprite(_x, _y, 4, 4, (int*)ISprite); /*_shape_type = 0;*/ 
-    } else if (shape == 1) {
-        lcd.drawSprite(_x, _y, 4, 4, (int*)L0Sprite); /*_shape_type = 1;*/
-    } else if (shape == 2) {
-        lcd.drawSprite(_x, _y, 4, 4, (int*)Z0Sprite); /*_shape_type = 2;*/
-    } else if (shape == 3) {
-        lcd.drawSprite(_x, _y, 4, 4, (int*)OSprite); /*_shape_type = 3;*/
-    } else if (shape == 4) {
-        lcd.drawSprite(_x, _y, 4, 4, (int*)TSprite); /*_shape_type = 4;*/
-    } else if (shape == 5) {
-        lcd.drawSprite(_x, _y, 4, 4, (int*)L1Sprite); /*_shape_type = 5;*/
-    } else if (shape == 6) {
-        lcd.drawSprite(_x, _y, 4, 4, (int*)Z1Sprite); /*_shape_type = 6;*/
-    }
-// return _shape_type;
+    _speed = 1;
+    _x = WIDTH/2 - 2;
+    _y = HEIGHT;
+    
+    _velocity.x = speed;
+    _velocity.y = speed;
 }
-    
-    
-    
-
 
 void Tetromino::update(Direction d, float mag)
 {
@@ -114,10 +62,12 @@
     if (_x < 1) {
         _x = 1;
     }
-    if (_x > WIDTH - _width - 1) {
-        _x = WIDTH - _width - 1;
+    if (_x > WIDTH - 3) {
+        _x = WIDTH - 3;
     }
 }
+
+
 Vector2D Tetromino::get_pos() {
     Vector2D p = {_x,_y};
     return p;