Untitled
unknown
plain_text
a year ago
1.3 kB
10
Indexable
#include "Game.h"
#include <iostream>
Game::Game()
: window(sf::VideoMode(720, 960), "The Game!"), timer(0), delay(0.3f), gameOver(false) {
// Khởi tạo tất cả các phần tử trong mảng `field` về 0
for (int i = 0; i < 23; ++i) {
for (int j = 0; j < 10; ++j) {
field[i][j] = 0;
}
}
// Load textures and fonts
t1.loadFromFile("images/tiles.png");
t2.loadFromFile("images/background.png");
t3.loadFromFile("images/frame.png");
font.loadFromFile("Roboto-Regular.ttf");
s.setTexture(t1);
s.setScale(2, 2);
frame.setTexture(t3);
background.setSize(sf::Vector2f(720, 960));
background.setFillColor(sf::Color(200, 220, 255, 180));
// Initialize text objects
// ... (Initialize all your texts here, similar to how you did in main)
resetGame();
}
void Game::resetGame() {
// Đặt lại tất cả các phần tử của mảng `field` về 0
for (int i = 0; i < 23; ++i) {
for (int j = 0; j < 10; ++j) {
field[i][j] = 0;
}
}
currentTetromino.generateNewTetromino();
nextTetromino.generateNewTetromino(); // Khởi tạo tetromino tiếp theo
score.reset();
gameOver = false;
timer = 0;
}
// Các hàm khác giữ nguyên...Editor is loading...
Leave a Comment