• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

kblackbox

  • sources
  • kde-4.14
  • kdegames
  • kblackbox
kbbballsonboard.h
Go to the documentation of this file.
1 //
2 // KBlackBox
3 //
4 // A simple game inspired by an emacs module
5 //
6 /***************************************************************************
7  * Copyright (c) 1999-2000, Robert Cimrman *
8  * cimrman3@students.zcu.cz *
9  * *
10  * Copyright (c) 2007, Nicolas Roffet *
11  * nicolas-kde@roffet.com *
12  * *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the *
26  * Free Software Foundation, Inc., *
27  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
28  ***************************************************************************/
29 
30 
31 
32 #ifndef KBBBALLSONBOARD_H
33 #define KBBBALLSONBOARD_H
34 
35 
36 #include <QList>
37 #include <QObject>
38 
39 
40 class KBBGameDoc;
41 
42 
43 
44 #define DIM_X 0
45 #define DIM_Y 1
46 #define DIM_MAX 2
47 
48 
49 
62 class KBBBallsOnBoard : public QObject
63 {
64  Q_OBJECT
65 
66  public:
70  KBBBallsOnBoard(KBBGameDoc* parent, const int columns, const int rows);
71 
72 
81  int absolutePositionToBorderPosition(int position[DIM_MAX]);
82 
90  int absolutePositionToBoxPosition(int position[DIM_MAX]);
91 
98  void add(int boxPosition);
99 
107  void borderPositionToAbsolutePosition(int borderPosition, int position[DIM_MAX]);
108 
109  int columns();
110 
116  bool contains(int boxPosition);
117 
121  int count();
122 
129  void newBoard(const int columns, const int rows);
130 
137  int numberOfBallsNotIn(KBBBallsOnBoard* otherBoard);
138 
144  int oppositeBorderPosition(int borderPosition);
145 
146  int oppositeBorderPositionWithPoints(const int borderPosition, QList<int> &points);
147 
153  void ray(const int borderPosition, QList<int> &points);
154 
161  void remove(int boxPosition);
162 
163  int rows();
164 
165 
166  signals:
167  void changes();
168 
169 
170  private:
177  void getOutgoingPosition( int position[DIM_MAX], int incomingDirection[DIM_MAX], QList<int> &points );
178 
184  bool positionInTheBox( int position[DIM_MAX] );
185 
186 
187  QList<int> m_balls;
188  int m_columns;
189  int m_rows;
190 };
191 
192 #endif // KBBBALLSONBOARD_H
KBBBallsOnBoard::absolutePositionToBoxPosition
int absolutePositionToBoxPosition(int position[DIM_MAX])
Convert (absolute) position to box position.
Definition: kbbballsonboard.cpp:72
KBBBallsOnBoard::oppositeBorderPosition
int oppositeBorderPosition(int borderPosition)
Compute the opposite border position of the given position.
Definition: kbbballsonboard.cpp:145
KBBGameDoc
Game document (Logical board)
Definition: kbbgamedoc.h:56
KBBBallsOnBoard::KBBBallsOnBoard
KBBBallsOnBoard(KBBGameDoc *parent, const int columns, const int rows)
Constructor.
Definition: kbbballsonboard.cpp:44
QObject
KBBBallsOnBoard::absolutePositionToBorderPosition
int absolutePositionToBorderPosition(int position[DIM_MAX])
Convert (absolute) position to border position.
Definition: kbbballsonboard.cpp:56
KBBBallsOnBoard::borderPositionToAbsolutePosition
void borderPositionToAbsolutePosition(int borderPosition, int position[DIM_MAX])
Convert border position to (abosulte) position.
Definition: kbbballsonboard.cpp:85
KBBBallsOnBoard::ray
void ray(const int borderPosition, QList< int > &points)
Compute the trajectory of a ray with the balls of the set.
Definition: kbbballsonboard.cpp:180
QList< int >
KBBBallsOnBoard::changes
void changes()
KBBBallsOnBoard::newBoard
void newBoard(const int columns, const int rows)
Define a new board and remove all balls.
Definition: kbbballsonboard.cpp:124
KBBBallsOnBoard::contains
bool contains(int boxPosition)
Check if there is a ball at the given position in the black box.
Definition: kbbballsonboard.cpp:112
KBBBallsOnBoard::oppositeBorderPositionWithPoints
int oppositeBorderPositionWithPoints(const int borderPosition, QList< int > &points)
Definition: kbbballsonboard.cpp:151
KBBBallsOnBoard::numberOfBallsNotIn
int numberOfBallsNotIn(KBBBallsOnBoard *otherBoard)
Compares 2 boards and return the number of differences.
Definition: kbbballsonboard.cpp:133
KBBBallsOnBoard::add
void add(int boxPosition)
Add a ball on this board.
Definition: kbbballsonboard.cpp:78
DIM_MAX
#define DIM_MAX
Definition: kbbballsonboard.h:46
KBBBallsOnBoard::columns
int columns()
Definition: kbbballsonboard.cpp:106
KBBBallsOnBoard::count
int count()
Number of balls on this board.
Definition: kbbballsonboard.cpp:118
QObject::parent
QObject * parent() const
KBBBallsOnBoard::rows
int rows()
Definition: kbbballsonboard.cpp:193
KBBBallsOnBoard
Set of balls (or various objects) with positions on the board.
Definition: kbbballsonboard.h:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kblackbox

Skip menu "kblackbox"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal