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

libkdegames/libkdegamesprivate/kgame

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

#include <KGame/KGameIO>

Inheritance diagram for KGameComputerIO:
Inheritance graph
[legend]

Public Slots

virtual void advance ()
 

Signals

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

Public Member Functions

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

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 513 of file kgameio.h.

Constructor & Destructor Documentation

KGameComputerIO::KGameComputerIO ( )

Creates a LOCAL computer player.

Definition at line 499 of file kgameio.cpp.

KGameComputerIO::KGameComputerIO ( KPlayer *  player)

Definition at line 504 of file kgameio.cpp.

KGameComputerIO::~KGameComputerIO ( )

Definition at line 509 of file kgameio.cpp.

Member Function Documentation

void KGameComputerIO::advance ( )
virtualslot

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

Definition at line 550 of file kgameio.cpp.

void KGameComputerIO::reaction ( )
protectedvirtual

Default implementation simply emits signalReaction.

Definition at line 579 of file kgameio.cpp.

int KGameComputerIO::reactionPeriod ( ) const

Definition at line 528 of file kgameio.cpp.

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 518 of file kgameio.cpp.

void KGameComputerIO::setAdvancePeriod ( int  ms)

Start a QTimer which calls advance every ms milli seconds.

Definition at line 533 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 523 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::stopAdvancePeriod ( )

Definition at line 541 of file kgameio.cpp.

void KGameComputerIO::unpause ( )

Equivalent to pause(0).

Immediately continue to increase the internal advance counter.

Definition at line 555 of file kgameio.cpp.


The documentation for this class was generated from the following files:
  • kgameio.h
  • kgameio.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:44:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames/libkdegamesprivate/kgame

Skip menu "libkdegames/libkdegamesprivate/kgame"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

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