File: square.h

package info (click to toggle)
galois 0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 948 kB
  • sloc: cpp: 4,075; xml: 2,325; makefile: 146
file content (78 lines) | stat: -rw-r--r-- 2,899 bytes parent folder | download
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
/* square.h -- spatial groups for square 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 __SQUARE_
#define __SQUARE_

#include <vector>
#include <gtkmm.h>
#include "grid.h"
#include "group.h"

class group_square : public group_2d
{
private:
  virtual int size() const { return 4; }
  virtual int rotate(int n, int m) const;
  virtual int reflect(int n) const;
  virtual int type(const coords &c) const { return 0; }
  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 100; }

  // game
  virtual coords left(const coords &c) const
  { return c + make_coords(-1, 0); }
  virtual coords right(const coords &c) const
  { return c + make_coords(1, 0); }
  virtual coords down(const coords &c) const
  { return c + make_coords(0, 1); }
  virtual grid<int> make_board(int width, int depth = 1) const
  { return grid<int>(20, 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_square_mirror : public group_square
{
private:
  virtual int size() const { return 8; }
  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 80; }
};

#endif /* __SQUARE_ */