123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include "Game.h"
- #include <Bild.h>
- // Inhalt der Game Klasse aus Game.h
- // Konstruktor
- Game::Game()
- : ReferenceCounter()
- {
- alpha = 0;
- menü = 0;
- client = 0;
- }
- // Destruktor
- Game::~Game()
- {
- if( client )
- client->release();
- if( menü )
- menü->release();
- }
- // nicht constant
- bool Game::laden()
- {
- return 1;
- }
- void Game::setMinigameClientZ( KSGClient::MinigameServerClient *client )
- {
- if( this->client )
- this->client->release();
- this->client = client;
- }
- void Game::setMinigameAPI( MinigameAPI *api )
- {
- }
- void Game::doPublicMausEreignis( MausEreignis &me )
- {
- if( menü )
- menü->doPublicMausEreignis( me );
- }
- void Game::doTastaturEreignis( TastaturEreignis &te )
- {
- if( menü )
- menü->doTastaturEreignis( te );
- }
- bool Game::tick( double zeit )
- {
- int val = (int)( zeit * 150 );
- if( menü && !menü->istBeendet() && alpha != 255 )
- {
- alpha += val;
- if( alpha > 255 )
- alpha = 255;
- return 1;
- }
- if( menü && menü->istBeendet() && alpha )
- {
- alpha -= val;
- if( alpha < 255 )
- alpha = 0;
- }
- if( menü )
- return menü->tick( zeit );
- return 0;
- }
- void Game::render( Bild &zRObj )
- {
- zRObj.setAlpha( alpha );
- if( menü )
- menü->render( zRObj );
- zRObj.releaseAlpha();
- }
- void Game::setUIFactory( UIInit &uiFactory )
- {
- this->uiFactory = uiFactory;
- if( !menü )
- menü = new Menü( uiFactory, dynamic_cast<KSGClient::MinigameServerClient *>( client->getThis() ) );
- }
- // constant
- bool Game::istEnde() const
- {
- return menü ? ( menü->istBeendet() && !alpha ) : 0;
- }
|