123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #include "Game.h"
- #include <Bild.h>
- // 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( screen )
- screen->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::doMausEreignis( MausEreignis &me )
- {
- if( menü )
- menü->doMausEreignis( 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 *screen )
- {
- this->screen = screen;
- 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;
- }
|