• 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
kbbgamedoc.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 KBBGAMEDOC_H
33 #define KBBGAMEDOC_H
34 
35 
36 #include <QObject>
37 
38 
39 #include <krandomsequence.h>
40 
41 
42 class KBBBallsOnBoard;
43 #include "kbbmainwindow.h"
44 class KBBTutorial;
45 
46 
47 
56 class KBBGameDoc : public QObject
57 {
58  Q_OBJECT
59 
60  public:
65  static const int HIT_POSITION = -1;
66 
67  static const int SCORE_LOST = 999;
68  static const int SCORE_ONE = 3;
69  static const int SCORE_TWO = 9;
70 
71 
75  KBBGameDoc(KBBMainWindow *parent, KBBTutorial* tutorial);
76 
77 
81  int columns() const;
82 
86  void gameOver();
87 
94  bool gameReallyStarted();
95 
96  bool mayShootRay(const int incomingPosition) const;
97 
105  void newGame(int balls, int columns, int rows);
106 
110  int numberOfBallsPlaced();
111 
115  int numberOfBallsToPlace();
116 
120  int rows() const;
121 
125  int score();
126 
136  int shootRay(int borderPosition);
137 
141  void startTutorial();
142 
143 
144  KBBBallsOnBoard* m_balls;
145  KBBBallsOnBoard* m_ballsPlaced;
146 
147 
148  public slots:
149  void timeChanged();
150 
151 
152  signals:
153  void isRunning(bool);
154  void updateStats();
155 
156 
157  private:
158  void setRunning(bool r);
159 
165  void setScore( int n );
166 
167  void clean(const int columns, const int rows);
168 
169  int m_columns;
170  bool m_gameReallyStarted;
171  int m_rows;
172  KRandomSequence m_random;
173  int m_score;
174  KBBTutorial* m_tutorial;
175 };
176 
177 #endif //KBBGAMEDOC_H
KBBGameDoc::SCORE_TWO
static const int SCORE_TWO
Definition: kbbgamedoc.h:69
KBBGameDoc::KBBGameDoc
KBBGameDoc(KBBMainWindow *parent, KBBTutorial *tutorial)
Constructor.
Definition: kbbgamedoc.cpp:45
KBBGameDoc::gameReallyStarted
bool gameReallyStarted()
Check if the player started to play.
Definition: kbbgamedoc.cpp:82
KBBGameDoc::SCORE_LOST
static const int SCORE_LOST
Definition: kbbgamedoc.h:67
KBBGameDoc::shootRay
int shootRay(int borderPosition)
Shoot a ray.
Definition: kbbgamedoc.cpp:136
KBBGameDoc::updateStats
void updateStats()
KBBGameDoc::m_balls
KBBBallsOnBoard * m_balls
Definition: kbbgamedoc.h:144
KBBGameDoc
Game document (Logical board)
Definition: kbbgamedoc.h:56
KBBGameDoc::numberOfBallsPlaced
int numberOfBallsPlaced()
Number of balls the user placed on the board.
Definition: kbbgamedoc.cpp:112
KBBGameDoc::SCORE_ONE
static const int SCORE_ONE
Definition: kbbgamedoc.h:68
QObject
KBBTutorial
Tutorial widget.
Definition: kbbtutorial.h:51
KBBGameDoc::HIT_POSITION
static const int HIT_POSITION
When a laser ray enter the black box, it exits on a defined border position, except if the laser ray ...
Definition: kbbgamedoc.h:65
KBBGameDoc::timeChanged
void timeChanged()
Definition: kbbgamedoc.cpp:164
KBBGameDoc::newGame
void newGame(int balls, int columns, int rows)
Create new board game and initialize game.
Definition: kbbgamedoc.cpp:97
KBBGameDoc::mayShootRay
bool mayShootRay(const int incomingPosition) const
Definition: kbbgamedoc.cpp:88
kbbmainwindow.h
KBBMainWindow
Main window of the game KBlackBox.
Definition: kbbmainwindow.h:49
KBBGameDoc::columns
int columns() const
Get the number of columns.
Definition: kbbgamedoc.cpp:65
KBBGameDoc::m_ballsPlaced
KBBBallsOnBoard * m_ballsPlaced
Definition: kbbgamedoc.h:145
KBBGameDoc::startTutorial
void startTutorial()
Initialize the tutorial.
Definition: kbbgamedoc.cpp:153
KBBGameDoc::isRunning
void isRunning(bool)
KBBGameDoc::numberOfBallsToPlace
int numberOfBallsToPlace()
Number of balls the user has to place on the board.
Definition: kbbgamedoc.cpp:118
QObject::parent
QObject * parent() const
KBBGameDoc::score
int score()
Get current score.
Definition: kbbgamedoc.cpp:130
KBBGameDoc::gameOver
void gameOver()
Stop the game, show solution and compute final score.
Definition: kbbgamedoc.cpp:71
KBBBallsOnBoard
Set of balls (or various objects) with positions on the board.
Definition: kbbballsonboard.h:62
KBBGameDoc::rows
int rows() const
Get the number of rows.
Definition: kbbgamedoc.cpp:124
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