#include "Game.h" #include // Inhalt der Game Klasse aus Game.h // Konstruktor Game::Game() { schrift = 0; screen = 0; alpha = 0; menü = 0; client = 0; ref = 1; } // Destruktor Game::~Game() { if( client ) client->release(); if( schrift ) schrift->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::setSchriftZ( Schrift *schrift ) { this->schrift = schrift; if( !menü && this->schrift && screen ) menü = new Menü( schrift, screen, client->getThis() ); } void Game::setBildschirmZ( Bildschirm *zScreen ) { screen = zScreen; if( !menü && schrift && screen ) menü = new Menü( schrift, screen, client->getThis() ); } // constant bool Game::istEnde() const { return menü ? ( menü->istBeendet() && !alpha ) : 0; } // Reference Counting MiniGameV *Game::getThis() { ref++; return this; } MiniGameV *Game::release() { ref--; if( !ref ) delete this; return 0; }