Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
isakura313 committed Mar 24, 2024
1 parent 80e590f commit c1e9742
Show file tree
Hide file tree
Showing 57 changed files with 53 additions and 139 deletions.
Binary file modified cmake-build-debug/.ninja_deps
Binary file not shown.
88 changes: 10 additions & 78 deletions cmake-build-debug/.ninja_log
Original file line number Diff line number Diff line change
@@ -1,79 +1,11 @@
# ninja log v5
378 410 1711026316810668189 untitled 17928892a736b80
5 378 1711026316776902496 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
7 381 1711026352024834581 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
381 411 1711026352057098549 untitled 17928892a736b80
6 380 1711026449827267883 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
380 415 1711026449864671781 untitled 17928892a736b80
6 383 1711026479089308679 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
383 415 1711026479123610335 untitled 17928892a736b80
6 387 1711026518758975255 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
388 420 1711026518793905168 untitled 17928892a736b80
7 389 1711026528954300698 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
389 421 1711026528988288768 untitled 17928892a736b80
8 475 1711026868177088648 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
475 510 1711026868213693121 untitled 17928892a736b80
5 393 1711026984282939099 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
393 423 1711026984315899699 untitled 17928892a736b80
7 467 1711027087493932322 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
467 502 1711027087529791960 untitled 17928892a736b80
5 378 1711027416970441659 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
378 414 1711027417006839829 untitled 17928892a736b80
7 462 1711027472341534016 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
462 499 1711027472379976960 untitled 17928892a736b80
7 475 1711027501550446703 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
475 510 1711027501586903041 untitled 17928892a736b80
7 446 1711027537680152819 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
446 481 1711027537716339362 untitled 17928892a736b80
6 374 1711027566444969149 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
374 406 1711027566478605455 untitled 17928892a736b80
5 391 1711027577310294759 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
391 421 1711027577343210514 untitled 17928892a736b80
6 456 1711027671534062044 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
456 491 1711027671570165545 untitled 17928892a736b80
7 453 1711027711135075857 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
453 488 1711027711171895407 untitled 17928892a736b80
7 459 1711027764268279360 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
459 493 1711027764303486599 untitled 17928892a736b80
7 447 1711027784175107120 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
447 482 1711027784211983546 untitled 17928892a736b80
7 453 1711027817279362825 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
453 487 1711027817314712483 untitled 17928892a736b80
6 443 1711027935552322893 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
443 477 1711027935588474834 untitled 17928892a736b80
6 457 1711028036198717507 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
457 491 1711028036233851709 untitled 17928892a736b80
6 422 1711028060689587302 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
422 454 1711028060724797176 untitled 17928892a736b80
7 474 1711028133371255222 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
474 508 1711028133406719974 untitled 17928892a736b80
6 452 1711028177729318271 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
453 605 1711028177884022161 untitled 17928892a736b80
7 390 1711028207317426166 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
390 422 1711028207351643075 untitled 17928892a736b80
7 451 1711028289609388559 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
451 489 1711028289648329085 untitled 17928892a736b80
7 449 1711028310442823871 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
449 486 1711028310480083719 untitled 17928892a736b80
7 457 1711028362054825991 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
457 493 1711028362092284090 untitled 17928892a736b80
6 452 1711028409710210639 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
452 487 1711028409746289146 untitled 17928892a736b80
7 469 1711028442142954984 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
470 504 1711028442178817573 untitled 17928892a736b80
5 381 1711028478883303085 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
381 410 1711028478915229728 untitled 17928892a736b80
7 461 1711028537140855730 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
461 497 1711028537178476955 untitled 17928892a736b80
6 388 1711028556049055538 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
388 419 1711028556082852778 untitled 17928892a736b80
6 383 1711028580345427192 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
383 415 1711028580379877770 untitled 17928892a736b80
7 710 1711028698569755035 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
711 746 1711028698606173919 untitled 17928892a736b80
7 487 1711028734935075932 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
488 644 1711028735094178353 untitled 17928892a736b80
7 460 1711028765778476659 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
460 495 1711028765814099120 untitled 17928892a736b80
7 455 1711028787683800417 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
455 491 1711028787720265717 untitled 17928892a736b80
20 526 1711273352298667055 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
527 570 1711273352344429815 untitled 17928892a736b80
7 380 1711273420533167665 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
380 411 1711273420567026436 untitled 17928892a736b80
6 408 1711273448645108497 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
408 444 1711273448682150629 untitled 17928892a736b80
7 490 1711273472952374062 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
490 527 1711273472990365689 untitled 17928892a736b80
8 725 1711274302153464594 CMakeFiles/untitled.dir/main.cpp.o 663be03a6d60196e
725 894 1711274302323461905 untitled 17928892a736b80
Binary file modified cmake-build-debug/CMakeFiles/untitled.dir/main.cpp.o
Binary file not shown.
4 changes: 2 additions & 2 deletions cmake-build-debug/Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Start testing: Mar 21 16:46 +03
Start testing: Mar 24 12:58 +03
----------------------------------------------------------
End testing: Mar 21 16:46 +03
End testing: Mar 24 12:58 +03
Binary file modified cmake-build-debug/untitled
Binary file not shown.
100 changes: 41 additions & 59 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,48 @@ int figures[7][4] =
}; // define figures

