Multi-user gravity beats for Sound of Science 2013 (server)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

57 lines
944 B

#pragma once
#include <string>
#include <boost/fusion/include/define_struct.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
struct Empty{};
BOOST_FUSION_DEFINE_STRUCT(
, Size,
(int, width)
(int, height)
)
BOOST_FUSION_DEFINE_STRUCT(
, Position,
(int, x)
(int, y)
)
BOOST_FUSION_DEFINE_STRUCT(
, IncomingPacket,
(std::string, name)
(Size, size)
)
struct User {
unsigned int index{0};
std::string name{"Unknown guest"};
bool update_lines{true};
Size size{0,0};
Position position{0,0};
template <typename Ball>
bool is_inside(Ball b){
float x = b.position.x;
float y = b.position.y;
return position.x < x && x < position.x + size.width
&& position.y < y && y < position.y + size.height;
}
User& operator=(IncomingPacket const & p){
name = p.name;
size = p.size;
return *this;
}
};
BOOST_FUSION_ADAPT_STRUCT(
User,
(unsigned int, index)
(std::string, name)
(Size, size)
(Position, position)
)