|
|
@ -88,6 +88,7 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
window.clear();
|
|
|
|
window.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Horizontal movement
|
|
|
|
int movement = 0;
|
|
|
|
int movement = 0;
|
|
|
|
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left))
|
|
|
|
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left))
|
|
|
|
movement--;
|
|
|
|
movement--;
|
|
|
@ -114,6 +115,7 @@ int main()
|
|
|
|
block.position.x += movement;
|
|
|
|
block.position.x += movement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Drawing block and land checking
|
|
|
|
shape.setFillColor(block.type->tile_type->color);
|
|
|
|
shape.setFillColor(block.type->tile_type->color);
|
|
|
|
bool landed = false;
|
|
|
|
bool landed = false;
|
|
|
|
for (int y = 0; y < 2; y++) {
|
|
|
|
for (int y = 0; y < 2; y++) {
|
|
|
@ -130,6 +132,8 @@ int main()
|
|
|
|
window.draw(shape);
|
|
|
|
window.draw(shape);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Landing (transfering block to grid and reinitializing)
|
|
|
|
if (landed) {
|
|
|
|
if (landed) {
|
|
|
|
for (int y = 0; y < 2; y++) {
|
|
|
|
for (int y = 0; y < 2; y++) {
|
|
|
|
for (int x = 0; x < 4; x++) {
|
|
|
|
for (int x = 0; x < 4; x++) {
|
|
|
@ -141,12 +145,12 @@ int main()
|
|
|
|
grid[global_y][global_x] = block.type->tile_type;
|
|
|
|
grid[global_y][global_x] = block.type->tile_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
landed = false;
|
|
|
|
|
|
|
|
block = Block();
|
|
|
|
block = Block();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
block.position.y++;
|
|
|
|
block.position.y++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Drawing grid
|
|
|
|
for (int y = 0; y < GRID_HEIGHT; y++) {
|
|
|
|
for (int y = 0; y < GRID_HEIGHT; y++) {
|
|
|
|
for (int x = 0; x < GRID_WIDTH; x++) {
|
|
|
|
for (int x = 0; x < GRID_WIDTH; x++) {
|
|
|
|
auto tile_type = grid[y][x];
|
|
|
|
auto tile_type = grid[y][x];
|
|
|
|