1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/* hexagon.h -- spatial groups for hexagonal bricks. -*- C++ -*-
Copyright (C) 2011-2015 Gerardo Ballabio
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef __HEXAGON_
#define __HEXAGON_
#include <vector>
#include <gtkmm.h>
#include "grid.h"
#include "group.h"
class group_hexagon : public group_2d
{
private:
virtual int size() const { return 6; }
virtual int rotate(int n, int m) const;
virtual int reflect(int n) const;
virtual int type(const coords &c) const
{ return ((c.x + c.y) % 2 == 0) ? 0 : -1; }
virtual std::vector<coords> neighbors(const coords &c) const;
virtual std::vector<coords> blockers(const coords &c) const
{ return std::vector<coords>(); }
virtual grid<bool> transform(const grid<bool> &g, int n) const;
virtual grid<bool> center(const grid<bool> &g) const;
public:
virtual int blockset_max() const { return 50; }
// game
virtual coords left(const coords &c) const
{ return c + make_coords(-1, (c.x % 2 == 0) ? 1 : -1); }
virtual coords right(const coords &c) const
{ return c + make_coords(1, (c.x % 2 == 0) ? 1 : -1); }
virtual coords down(const coords &c) const
{ return c + make_coords(0, 2); }
virtual grid<int> make_board(int width, int depth = 1) const
{ return grid<int>(40, width, 1, -width / 2, 0, 0); }
virtual std::vector<int> check_lines(grid<int> &g, int n) const;
virtual void color_line(grid<int> &g, int n, int c) const;
virtual void remove_line(grid<int> &g, int n) const;
// drawing methods
virtual Gdk::Rectangle block_size(const grid<bool> &b, int size) const;
virtual Gdk::Rectangle board_size(int size, int rows, int cols,
int layers) const;
virtual void draw_brick(Cairo::RefPtr<Cairo::Context> context,
const coords &c, const Gdk::RGBA &color,
int size) const;
virtual void draw_shadow(Cairo::RefPtr<Cairo::Context> context,
const coords &c, const Gdk::RGBA &color,
int size) const;
virtual void draw_board(Cairo::RefPtr<Cairo::Context> context,
int rows, int cols, int layers, int size) const;
};
class group_hexagon_mirror : public group_hexagon
{
private:
virtual int size() const { return 12; }
virtual int rotate(int n, int m) const;
virtual int reflect(int n) const;
virtual grid<bool> transform(const grid<bool> &g, int n) const;
public:
virtual int blockset_max() const { return 30; }
};
#endif /* __HEXAGON_ */
|