![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
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.
Diff: Tetromino/Tetromino.cpp
- Revision:
- 6:39cbec524483
- Parent:
- 4:7ddd287a5d28
- Child:
- 7:80e1c83b9b6a
--- a/Tetromino/Tetromino.cpp Sun May 31 17:35:30 2020 +0000 +++ b/Tetromino/Tetromino.cpp Sun May 31 20:41:41 2020 +0000 @@ -1,24 +1,5 @@ #include "Tetromino.h" -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() { @@ -29,20 +10,21 @@ } -void Tetromino::init(int number, int x, int y, int speed) +void Tetromino::init(int x, int y, int height, int width, int speed) { - _x = x; - _y = y; - _speed = speed; - _number = blockArray[blocknumber]; - + _x = WIDTH/2 - width/2; + _y = HEIGHT/2 - height/2; + + _height = height; + _width = width; _speed = 1; - _x = WIDTH/2 - 2; - _y = HEIGHT; - - _velocity.x = speed; - _velocity.y = speed; + +} + +void Tetromino::draw(N5110 &lcd) +{ + lcd.drawRect(WIDTH/2 - _width/2, HEIGHT, 4, 4, FILL_BLACK); } void Tetromino::update(Direction d, float mag) @@ -62,11 +44,22 @@ if (_x < 1) { _x = 1; } - if (_x > WIDTH - 3) { - _x = WIDTH - 3; + if (_x > WIDTH - 1) { + _x = WIDTH - 1; } } +/*void Tetromino::set_velocity(Vector2D v) +{ + _velocity.x = v.x; + _velocity.y = v.y; +}*/ + +Vector2D Tetromino::get_velocity() +{ + Vector2D v = {_velocity.x,_velocity.y}; + return v; +} Vector2D Tetromino::get_pos() { Vector2D p = {_x,_y};