-
Build the binary
/usr/bin/cmake --build /home/laptop/git/kyberdrb/Tetris/cmake-build-debug --target Tetris -j 1
-
Run the game
-
on Linux
./Tetris
-
on Windows
./Tetris.exe
-
-
ConstructionSite (stavenisko - hracia plocha)
-
BuildingBlock /
Polyomino
-
multiple Bricks/Monominos together in various shapes
-
abstract class/interface -
Component
-
Brick
/Monomino
-
single brick - tehlička - polyomino consisting of a single brick; the Leaf class in Composite design pattern)
-
-
Domino
-
Polyomino type of order 2
-
Composite specialization - two bricks glued together by their sides
-
Types:
-
Straight only
# #
##
-
-
-
Tromino
-
Polyomino type of order 3
-
Composite specialization - three bricks glued together by their sides
-
Types:
-
Straight
# # #
###
-
L
# ##
## #
## #
# ##
-
-
-
Tetromino
-
Polyomino type of order 4
-
Composite specialization - four bricks glued together by their sides
-
Types:
-
Straight
# # # #
####
-
Square
## ##
-
L
# # ##
### #
## # #
# ###
-
T
### #
# ## #
# ###
# ## #
-
S
/ skew## ##
# ## #
-
-
-
-
Monomino has fallen to the bottom OR Monomino has fallen onto another Monomino (two bricks/monominos are on top of each other) - the (active/moving/falling) brick stops moving (deactivates/freezes) and next brick is created, appears and starts falling
-
Every Polyomino will have the ability to
rotate
itself (clockwise/counterclockwise),flip horizontally
- horizontal symmetry,flip vertically
- vertical symmetry
-
Basic rotation
Rotate domino by the pivot - the first monomino
f: first monomino - the pivot
s: second monomino
Rotation/Orientation
0 -> 90 -> 180 -> 270
s
fs -> f -> sf -> f
s
## -> # (2, 4)
(2, 4) (2, 5) # (3, 4) second monomino: move down, move left
# (2, 4) -> ## (2, 4) (2, 5) second monomino: move right, move up
# (3, 4)
Full rotation
Recalculation of coordinates and their order for 'freeOrthogonalNeighboursForFirstMonomino'
Domino: lookAroundFirstMonomino()
Domino full coords: under, left, above, right
| fs | (0, 2), (0, 3): (1, 2), (0, 1), (-1, 2), (0, 3)
| | ^^^^^^
| | removed because row index is out of bounds
| |
``````
Domino: rotateClockwise()
Domino full coords: 1st clockwise option from current position for second monomino; 2nd rotation position for second monomino; 3rd rotation position; current position of Monomino
| fs | (0, 2), (0, 3): (1, 2), (0, 1), (0, 3)
| | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
| |
``````
Domino: rotateClockwise()
| f | (0, 2), (1, 2): (0, 1), (0, 3), (1, 2)
| s | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
| |
``````
Domino: rotateClockwise()
|sf | (0, 2), (0, 1): (0, 3), (1, 2), (0, 1)
| | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
| |
``````
Domino: rotateClockwise()
| fs | (0, 2), (0, 3): (1, 2), (0, 1), (0, 3)
| |
| |
| |
``````
Domino: moveLeft()
Domino: lookAroundFirstMonomino()
Domino full coords: under, left, above, right
(0, 1), (0, 2): (1, 1), (0, 0), (-1, 1), (0, 2)
^^^^^^ ^^^^^< removed; row index out of bounds
removed: playing field boundary / non-blank sign
freeOrthogonalNeighbours: (1, 1), (0, 2)
|fs | (0, 1), (0, 2): (1, 1), (0, 2)
| | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
| |
``````
Domino: rotateClockwise()
|f | (0, 1), (1, 1): (0, 2), (1, 1)
|s | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
| |
``````
Domino: rotateClockwise()
|fs | (0, 1), (0, 2): (1, 1), (0, 2)
| |
| |
| |
``````
Domino: moveDown()
Domino: lookAroundFirstMonomino()
Domino full coords: under, left, above, right
(1, 1), (1, 2): (2, 1), (1, 0), (0, 1), (1, 2)
^^^^^^
removed: playing field boundary / non-blank sign
freeOrthogonalNeighbours: (2, 1), (0, 1), (1, 2) - maybe some adjustment is needed
| |
|fs | (1, 1), (1, 2): (2, 1), (0, 1), (1, 2)
| | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
``````
Domino: rotateClockwise()
| |
|f | (1, 1), (2, 1): (0, 1), (1, 2), (2, 1)
|s | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
``````
Domino: rotateClockwise()
|s |
|f | (1, 1), (0, 1): (1, 2), (2, 1), (0, 1)
| | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
``````
Domino: rotateClockwise()
| |
|fs | (1, 1), (1, 2): (2, 1), (0, 1), (1, 2)
| | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
``````
Domino: moveRight()
Domino: lookAroundFirstMonomino()
Domino full coords: under, left, above, right
(1, 2), (1, 3): (2, 2), (1, 1), (0, 2), (1, 3)
freeOrthogonalNeighbours: (2, 2), (1, 1), (0, 2), (1, 3)
| |
| fs | (1, 2), (1, 3): (2, 2), (1, 1), (0, 2), (1, 3)
| | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
``````
Domino: rotateClockwise()
| |
| f | (1, 2), (2, 2): (1, 1), (0, 2), (1, 3), (2, 2)
| s | ^^^^^^
| | next clockwise rotation coordinate are applied for second monomino and moved to the end
``````
Domino: moveRight()
Domino: lookAroundFirstMonomino()
Domino full coords: under, left, above, right
(1, 3), (2, 3): (2, 3), (1, 1), (0, 3), (1, 4)
freeOrthogonalNeighbours: (2, 3), (1, 1), (0, 3), (1, 4)
Domino: adjust coordinate order for clockwise rotation by current Domino orientation
current Domino orientation: 270 degrees
freeOrthogonalNeighbours: (1, 1), (0, 3), (1, 4), (2, 3) - move front element to the back one time
| |
| f | (1, 3), (2, 3): (1, 1), (0, 3), (1, 4), (2, 3)
| s |
| |
``````
for each commit related to Tetris directory
do
cp README.adoc /home/laptop/git/kyberdrb/Tetris
cp CMakeLists.txt /home/laptop/git/kyberdrb/Tetris
cp --recursive src/ /home/laptop/git/kyberdrb/Tetris/
cp --recursive tests/ /home/laptop/git/kyberdrb/Tetris/
git log | tac
git checkout
---
git status && date
date && git status && echo "" && git diff && date
SPACE
isBrickActive -> isActiveBrickActive
git add --all
git commit -m "some commit message"
git push
-
clockwise rotacia Domina
-
urobit clockwise otacanie vo vsetkych dostupnych smeroch; nedostupne smery preskocit/vymazat: - OK
-
zoznam suradnic pre vsetky ortogonalne pozicie dostat do ConstructionSite z Domina cez navratovu hodnotu ako temporary vector - OK
-
rozdelit skenovanie (a este neimplementovany order adjustment) pre adjacentNeighbours v Domine, KTORE bude skenovane po posunuti/vytvoreni Domina, OD clockwise rotacie Domina a rotacie suradnic - OK
-
zoznam dostupnych suradnic pre rotaciu bude ulozeny ako atribut v Domine, a bude sa aktualizovať (zmaze sa a znova sa naplni aktualnymi suradnicami) po každom pohybe a po vytvorení (alebo skor zviditelneni?) z ContstructionSite podla toho, ci nejake frozen monomino nestoji v ceste, resp ci je pozicia na cielovych suradniciach volna (BLANK); suradnicu, ktora je obsadena frozen Dominom, preskocit/ignorovat; zoznam bude vzdy obsahovať aspon sucasnu poziciu Domina (na zaciatku ako posledny prvok); zoznam bude ulozeny ako deque; po kazdej rotacii sa zoznam suradnic zrotuje, t.j. prva suradnica sa presunie na koniec - OK
-
po implememtacii clockwise rotacie upravit v ConstructionSite boundary checky pre pohyb Domina vlavo/vpravo/dole, lebo logika pre pohyb sa spolieha na predpoklad ze pri horizontalnom Domine su monomina v poradi - OK
-
pred commitom: precistit kod, otestovat vsetky rotacie, pphyb a blokacie o ine Domino alebo playing field boundary pri rotovanom domine - OK
-
-
Tetris: to be implemented
-
counterclockwise rotation
-
horizontal flip
-
vertical flip
-
-
Tetris general
-
Game Loop
-
Erase element in
std::vector
-
https://duckduckgo.com/?t=ffab&q=c%2B%2B+vector+erase+element+at+index&ia=web
-
https://stackoverflow.com/questions/875103/how-do-i-erase-an-element-from-stdvector-by-index
-
https://duckduckgo.com/?t=ffab&q=c%2B%2B+vector+for+each+erase&ia=web
-
https://stackoverflow.com/questions/3938838/erasing-from-a-stdvector-while-doing-a-for-each
-
https://duckduckgo.com/?t=ffab&q=c%2B%2B+vector+iterator+for+loop&ia=web
-
https://stackoverflow.com/questions/12702561/iterate-through-a-c-vector-using-a-for-loop
-
https://duckduckgo.com/?t=ffab&q=c%2B%2B+vector+iterator+for+loop+erase&ia=web
-
https://stackoverflow.com/questions/4645705/vector-erase-iterator
-
https://duckduckgo.com/?t=ffab&q=c%2B%2B+vector+remove_if+example&ia=web
-
https://stackoverflow.com/questions/7958216/c-remove-if-on-a-vector-of-objects
-