Select Git revision
palya.cpp 1.61 KiB
#include "palya.h"
#include "palyamezo.h"
#include "mester.h"
#include "player.h"
#include "textwidget.h"
using namespace std;
using namespace genv;
Palya::Palya()
{
gout.open(XX,YY);
gout << font("LiberationSans-Regular.ttf",32);
for(int i = 1; i<=20; i++){
for(int j = 1; j<=20; j++){
Palyamezo* negyzet = new Palyamezo(this, 100+((i-1)*40), 100+((j-1)*40), 40, 40, 20*(i-1)+j);
palyaterulet.push_back(negyzet);
negyzet->draw();
}
}
mesztor = new Mester();
title = new TextWidget(this, 410, 30, 200, 50, "Tic-tac-toe");
title->draw();
gout << font("LiberationSans-Regular.ttf",24);
bo3 = new TextWidget(this, 30, 30, 200, 50, "Best of 3");
bo3->draw();
gout << font("LiberationSans-Regular.ttf",26);
pontok1 = new TextWidget(this, 300, 920, 40, 40, "0");
pontok2 = new TextWidget(this, 700, 920, 40, 40, "0");
nev1 = new TextWidget(this, 140, 920, 100, 40, mesztor->player1->get_name());
nev2 = new TextWidget(this, 800, 920, 100, 40, mesztor->player2->get_name());
pontok1->draw();
pontok2->draw();
nev1->draw();
nev2->draw();
}
void Palya::jatek(event ev){
mesztor->set_negyzetek(palyaterulet);
for(Palyamezo* negyzet : palyaterulet){
mesztor->iranyitas(negyzet, ev);
mesztor->szabalyzat(negyzet);
}
}
void Palya::grafikai_valtozas(){
pontok1->set_text(to_string(mesztor->player1->get_pontszam()));
pontok2->set_text(to_string(mesztor->player2->get_pontszam()));
pontok1->draw();
pontok2->draw();
}
Palya::~Palya() {}