bool check() {
for (int i = 0; i < 4; i++) {
if (a[i].x < 0 || a[i].x >= N || a[i].y >= M) {
return 0;
}
// }else if (field[a[i].y][a[i].x]) {
// if(field[a[i].y][a[i].x] ==field[b[i].y][b[i].x] ) {
// std::cout << "Hello World!";
// }
//
// return 0;
// }
for (int i = 0; i < 4; i++)
if (a[i].x < 0 || a[i].x >= N || a[i].y >= M) return 0;
else if (field[a[i].y][a[i].x]) return 0;
}

return 1;
};



int main() {
srand(time(0));

RenderWindow window(VideoMode(320, 480), "Tetris");
Music music;
//
// if (!music.openFromFile("back_sound.wav"))
// return -1; // error
// music.play();
music.openFromFile("backgroundSound.wav");

music.openFromFile("music/backgroundSound.wav");
music.setVolume(5.f);
music.setPitch(1.f);
music.play();
Music musicLose;
musicLose.openFromFile("looseSound.wav");

musicLose.openFromFile("music/gameOver.wav");
musicLose.setVolume(5.f);
musicLose.setPitch(1.f);

Music musicLine;
musicLine.openFromFile("happySound.wav");
musicLine.openFromFile("music/happySound.wav");
musicLine.setVolume(5.f);
musicLine.setPitch(1.f);

Font font;
font.loadFromFile("playFont.ttf");
font.loadFromFile("fonts/playFont.ttf");
Text text;
text.setFont(font);
text.setString(std::to_string(countLine));
text.setCharacterSize(50);
text.setFillColor(Color::White);
text.setPosition(260,8);
text.setPosition(260, 8);

Texture t1, t2, t3;
t1.loadFromFile("tiles.png");
t2.loadFromFile("background1.png");
t3.loadFromFile("frame.png");
t1.loadFromFile("images/tiles.png");
t2.loadFromFile("images/background1.png");
t3.loadFromFile("images/frame.png");

Sprite tiles(t1), background(t2), frame(t3);

Expand All @@ -93,10 +84,9 @@ int main() {
Clock clock;

while (window.isOpen()) {
// float time = clock.getElapsedTime().asSeconds();
// clock.restart();
timer += clock.restart().asSeconds();
Event e;

while (window.pollEvent(e)) {
if (e.type == Event::Closed) {
window.close();
Expand All @@ -111,23 +101,21 @@ int main() {
}
}
}
if (Keyboard::isKeyPressed(Keyboard::Down)) {
delay = 0.05;
}
if (Keyboard::isKeyPressed(Keyboard::Down)) {
delay = 0.05;
}

// move
for (int i = 0; i < 4; i++) {

b[i] = a[i];
a[i].x += dx;

}
if (!check()) {
for (int i = 0; i < 4; i++) {
a[i] = b[i];

}
}

// rotate
if (rotate) {
Point center = a[1];
Expand All @@ -143,35 +131,42 @@ int main() {
}
}
}
//tick

// tick
if (timer > delay) {
{
for (int i = 0; i < 4; i++) {
b[i] = a[i];
a[i].y += 1;
}

// Game over
for (int i = 0; i < 4; i++) {
if (field[a[i].y][a[i].x]) {
if(field[a[i].y][a[i].x] ==field[b[i].y][b[i].x] ) {
if (field[a[i].y][a[i].x] == field[b[i].y][b[i].x]) {
std::cout << "Game over!";
// timer = 1000;
musicLose.play();
music.stop();
// window.clear();
sleep(3);
musicLose.play();
// проиграть звук проигрыша
// остановить главную музыку
// можно еще сделать надпись Game over вместо счета
sleep(sf::milliseconds(2500)); // это очевидно костыль, но пока так
window.close();
break;

break; // стоп loop, иначе вылетает игра
}
}

}
// end of game over

if (!check()) {
for (int i = 0; i < 4; i++) {
field[b[i].y][b[i].x] = colorNum;
}
colorNum = 1 + rand() % 7;
int n = rand() % 7;

std::cout << std::to_string(n);

for (int i = 0; i < 4; i++) {
// TODO обсудить появление фигуры
a[i].x = figures[n][i] % 2;
Expand All @@ -183,43 +178,30 @@ int main() {
timer = 0;
}

/////check lose///////
// for (int i= M-1; i> 0; i--) {
// if(field[i][19] != 0) {
// std::cout << std::to_string(field[i][19])+ ";";
//
// }
//
// }
///////check lines//////////
int k = M - 1;
for (int i = M - 1; i > 0; i--) {
int count = 0;
for (int j = 0; j < N; j++) {
if (field[i][j]) {
count++;
}
field[k][j] = field[i][j]; // TODO позже удалить

field[k][j] = field[i][j];
}
if (count < N) {
k = k - 1;
}
else {
} else {
musicLine.play();
countLine = countLine + 1;
text.setString(std::to_string(countLine));

}

}


}

dx = 0;
rotate = 0;
delay = 0.3;
// отрисовка?

window.clear(Color::White);
window.draw(background);
for (int i = 0; i < M; i++)
Expand Down
Loading

0 comments on commit c1e9742

Please sign in to comment.