Skip to content
Snippets Groups Projects
Commit d1786791 authored by Borostyán József Bálint's avatar Borostyán József Bálint :flag_al:
Browse files

Upload New File

parent 3b040fb7
No related branches found
No related tags found
No related merge requests found
menu.cpp 0 → 100644
#include "menu.hpp"
#include "graphics.hpp"
using namespace genv;
Menu::Menu(int x, int y, int w, int h, std::function<void()> start_callback)
: Widget(x, y, w, h), on_start(start_callback) {}
void Menu::draw() const {
// hatter
gout << color(30, 30, 30) << move_to(x, y) << box(width, height);
// cim
gout << font("LiberationSans-Bold.ttf", 50);
gout << move_to(x + width / 2 - 180, y + 50);
gout << color(255, 0, 0) << text("Connect");
gout << color(255, 255, 0) << text(" Four");
// START
gout << color(200, 200, 200) << move_to(x + width / 2 - 60, y + 150)
<< box(120, 50);
gout << color(0, 0, 0) << move_to(x + width / 2 - 30, y + 180)
<< text("START");
}
void Menu::handle(event ev) {
if (ev.type == ev_mouse && ev.button == btn_left) {
int mx = ev.pos_x;
int my = ev.pos_y;
if (mx >= x + width / 2 - 60 && mx <= x + width / 2 + 60 &&
my >= y + 150 && my <= y + 200) {
on_start();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment