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.

Committer:
el18rs
Date:
Sun May 31 17:01:53 2020 +0000
Revision:
4:7ddd287a5d28
Parent:
3:522c6f850e91
Child:
6:39cbec524483
Includes most parts but still has errors that need fixing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el18rs 3:522c6f850e91 1 #include "Tetromino.h"
el18rs 3:522c6f850e91 2
el18rs 4:7ddd287a5d28 3 int tetromino[3][4][4] = {
el18rs 4:7ddd287a5d28 4 {
el18rs 4:7ddd287a5d28 5 {1,1,1,1},
el18rs 4:7ddd287a5d28 6 {1,1,1,1},
el18rs 4:7ddd287a5d28 7 {1,1,1,1},
el18rs 4:7ddd287a5d28 8 {1,1,1,1}
el18rs 4:7ddd287a5d28 9 }, {
el18rs 4:7ddd287a5d28 10 {1,1,1,1},
el18rs 4:7ddd287a5d28 11 {1,1,1,1},
el18rs 4:7ddd287a5d28 12 {1,1,1,1},
el18rs 4:7ddd287a5d28 13 {1,1,1,1}
el18rs 4:7ddd287a5d28 14 }, {
el18rs 4:7ddd287a5d28 15 {1,1,1,1},
el18rs 4:7ddd287a5d28 16 {1,1,1,1},
el18rs 4:7ddd287a5d28 17 {1,1,1,1},
el18rs 4:7ddd287a5d28 18 {1,1,1,1}
el18rs 4:7ddd287a5d28 19 }
el18rs 3:522c6f850e91 20 };
el18rs 3:522c6f850e91 21
el18rs 3:522c6f850e91 22 Tetromino::Tetromino()
el18rs 3:522c6f850e91 23 {
el18rs 3:522c6f850e91 24
el18rs 3:522c6f850e91 25 }
el18rs 3:522c6f850e91 26
el18rs 3:522c6f850e91 27 Tetromino::~Tetromino()
el18rs 3:522c6f850e91 28 {
el18rs 3:522c6f850e91 29
el18rs 3:522c6f850e91 30 }
el18rs 3:522c6f850e91 31
el18rs 4:7ddd287a5d28 32 void Tetromino::init(int number, int x, int y, int speed)
el18rs 3:522c6f850e91 33 {
el18rs 3:522c6f850e91 34 _x = x;
el18rs 4:7ddd287a5d28 35 _y = y;
el18rs 4:7ddd287a5d28 36 _speed = speed;
el18rs 4:7ddd287a5d28 37 _number = blockArray[blocknumber];
el18rs 3:522c6f850e91 38
el18rs 3:522c6f850e91 39
el18rs 4:7ddd287a5d28 40 _speed = 1;
el18rs 4:7ddd287a5d28 41 _x = WIDTH/2 - 2;
el18rs 4:7ddd287a5d28 42 _y = HEIGHT;
el18rs 4:7ddd287a5d28 43
el18rs 4:7ddd287a5d28 44 _velocity.x = speed;
el18rs 4:7ddd287a5d28 45 _velocity.y = speed;
el18rs 3:522c6f850e91 46 }
el18rs 3:522c6f850e91 47
el18rs 3:522c6f850e91 48 void Tetromino::update(Direction d, float mag)
el18rs 3:522c6f850e91 49 {
el18rs 3:522c6f850e91 50 _speed = int(mag*10.0f);
el18rs 3:522c6f850e91 51
el18rs 3:522c6f850e91 52 if (d == CENTRE) {
el18rs 3:522c6f850e91 53 _y+=_speed;
el18rs 3:522c6f850e91 54 } else if (d == S) {
el18rs 3:522c6f850e91 55 _y+=_speed*2;
el18rs 3:522c6f850e91 56 } else if (d == E) {
el18rs 3:522c6f850e91 57 _x+=_speed;
el18rs 3:522c6f850e91 58 } else if (d == W) {
el18rs 3:522c6f850e91 59 _x-=_speed;
el18rs 3:522c6f850e91 60 }
el18rs 3:522c6f850e91 61
el18rs 3:522c6f850e91 62 if (_x < 1) {
el18rs 3:522c6f850e91 63 _x = 1;
el18rs 3:522c6f850e91 64 }
el18rs 4:7ddd287a5d28 65 if (_x > WIDTH - 3) {
el18rs 4:7ddd287a5d28 66 _x = WIDTH - 3;
el18rs 3:522c6f850e91 67 }
el18rs 3:522c6f850e91 68 }
el18rs 4:7ddd287a5d28 69
el18rs 4:7ddd287a5d28 70
el18rs 3:522c6f850e91 71 Vector2D Tetromino::get_pos() {
el18rs 3:522c6f850e91 72 Vector2D p = {_x,_y};
el18rs 3:522c6f850e91 73 return p;
el18rs 3:522c6f850e91 74 }