#include <kgameio.h>
Inheritance diagram for KGameComputerIO:


Public Slots | |
| virtual void | advance () |
| Works kind of similar to QCanvas::advance. | |
Signals | |
| void | signalReaction () |
| This signal is emitted when your computer player is meant to do something, or better is meant to be allowed to do something. | |
Public Member Functions | |
| KGameComputerIO () | |
| Creates a LOCAL computer player. | |
| KGameComputerIO (KPlayer *player) | |
| ~KGameComputerIO () | |
| int | rtti () const |
| Run time idendification. | |
| void | setReactionPeriod (int advanceCalls) |
| The number of advance calls until the player (or rather: the IO) does something (default: 1). | |
| int | reactionPeriod () const |
| void | setAdvancePeriod (int ms) |
Start a QTimer which calls advance every ms milli seconds. | |
| void | stopAdvancePeriod () |
| void | pause (int calls=-1) |
| Ignore calls number of advance calls. | |
| void | unpause () |
| Equivalent to pause(0). | |
Protected Member Functions | |
| virtual void | reaction () |
| Default implementation simply emits signalReaction. | |
Classes | |
| class | KGameComputerIOPrivate |
The KGameComputerIO class. It is used to create a LOCAL computer player and communicate transparently with it. Question: Is this needed or is it overwritten anyway for a real game?
You most probably don't want to use this if you want to design a turn based game/player. You'll rather use KGameIO directly, i.e. subclass it yourself. You just need to use KGameIO::signalPrepareTurn and/or KGameIO::notifyTurn there.
This is rather meant to be of use in real time games.
Definition at line 477 of file kgameio.h.
|
|
Creates a LOCAL computer player.
Definition at line 449 of file kgameio.cpp. |
|
|
Definition at line 454 of file kgameio.cpp. |
|
|
Definition at line 464 of file kgameio.cpp. References KGameComputerIO::KGameComputerIOPrivate::mAdvanceTimer. |
|
|
Works kind of similar to QCanvas::advance.
Increase the internal advance counter. If This is very useful if you use QCanvas as you can use this in your QCanvas::advance call. The advantage is that if you change the speed of the game (i.e. change QCanvas::setAdvancePeriod) the computer player gets slower as well. If you don't use QCanvas you can use setAdvancePeriod to get the same result. Alternatively you can just use a QTimer. Definition at line 515 of file kgameio.cpp. References KGameComputerIO::KGameComputerIOPrivate::mAdvanceCounter, KGameComputerIO::KGameComputerIOPrivate::mPauseCounter, KGameComputerIO::KGameComputerIOPrivate::mReactionPeriod, and reaction(). Referenced by setAdvancePeriod(). |
|
|
Ignore calls number of advance calls. if calls is -1 then all following advance calls are ignored until unpause is called. This simply prevents the internal advance counter to be increased. You may want to use this to emulate a "thinking" computer player. Note that this means if you increase the advance period (see setAdvancePeriod), i.e. if you change the speed of your game, your computer player thinks "faster".
Definition at line 505 of file kgameio.cpp. References KGameComputerIO::KGameComputerIOPrivate::mPauseCounter. Referenced by unpause(). |
|
|
Default implementation simply emits signalReaction.
Definition at line 534 of file kgameio.cpp. References signalReaction(). Referenced by advance(). |
|
|
Definition at line 483 of file kgameio.cpp. References KGameComputerIO::KGameComputerIOPrivate::mReactionPeriod. |
|
|
Run time idendification. Predefined values are from IOMode You MUST overwrite this in derived classes!
Implements KGameIO. Definition at line 473 of file kgameio.cpp. References KGameIO::ComputerIO. |
|
|
Start a QTimer which calls advance every
Definition at line 488 of file kgameio.cpp. References advance(), KGameComputerIO::KGameComputerIOPrivate::mAdvanceTimer, and stopAdvancePeriod(). Here is the call graph for this function: ![]() |
|
|
The number of advance calls until the player (or rather: the IO) does something (default: 1).
Definition at line 478 of file kgameio.cpp. References KGameComputerIO::KGameComputerIOPrivate::mReactionPeriod. |
|
|
This signal is emitted when your computer player is meant to do something, or better is meant to be allowed to do something.
Referenced by reaction(). |
|
|
Definition at line 496 of file kgameio.cpp. References KGameComputerIO::KGameComputerIOPrivate::mAdvanceTimer. Referenced by setAdvancePeriod(). |
|
|
Equivalent to pause(0). Immediately continue to increase the internal advance counter. Definition at line 510 of file kgameio.cpp. References pause(). Here is the call graph for this function: ![]() |
1.4.6