-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgame.cpp
More file actions
52 lines (41 loc) · 758 Bytes
/
game.cpp
File metadata and controls
52 lines (41 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <fstream>
#include "game.h"
Game::Game()
{
this->i=0;
this->matrix = new char[100];
std::ifstream f("matrix.bin", std::ios::in|std::ios::binary);
if(f){
this->load(f);
f.close();
}
}
Game::~Game()
{
std::ofstream f("matrix.bin", std::ios::out | std::ios::binary);
if(!f) {
std::cout << "Cannot open file for writting." << std::endl;
}else{
this->save(f);
f.close();
}
delete []this->matrix;
}
void Game::load(std::ifstream &f)
{
}
void Game::save(std::ofstream &f)
{
f.write(this->matrix, 100);
std::cout << "saved " << 100 << " bytes " << std::endl;
}
void Game::update()
{
std::cout << "time " << this->i << std::endl;
this->i++;
}
bool Game::isOver()const
{
return this->i==10;
}