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:
5:53e021832adc
--- a/TetrisGame/TetrisGame.cpp	Sun May 24 11:18:33 2020 +0000
+++ b/TetrisGame/TetrisGame.cpp	Sun May 31 17:01:53 2020 +0000
@@ -10,81 +10,79 @@
     
 }
 
-void TetrisGame::init(int tetromino_width, int tetromino_height, int tetromino_size, int speed)
+void TetrisGame::init(int number, int x, int y, int speed)
 {
-    _tetromino_width = tetromino_width;
-    _tetromino_height = tetromino_height;
-    _tetromino_size = tetromino_size;
+    // initialise game parameters
+    _number = blockArray[blocknumber];
+    _x = x;
+    _y = y;
     _speed = speed;
     
-    // CHANGE SO STARTS AT TOP?
-    _p1x = GAP;
-    _p1.init(_p1x,_tetromino_height,_tetromino_width);
-    _tetromino.init(_tetromino_height, _tetromino_width, _tetromino_size,_speed);
+    _tetromino.init(_number, WIDTH/2 - 2, HEIGHT, _speed); // puts tetromino in middle SHOULD THIS INCLUDE ARRAY????
+    
 }
 
+
 void TetrisGame::read_input(Gamepad &pad)
 {
     _d = pad.get_direction();
-    _mag = pad.getmag();
+    _mag = pad.get_mag();
 }
 
 void TetrisGame::draw(N5110 &lcd)
 {
+    // draw elements in lcd buffer 
     
+    // board
     lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT);
     
-    _p1.draw(lcd);
-}
-
-void TetrisGame::update(Gamepax &pad)
-{
-    check_goal(pad);
+    _tetromino.draw(lcd, _number);
     
-    _p1.update(_d,_mag);
     
-    check_floor_collision(pad);
-    check_tetromino_collisions(pad);
 }
 
-void TetrisGame::check_floor_collision(Gamepad &pad)
+void TetrisGame::update(Gamepad &pad)
 {
-    Vector2D tetromino_pos = _tetromino.get_pos();
+    // check_score(pad);
+    
+    // _p1.update(_d,_mag);
+    _tetromino.update(_d,_mag);
     
-    if (tetromino_pos.y + _tetromino_size >= (HEIGHT-1) ) {
-        
-        tetromino_pos.y = (HEIGHT-1) - _tetromino_size;
-        tetromino_velocity.y = 0;
-        
-        pad.tone(750.0,0.1);
-    }
- // update tetromino parameters??   
+    check_wall_collision(pad);
+    check_tetromino_collisions();
 }
-    
-void TetrisGame::check_tetromino_collisions(Gamepad &pad)
+
+
+void TetrisGame::check_wall_collision(Gamepad &pad)
 {
     Vector2D tetromino_pos = _tetromino.get_pos();
     Vector2D tetromino_velocity = _tetromino.get_velocity();
     
-    Vector2D p1_pos = _p1.get_pos();
-    
-    if (
-    (tetromino_pos.y >= p1_pos.y) && 
-    (tetromino_pos.y <= p1_pos.y + _tetromino_height) &&
-    (tetromino_pos.x >= _p1x) &&
-    (tetromino_pos.x <= _plx + _tetromino_width)
-    ) {
-        tetromino_pos.x = _plx + _tetromino_width;
-        tetromino_velocity.x = 0;
+    // check if hit floor
+    if (tetromino_pos.y + 4 >= (HEIGHT-1) ) {
+        
+        tetromino_pos.y = (HEIGHT-1) - 4;
+        tetromino_velocity.y = 0;
+        
+        pad.tone(750.0,0.1);
         
-        pad.tone(1000.0,0.1);
+        cancel_line(); // check if line full and cancel + drop down if it is 
+                
+        _tetromino.init(_number, WIDTH/2 - 2, HEIGHT, _speed); // drop new shame
+        
+        blocknumber ++;
+        if (blocknumber > 4) {
+            blocknumber = 0;
+            }
+    }
+    // check if hit roof
+    else if (tetromino_pos.y <= 1) {
+        
+        exit_game();
+                
     }
     
-    
-    
-    
-    
-    
-    
-    
-    
\ No newline at end of file
+    // SAVE OLD SCREEN AND DROP NEW TETROMINO???? //
+ // update tetromino parameters??   
+}
+