KGameComputerIO Class Reference

#include <kgameio.h>

Inheritance diagram for KGameComputerIO:

KGameIO List of all members.

Detailed Description

KGameIO variant for real-time games.

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.

Author:
<b_mann@gmx.de>

Definition at line 477 of file kgameio.h.


Public Slots

virtual void advance ()

Signals

void signalReaction ()

Public Member Functions

 KGameComputerIO ()
 KGameComputerIO (KPlayer *player)
 ~KGameComputerIO ()
int rtti () const
void setReactionPeriod (int advanceCalls)
int reactionPeriod () const
void setAdvancePeriod (int ms)
void stopAdvancePeriod ()
void pause (int calls=-1)
void unpause ()

Protected Member Functions

virtual void reaction ()

Constructor & Destructor Documentation

KGameComputerIO::KGameComputerIO (  ) 

Creates a LOCAL computer player.

Definition at line 449 of file kgameio.cpp.


Member Function Documentation

int KGameComputerIO::rtti (  )  const [virtual]

Run time idendification.

Predefined values are from IOMode You MUST overwrite this in derived classes!

Returns:
rtti value

Implements KGameIO.

Definition at line 473 of file kgameio.cpp.

void KGameComputerIO::setReactionPeriod ( int  advanceCalls  ) 

The number of advance calls until the player (or rather: the IO) does something (default: 1).

Definition at line 478 of file kgameio.cpp.

void KGameComputerIO::setAdvancePeriod ( int  ms  ) 

Start a QTimer which calls advance every ms milli seconds.

Definition at line 488 of file kgameio.cpp.

void KGameComputerIO::pause ( int  calls = -1  ) 

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".

Parameters:
calls Number of advance calls to be ignored

Definition at line 505 of file kgameio.cpp.

void KGameComputerIO::unpause (  ) 

Equivalent to pause(0).

Immediately continue to increase the internal advance counter.

Definition at line 510 of file kgameio.cpp.

void KGameComputerIO::advance (  )  [virtual, slot]

Works kind of similar to QCanvas::advance.

Increase the internal advance counter. If reactionPeriod is reached the counter is set back to 0 and signalReaction is emitted. This is when the player is meant to do something (move its units or so).

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.

void KGameComputerIO::signalReaction (  )  [signal]

This signal is emitted when your computer player is meant to do something, or better is meant to be allowed to do something.

void KGameComputerIO::reaction (  )  [protected, virtual]

Default implementation simply emits signalReaction.

Definition at line 534 of file kgameio.cpp.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys