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:
Wed Jun 03 22:27:46 2020 +0000
Revision:
26:00e1a6076038
Parent:
25:a7c89c54454a
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el18rs 3:522c6f850e91 1 #include "Tetromino.h"
el18rs 3:522c6f850e91 2
el18rs 3:522c6f850e91 3 Tetromino::Tetromino()
el18rs 3:522c6f850e91 4 {
el18rs 23:cbfa9d1ee3db 5
el18rs 3:522c6f850e91 6 }
el18rs 3:522c6f850e91 7
el18rs 3:522c6f850e91 8 Tetromino::~Tetromino()
el18rs 3:522c6f850e91 9 {
el18rs 23:cbfa9d1ee3db 10
el18rs 3:522c6f850e91 11 }
el18rs 3:522c6f850e91 12
el18rs 23:cbfa9d1ee3db 13 void Tetromino::init(int x, int y)
el18rs 3:522c6f850e91 14 {
el18rs 10:7310c9440547 15 _x = x;
el18rs 10:7310c9440547 16 _y = y;
el18rs 4:7ddd287a5d28 17 _speed = 1;
el18rs 6:39cbec524483 18
el18rs 6:39cbec524483 19 }
el18rs 6:39cbec524483 20
el18rs 6:39cbec524483 21 void Tetromino::draw(N5110 &lcd)
el18rs 6:39cbec524483 22 {
el18rs 11:0183a52c1077 23 lcd.drawRect(_x, _y, 4, 4, FILL_BLACK);
el18rs 3:522c6f850e91 24 }
el18rs 3:522c6f850e91 25
el18rs 3:522c6f850e91 26 void Tetromino::update(Direction d, float mag)
el18rs 3:522c6f850e91 27 {
el18rs 17:70d45e9e44a8 28 _speed = int(mag*2.5f);
el18rs 23:cbfa9d1ee3db 29
el18rs 25:a7c89c54454a 30 if (d == S) {
el18rs 8:cebb2aca8e19 31 _y+=_speed;
el18rs 3:522c6f850e91 32 } else if (d == E) {
el18rs 8:cebb2aca8e19 33 _x+=_speed;
el18rs 12:965b39a2e049 34 // printf("d = %i, x = %i, y = %i, speed = %i\n",d,_x,_y,_speed);
el18rs 3:522c6f850e91 35 } else if (d == W) {
el18rs 8:cebb2aca8e19 36 _x-=_speed;
el18rs 12:965b39a2e049 37 // printf("d = %i, x = %i, y = %i, speed = %i\n",d,_x,_y,_speed);
el18rs 3:522c6f850e91 38 }
el18rs 23:cbfa9d1ee3db 39
el18rs 19:2ad31dbd5d11 40 if (_x < 20) {
el18rs 19:2ad31dbd5d11 41 _x = 20;
el18rs 19:2ad31dbd5d11 42 printf("left wall hit\n");
el18rs 23:cbfa9d1ee3db 43 } else if (_x > 56) {
el18rs 19:2ad31dbd5d11 44 _x = 56;
el18rs 19:2ad31dbd5d11 45 printf("right wall hit\n");
el18rs 3:522c6f850e91 46 }
el18rs 19:2ad31dbd5d11 47 // printf("back corner of block = (%i,%i)\n",_x,_y);
el18rs 19:2ad31dbd5d11 48 // printf("front corner of block = (%i, %i)\n",_x+3,_y+3);
el18rs 3:522c6f850e91 49 }
el18rs 4:7ddd287a5d28 50
el18rs 23:cbfa9d1ee3db 51 Vector2D Tetromino::get_pos()
el18rs 6:39cbec524483 52 {
el18rs 3:522c6f850e91 53 Vector2D p = {_x,_y};
el18rs 3:522c6f850e91 54 return p;
el18rs 3:522c6f850e91 55 }