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:
3:522c6f850e91
Child:
4:7ddd287a5d28
diff -r 55092965eadd -r 522c6f850e91 Tetromino/Tetromino.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tetromino/Tetromino.cpp	Sun May 24 11:18:33 2020 +0000
@@ -0,0 +1,124 @@
+#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,},
+};
+
+Tetromino::Tetromino()
+{
+    
+}
+
+Tetromino::~Tetromino()
+{
+    
+}
+
+void Tetromino::init(int x, int height, int width)
+{
+    _x = x;
+    _y = HEIGHT/2 - height/2;
+    _height = height;
+    _width = width;
+    _speed = 1;
+    
+}
+
+
+
+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;
+}
+    
+    
+    
+
+
+void Tetromino::update(Direction d, float mag)
+{
+    _speed = int(mag*10.0f);
+    
+    if (d == CENTRE) {
+        _y+=_speed;
+    } else if (d == S) {
+        _y+=_speed*2;
+    } else if (d == E) {
+        _x+=_speed;
+    } else if (d == W) {
+        _x-=_speed;
+    }
+        
+    if (_x < 1) {
+        _x = 1;
+    }
+    if (_x > WIDTH - _width - 1) {
+        _x = WIDTH - _width - 1;
+    }
+}
+Vector2D Tetromino::get_pos() {
+    Vector2D p = {_x,_y};
+    return p;
+}
\ No newline at end of file