Skip to content
Snippets Groups Projects
Commit 8da4c928 authored by Monoki Dorina's avatar Monoki Dorina
Browse files

elmenti a beirt adatokat es betolti legkozelebb

parent 7ac08d75
Branches
No related tags found
No related merge requests found
......@@ -68,12 +68,14 @@ void Application::event_loop()
}
std::set<int> aura_halmaz = _game->aura(focus);
// std::set<int> aura_ertekek;
for (int i=0; i<widgets.size(); i++)
{
if (aura_halmaz.find(i) != aura_halmaz.end())
{
action("aura",i,1);
}
else
{
......
File moved
......@@ -4,10 +4,10 @@
using namespace genv;
Field::Field(Application* parent, int x, int y, int meret, int index, int ertek):
Widget(parent, x, y, meret, meret), _index(index), _ertek(ertek)
Widget(parent, x, y, meret, meret), _index(index), _ertek(ertek),
_fix(ertek), _aura(false), _helytelen(false)
{
_fix=_ertek;
_aura=false;
}
void Field::rajzol() const
......@@ -69,10 +69,16 @@ void Field::rajzol() const
gout << move_to(_x, _y+_mag-2) << line(_szel,0);
// szoveg
if (_helytelen)
gout << color(255,0,0);
gout << font("LiberationSans-Regular.ttf",_szel/3);
if (_ertek)
{
gout << move_to(_x+(_szel-gout.twidth(std::to_string(_ertek)))/2,
_y+(_mag+gout.cascent())/2)
gout << move_to(_x+ (_szel-gout.twidth(std::to_string(_ertek)))/2,
_y+(_mag-gout.cascent()-gout.cdescent())/2)
<< text(std::to_string(_ertek));
//gout << text(" ") << text(std::to_string(_aura));
......
......@@ -19,10 +19,11 @@ class Field : public Widget
protected:
int _ertek;
bool _fix;
bool _aura;
int _index;
bool _fix;
bool _aura;
bool _helytelen;
};
#endif // FIELD_HPP
......@@ -6,13 +6,13 @@
using namespace std;
GameMaster::GameMaster(Application* parent, std::string mo, std::string fe) :
_parent(parent), _fajl_megoldas(mo), _fajl_feladat(fe)
_parent(parent), _fajl_megoldas(mo), _fajl_feladat(fe), _fajl_save("save.txt")
{
_parent->register_gm(this);
_megoldas = fajl_beolvasas(_fajl_megoldas);
_feladat = fajl_beolvasas(_fajl_feladat);
_save = _feladat;
_fajl_save = "save.txt";
_save = fajl_beolvasas(_fajl_save);
// megmondja hogy melyik indexek melyik nagy negyzethez tartoznak
_negyzetek.resize(9);
......@@ -94,11 +94,16 @@ void GameMaster::save(int sorszam, int ertek)
save_fajlba();
}
bool GameMaster::szabalyos_e(Index jelenlegi)
bool GameMaster::szabalyos_e(int jelenlegi_ertek, set<int> ertekek)
{
}
std::vector<int> GameMaster::get_feladat()
{
return _feladat;
}
std::vector<int> GameMaster::get_save()
{
return _save;
......
......@@ -16,12 +16,13 @@ class GameMaster
void fajl_kiiras(std::string fajlnev, std::vector<int> v) const;
void save_fajlba();
std::vector<int> get_feladat();
std::vector<int> get_save();
virtual void save(int,int);
std::set<int> aura(Index);
virtual int negyzet_szama(Index);
virtual bool szabalyos_e(Index);
virtual bool szabalyos_e(int,std::set<int>);
protected:
......
......@@ -6,6 +6,8 @@
#include <vector>
#define sorszam_i 9*j+i
using namespace std;
class MyApp : public Application
......@@ -13,15 +15,20 @@ class MyApp : public Application
public:
MyApp(int szel, int mag) : Application(szel,mag)
{
game = new GameMaster(this,"mo1.txt","fe1.txt");
vector<int> game_kezdo = game->get_save();
game = new GameMaster(this,"megoldas.txt","feladat.txt");
vector<int> game_feladat = game->get_feladat();
vector<int> game_save = game->get_save();
for (int j=0; j<9; j++) // sor
{
for (int i=0; i<9; i++) // oszlop
{
Field *f = new Field(this,i*78,j*78,78,9*j+i,game_kezdo[9*j+i]);
Field *f = new Field(this,i*78,j*78,78,sorszam_i,game_feladat[sorszam_i]);
palya.push_back(f);
if (game_feladat[sorszam_i] == 0)
{
palya[sorszam_i]->set_ertek(game_save[sorszam_i]);
}
}
}
}
......
File moved
0 8 5 6 0 1 0 0 0 0 0 6 5 4 0 0 2 1 0 0 0 0 3 0 0 0 0 8 0 7 9 0 4 1 0 0 0 3 0 5 0 7 9 8 6 1 9 0 8 0 0 0 0 0 0 0 3 0 7 0 6 0 0 0 2 0 0 8 5 3 0 0 7 0 8 3 0 6 0 0 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment