Skip to content
Snippets Groups Projects
Commit 86f09ccc authored by Papp Benjámin's avatar Papp Benjámin
Browse files

eger iranyitas, mester létrehozva

parent b8b82252
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,13 @@ using namespace genv; ...@@ -5,12 +5,13 @@ using namespace genv;
int main() int main()
{ {
event ev;
Palya* tictac = new Palya(); Palya* tictac = new Palya();
event ev;
while (gin >> ev && ev.keycode!=key_escape) while (gin >> ev && ev.keycode!=key_escape)
{ {
tictac->proba(ev); tictac->jatek(ev);
gout << refresh; gout << refresh;
} }
} }
......
#include "mester.h"
#include "palya.h"
#include "palyamezo.h"
#include <iostream>
using namespace genv;
Mester::Mester(Palya* _p) : p(_p) {}
void Mester::iranyitas(Palyamezo* f, event ev) {
if(f->hozzaer(ev) && !f->filled)
f->chosen_draw();
if(!f->hozzaer(ev) && !f->filled)
f->draw();
if(f->select(ev) && !f->filled)
lepes = true;
}
void Mester::turn() {}
Mester::~Mester() {}
mester.h 0 → 100644
#ifndef MESTER_H
#define MESTER_H
#include "graphics.hpp"
class Palya;
class Palyamezo;
class Mester
{
Palya* p;
genv::event ev;
bool lepes = false;
public:
Mester(Palya* _p);
void iranyitas(Palyamezo* f, genv::event ev);
void turn();
~Mester();
};
#endif // MESTER_H
#include <iostream> #include <iostream>
#include "palya.h" #include "palya.h"
#include "palyamezo.h"
#include "mester.h"
using namespace std; using namespace std;
using namespace genv; using namespace genv;
...@@ -9,20 +11,17 @@ Palya::Palya() ...@@ -9,20 +11,17 @@ Palya::Palya()
gout.open(XX,YY); gout.open(XX,YY);
for(int i = 0; i<20; i++){ for(int i = 0; i<20; i++){
for(int j = 0; j<20; j++){ for(int j = 0; j<20; j++){
Palyamezo* proba = new Palyamezo(this, 100+(i*40), 100+(j*40), 40, 40, i, j); Palyamezo* negyzet = new Palyamezo(this, 100+(i*40), 100+(j*40), 40, 40, i, j);
palyaterulet.push_back(proba); palyaterulet.push_back(negyzet);
negyzet->draw();
} }
} }
for(Widget* r : palyaterulet) mesztor = new Mester(this);
r->draw();
} }
void Palya::proba(event ev) void Palya::jatek(event ev){
{ for(Palyamezo* negyzet : palyaterulet)
for(Palyamezo* r : palyaterulet){ mesztor->iranyitas(negyzet, ev);
if(r->hozzaer(ev))
cout << r->index_m << " - " << r->index_n << endl;
}
} }
Palya::~Palya() {} Palya::~Palya() {}
#ifndef PALYA_H #ifndef PALYA_H
#define PALYA_H #define PALYA_H
#include <vector> #include <vector>
#include "palyamezo.h" #include "graphics.hpp"
class Mester;
class Palyamezo;
class Palya class Palya
{ {
std::vector<Palyamezo*> palyaterulet;
public:
const int XX = 1000; const int XX = 1000;
const int YY = 1000; const int YY = 1000;
public:
Palya(); Palya();
void proba(genv:: event ev); std::vector<Palyamezo*> palyaterulet;
Mester* mesztor;
void jatek(genv::event ev);
~Palya(); ~Palya();
}; };
......
...@@ -5,11 +5,17 @@ using namespace genv; ...@@ -5,11 +5,17 @@ using namespace genv;
Palyamezo::Palyamezo(Palya* _p, int _x, int _y, int _w, int _h, int _m, int _n) : Palyamezo::Palyamezo(Palya* _p, int _x, int _y, int _w, int _h, int _m, int _n) :
Widget(_p, _x, _y, _w, _h), index_m(_m), index_n(_n) {} Widget(_p, _x, _y, _w, _h), index_m(_m), index_n(_n) {}
Palyamezo::~Palyamezo() {}
void Palyamezo::draw(){ void Palyamezo::draw(){
int t = 255; int t = 255;
gout << move_to(x,y) << color(t,t,t) << box(w,h); gout << move_to(x,y) << color(t,t,t) << box(w,h);
t = 0; t = 0;
gout << move_to(x+1,y+1) << color(t,t,t) << box(w-2,h-2); gout << move_to(x+1,y+1) << color(t,t,t) << box(w-2,h-2);
} }
void Palyamezo::chosen_draw()
{
int t = 175;
gout << move_to(x+1,y+1) << color(t,t,t) << box(w-2,h-2);
}
Palyamezo::~Palyamezo() {}
...@@ -4,12 +4,14 @@ ...@@ -4,12 +4,14 @@
class Palyamezo : public Widget class Palyamezo : public Widget
{ {
int index_m;
int index_n;
public: public:
Palyamezo(Palya* _p, int _x, int _y, int _w, int _h, int _m, int _n); Palyamezo(Palya* _p, int _x, int _y, int _w, int _h, int _m, int _n);
~Palyamezo(); ~Palyamezo();
int index_m;
int index_n;
void draw() override; void draw() override;
void chosen_draw();
bool filled = false;
}; };
#endif // PALYAMEZO_H #endif // PALYAMEZO_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment