bool Monitor::dispfoul( const char * command ) { // foul or drop_ball int x, y, side; if ( std::sscanf( command, " ( dispfoul %d %d %d ) ", &x, &y, &side ) != 3 ) { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } double real_x = x / SHOWINFO_SCALE; double real_y = y / SHOWINFO_SCALE; if ( static_cast< Side >( side ) == NEUTRAL ) { M_stadium.dropBall( PVector( real_x, real_y ) ); } else { M_stadium.callFoul( static_cast< Side >( side ), PVector( real_x, real_y ) ); } return true; }
Particle(unsigned int energy_limit){ shell.set_max(energy_limit); target = 10; shell.give(random(energy_limit)); mass = 20; acceleration = PVector(0, 0); velocity = PVector(0, 0); location = PVector(0, 0); maxspeed = 50-mass; maxforce = 50; }
bool Monitor::dispplayer( const char * command ) { // a player is given new position by the monitor int side, unum; int x, y, a; if ( std::sscanf( command, " ( dispplayer %d %d %d %d %d ) ", &side, &unum, &x, &y, &a ) != 5 ) { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } double real_x = x / SHOWINFO_SCALE; double real_y = y / SHOWINFO_SCALE; double angle = Deg2Rad( a ); PVector vel( 0.0, 0.0 ); return M_stadium.movePlayer( static_cast< Side >( side ), unum, PVector( real_x, real_y ), &angle, &vel ); }
void Post_DrawTerrainMaterialTest() { // r3dRenderer->SetTex(gBuffer_Color->Tex); // r3dRenderer->SetTex(gBuffer_Normal->Tex,1); r3dRenderer->SetTex(gBuffer_Depth->Tex); // r3dRenderer->SetTex(gBuffer_Aux->Tex,3); float DepthZ = r3dRenderer->FarClip * 0.9375f; D3DXVECTOR4 CamVector(gCam.x,gCam.y,gCam.z, DepthZ); D3DXVECTOR4 PVector(20,100, 0,0); r3dRenderer->pd3ddev->SetPixelShaderConstantF( 7, (float *)&CamVector, 1 ); r3dRenderer->pd3ddev->SetPixelShaderConstantF( 8, (float *)&PVector, 1 ); r3dRenderer->SetPixelShader( "POST_TERRAINMAT" ); r3dRenderer->SetVertexShader( "VS_POST_QUAD" ); D3DXMATRIX mWorld; D3DXMATRIX ShaderMat; D3DXMatrixIdentity(&mWorld); ShaderMat = mWorld * r3dRenderer->ViewProjMatrix; D3DXMatrixTranspose( &ShaderMat, &ShaderMat ); r3dRenderer->pd3ddev->SetVertexShaderConstantF( 0, (float *)&ShaderMat, 4 ); r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA | R3D_BLEND_NZ); r3dDrawBox2DZ(0,0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, DepthZ, r3dColor(255,150,0)); r3dRenderer->SetVertexShader(); r3dRenderer->SetPixelShader(); r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA); r3dRenderer->pd3ddev->SetSamplerState( 1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); r3dRenderer->pd3ddev->SetSamplerState( 1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); r3dRenderer->pd3ddev->SetSamplerState( 2, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); r3dRenderer->pd3ddev->SetSamplerState( 2, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); r3dRenderer->SetTex(NULL); r3dRenderer->SetMaterial(NULL); }
bool Monitor::coach_move( const char * command ) { char obj[128]; double x = 0.0, y = 0.0, ang = 0.0, velx = 0.0, vely = 0.0; int n = std::sscanf( command, " ( move ( %127[^)] ) %lf %lf %lf %lf %lf ) ", obj, &x, &y, &ang, &velx, &vely ); if ( n < 3 || std::isnan( x ) != 0 || std::isnan( y ) != 0 || std::isnan( ang ) != 0 || std::isnan( velx ) != 0 || std::isnan( vely ) != 0 ) { sendMsg( MSG_BOARD, "(error illegal_object_form)" ); return false; } std::string obj_name = "("; obj_name += obj; obj_name += ')'; if ( obj_name == BALL_NAME ) { M_stadium.clearBallCatcher(); if ( n == 3 || n == 4 ) { M_stadium.moveBall( PVector( x, y ), PVector( 0.0, 0.0 ) ); } else if ( n == 6 ) { M_stadium.moveBall( PVector( x, y ), PVector( velx, vely ) ); } else { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } } else { char teamname[128]; int unum = 0; if ( std::sscanf( obj_name.c_str(), PLAYER_NAME_FORMAT, teamname, &unum ) != 2 || unum < 1 || MAX_PLAYER < unum ) { sendMsg( MSG_BOARD, "(error illegal_object_form)" ); return false; } Side side = ( M_stadium.teamLeft().name() == teamname ? LEFT : M_stadium.teamRight().name() == teamname ? RIGHT : NEUTRAL ); PVector pos( x, y ); PVector vel( velx, vely ); ang = Deg2Rad( rcss::bound( ServerParam::instance().minMoment(), ang, ServerParam::instance().maxMoment() ) ); if ( n == 3 ) { M_stadium.movePlayer( side, unum, pos, NULL, NULL ); } else if ( n == 4 ) { M_stadium.movePlayer( side, unum, pos, &ang, NULL ); } else if ( n == 6 ) { M_stadium.movePlayer( side, unum, pos, &ang, &vel ); } else { sendMsg( MSG_BOARD, "(error illegal_command_form)" ); return false; } } sendMsg( MSG_BOARD, "(ok move)" ); return true; }