Skip to content

Commit ca6cdc4

Browse files
authored
Merge pull request #12 from FLAK-ZOSO/I/O
I/O
2 parents c71415c + 3a4ed6c commit ca6cdc4

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

game.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#include <iostream>
22
#include <cstdlib>
3+
34
#include "time.h"
45

6+
#define CLS "\33[2J\33[H"
7+
58

69
struct Game {
710
char matrix[20][50]; // Il campo di gioco
@@ -112,7 +115,7 @@ void updateMatrix(Game &game_) { // Passo per riferimento la variabile di tipo G
112115

113116

114117
void printMatrix(Game game_) {
115-
system("cls");
118+
std::cout << CLS;
116119

117120
// Stampo la matrice
118121
for (int i = 0; i < 50; i++)
@@ -121,7 +124,7 @@ void printMatrix(Game game_) {
121124
for (int i = 0; i < 20; i++) {
122125
for (int j = 0; j < 50; j++)
123126
std::cout << game_.matrix[i][j];
124-
std::cout << std::endl;
127+
std::cout << '\n';
125128
}
126129
for (int i = 0; i < 50; i++)
127130
std::cout << '#';

labirint.exe

512 Bytes
Binary file not shown.

main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Game game(std::string name) { // Ritorna l'oggetto Game
2727
myGame.zFrames = 0;
2828
myGame.zFuel = 0; // Quante @ devi ancora usare
2929
srand(time(0)); // Rende casuale la generazione di numeri casuali con rand()
30+
// std::ios_base::sync_with_stdio(false); // Rende la console non bloccante
3031

3132
// Informazioni
3233
while ((std::cout << "Bonus frequency (period): ") && (!(std::cin >> myGame.bonusFrequency))) {

0 commit comments

Comments
 (0)