#include #include #include #include "Spieler.h" #include using namespace Network; float randomFloat() { float r = (float)rand(); float r2 = (float)rand(); float r3 = (float)rand(); return r * r2 / r3; } int main() { Vertex v = Vertex( 1e-23, 0 ); float length = v.getLength(); v.normalize(); Framework::initFramework(); Network::Start( 1 ); Framework::M2Datei dat; dat.setPfad( "/test/spiele/3/models/ship.m2" ); dat.leseDaten(); Model2DData *data = dat.ladeModel( "ship" ); Server *s = new Server(); s->verbinde( 11788, 1 ); while( true ) { SKlient *k = s->getKlient(); Spieler s; s.setTastataturStatus( T_GAS, 1 ); s.setModelData( data->getThis() ); int count = 0; while( true ) { count++; if( count == 11788 ) { int x = 0; } s.tick( 0.03333333 ); float r = (float)rand() / (float)RAND_MAX; char calc = (char)(r * 10); switch( calc ) { case 0: s.setTastataturStatus( T_GAS, 1 ); break; case 1: s.setTastataturStatus( T_GAS, 0 ); break; case 2: s.setTastataturStatus( T_ROT_L, 1 ); break; case 3: s.setTastataturStatus( T_ROT_L, 0 ); break; case 4: s.setTastataturStatus( T_ROT_R, 1 ); break; case 5: s.setTastataturStatus( T_ROT_R, 0 ); break; } char buff[ 25 ]; *(float*)buff = s.getPosition().x; *(float*)( buff + 4 ) = s.getPosition().y; *(float*)( buff + 8 ) = s.getSpeed().x; *(float*)( buff + 12 ) = s.getSpeed().y; *(float*)( buff + 16 ) = s.getDrehung(); *(float*)( buff + 20 ) = s.getDrehungSpeed(); *( buff + 24 ) = calc; if( !k->sende( buff, 25 ) ) break; } k->release(); } data->release(); s->release(); Network::Exit(); Framework::releaseFramework(); return 0; }