Skip to content
Snippets Groups Projects
Commit 930a2ae9 authored by Bolla Péter's avatar Bolla Péter
Browse files

Correct Draw()

parent 0700a976
Branches
No related tags found
No related merge requests found
#include "button.hpp"
#include<iostream>
using namespace genv;
struct DrawColor{
......@@ -21,26 +21,11 @@ void Button::Draw() const
else gout<<color(BG_BLACK.r,BG_BLACK.g, BG_BLACK.b);
gout<<move_to(_x,_y)<<box(_sx,_sy);
}
void Button::Handle(genv::event ev)
{
if(ev.type == ev_mouse)
{
if( ev.button == btn_left)
{
Press();
action();
}
else if(ev.button == -btn_left)
{
Release();
}
}
//If occupied -> draw the piece
if(_s.occupied)
gout.load_font("LUCEFONT.TTF", 40);
//gout.load_font("LUCEFONT.TTF", 40);
gout<<move_to(_x+2, _y+2*_sy);
{
if(_s.piece.team == Light)
{
......@@ -48,32 +33,32 @@ void Button::Handle(genv::event ev)
{
case Pawn:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('P');
gout<<text('P');
break;
}
case Rook:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('R');
gout<<text('R');
break;
}
case Knight:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('N');
gout<<text('N');
break;
}
case Bishop:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('B');
gout<<text('B');
break;
}
case King:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('K');
gout<<text('K');
break;
}
case Queen:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('Q');
gout<<text('Q');
break;
}
case Empty:
......@@ -86,32 +71,32 @@ void Button::Handle(genv::event ev)
case Pawn:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('p');
gout<<text('p');
break;
}
case Rook:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('r');
gout<<text('r');
break;
}
case Knight:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('n');
gout<<text('n');
break;
}
case Bishop:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('b');
gout<<text('b');
break;
}
case King:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('k');
gout<<text('k');
break;
}
case Queen:
{
gout<<move_to(_x+_sx-_sx/10, _y+_sy-_sy/10)<<text('q');
gout<<text('q');
break;
}
case Empty:
......@@ -121,6 +106,22 @@ void Button::Handle(genv::event ev)
}
}
void Button::Handle(genv::event ev)
{
if(ev.type == ev_mouse)
{
if( ev.button == btn_left)
{
Press();
action();
}
else if(ev.button == -btn_left)
{
Release();
}
}
}
void Button::Press()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment