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

jatszhato de nem tud szabalyokat

parent ec7f7534
Branches
No related tags found
No related merge requests found
......@@ -54,6 +54,15 @@ void Application::event_loop()
widgets[9*focus.sor+focus.oszlop]->kezel(ev);
}
if (ev.keycode >= 49 && ev.keycode <= 57)
{
action(9*focus.sor+focus.oszlop, ev.keycode-48);
}
if (ev.keycode==key_delete || ev.keycode==key_backspace)
{
action(9*focus.sor+focus.oszlop, 0);
}
}
for (Widget *w : widgets)
......
......@@ -34,6 +34,7 @@ class Application
virtual void event_loop();
virtual void register_widget(Widget*);
virtual void register_gm(GameMaster*);
virtual void action(int,int) = 0;
protected:
std::vector<Widget*> widgets;
......
#include "field.hpp"
#include <string>
#include <iostream>
using namespace genv;
......@@ -12,23 +13,6 @@ Field::Field(Application* parent, int x, int y, int meret, int index, int ertek)
void Field::rajzol() const
{
/// keret
if (_kijelolt)
{
if (_fix)
gout << color(light_grey);
else
gout << color(light_purple);
}
else
{
if (_fix)
gout << color(dark_grey);
else
gout << color(dark_purple);
}
gout << move_to(_x,_y) << box(_szel,_mag);
/// hatter
if (_kijelolt)
{
......@@ -51,9 +35,9 @@ void Field::rajzol() const
else
gout << color(light_purple);
}
gout << move_to(_x+1,_y+1) << box(_szel-2,_mag-2);
gout << move_to(_x,_y) << box(_szel,_mag);
/// vonalak
/// keret, szoveg
if (_kijelolt)
{
if (_fix)
......@@ -69,27 +53,23 @@ void Field::rajzol() const
gout << color(dark_purple);
}
// keret
gout << move_to(_x,_y) << line(_szel,0) << line(0,_mag) << line(-_szel,0) << line(0,-_mag);
// vonalak
if ((_index%9) % 3 ==0) // bal
gout << move_to(_x+1,_y) << line(0,_mag);
if ((_index%9) % 3 ==2) //jobb
gout << move_to(_x+_szel-2,_y) << line(0,_mag);
gout << move_to(_x+1, _y) << line(0,_mag);
/// szoveg
if (_kijelolt)
{
if (_fix)
gout << color(light_grey);
else
gout << color(light_purple);
}
else
{
if (_fix)
gout << color(dark_grey);
else
gout << color(dark_purple);
}
if ((_index%9) % 3 ==2) // jobb
gout << move_to(_x+_szel-2, _y) << line(0,_mag);
if ((_index/9) % 3 ==0) // font
gout << move_to(_x, _y+1) << line(_szel,0);
if ((_index/9) % 3 ==2) // lent
gout << move_to(_x, _y+_mag-2) << line(_szel,0);
// szoveg
if (_ertek)
{
gout << move_to(_x+(_szel-gout.twidth(std::to_string(_ertek)))/2,
......@@ -101,9 +81,11 @@ void Field::rajzol() const
void Field::kezel(genv::event ev)
{
_kijelolt=!_kijelolt;
std::cout << _ertek << std::endl;
}
void Field::set_ertek(int uj)
{
_ertek=uj;
if (!_fix)
_ertek=uj;
}
......@@ -26,6 +26,12 @@ class MyApp : public Application
}
}
void action(int i, int be)
{
palya[i]->set_ertek(be);
game->action();
}
protected:
vector<Field*> palya;
GameMaster* game;
......
......@@ -4,12 +4,6 @@
#include "graphics.hpp"
#include "application.hpp"
/*#define dark_purple 130,37,184
#define light_purple 210,145,255
#define bg_purple 246,232,255
#define white 255,255,255
#define black 0,0,0*/
#define dark_purple 56,0,102
#define mid_purple 133,133,255
#define light_purple 204,204,255
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment