• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
KGameComputerIO Class Reference

#include <kgameio.h>

Inheritance diagram for KGameComputerIO:
KGameIO

Public Slots

virtual void advance ()
 

Signals

void signalReaction ()
 
- Signals inherited from KGameIO
void signalPrepareTurn (TQDataStream &stream, bool turn, KGameIO *io, bool *send)
 

Public Member Functions

 KGameComputerIO ()
 
 KGameComputerIO (KPlayer *player)
 
int rtti () const
 
void setReactionPeriod (int advanceCalls)
 
int reactionPeriod () const
 
void setAdvancePeriod (int ms)
 
void stopAdvancePeriod ()
 
void pause (int calls=-1)
 
void unpause ()
 
- Public Member Functions inherited from KGameIO
 KGameIO ()
 
 KGameIO (KPlayer *)
 
void Debug ()
 
KPlayer * player () const
 
KGame * game () const
 
void setPlayer (KPlayer *p)
 
virtual void initIO (KPlayer *p)
 
virtual void notifyTurn (bool b)
 
bool sendInput (TQDataStream &stream, bool transmit=true, TQ_UINT32 sender=0)
 

Protected Member Functions

virtual void reaction ()
 

Additional Inherited Members

- Public Types inherited from KGameIO
enum  IOMode {
  GenericIO =1, KeyIO =2, MouseIO =4, ProcessIO =8,
  ComputerIO =16
}
 

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_man.nosp@m.n@gm.nosp@m.x.de

Definition at line 481 of file kgameio.h.

Constructor & Destructor Documentation

◆ KGameComputerIO()

KGameComputerIO::KGameComputerIO ( )

Creates a LOCAL computer player.

Definition at line 449 of file kgameio.cpp.

Member Function Documentation

◆ advance

void KGameComputerIO::advance ( )
virtualslot

Works kind of similar to TQCanvas::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 TQCanvas as you can use this in your TQCanvas::advance call. The advantage is that if you change the speed of the game (i.e. change TQCanvas::setAdvancePeriod) the computer player gets slower as well.

If you don't use TQCanvas you can use setAdvancePeriod to get the same result. Alternatively you can just use a TQTimer.

Definition at line 515 of file kgameio.cpp.

◆ pause()

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
callsNumber of advance calls to be ignored

Definition at line 505 of file kgameio.cpp.

◆ reaction()

void KGameComputerIO::reaction ( )
protectedvirtual

Default implementation simply emits signalReaction.

Definition at line 534 of file kgameio.cpp.

◆ rtti()

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.

◆ setAdvancePeriod()

void KGameComputerIO::setAdvancePeriod ( int  ms)

Start a TQTimer which calls advance every ms milli seconds.

Definition at line 488 of file kgameio.cpp.

◆ setReactionPeriod()

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.

◆ signalReaction

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.

◆ unpause()

void KGameComputerIO::unpause ( )

Equivalent to pause(0).

Immediately continue to increase the internal advance counter.

Definition at line 510 of file kgameio.cpp.


The documentation for this class was generated from the following files:
  • kgameio.h
  • kgameio.cpp

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.8.13
This website is maintained by Timothy Pearson.