#ifndef _global_h # include "global.h" #endif #ifndef _pool_h # include "pool.h" #endif #ifndef _pcon_h # include "pcon.h" #endif #ifndef _pocket_h # include "pocket.h" #endif #ifndef _wall_h # include "wall.h" #endif #ifndef _graph_h # include "graph.h" #endif #ifndef _mover_h # include "mover.h" #endif #ifndef _keeper_h # include "keeper.h" #endif // // Voreinstellungen // const int Pool::nPockets = 6; const Real & Pool::GetNormalBallSize() const { return BallRadius; } void Pool::InitArea( double wx, double wy ) { area_width = wx; area_height = wy; if (area_width/2.>area_height) area_height = area_width/2.; else area_width = area_height*2.; area_off_x = (MaxX()-area_width)/2.; area_off_y = (MaxY()-PocketHeight-area_height)/2.; } int Pool::SelectTable( int col ) { col = Billard::SelectTable(col); pocket_col = CreateColorMix( 0, table_line_col ); return col; } Pool::Pool(double wx, double wy) : Billard(wx,wy+PocketHeight) { InitArea(wx,wy); pcon = 0; for (int i=0;iGetActRadius(); InitTable(); } void Pool::DrawBackground() const { Billard::DrawBackground(); // Undraw middle marker SetBgColor( outer_cushion_col ); double outer = PAreaOffY()-TAreaOffY(); int i=4; DrawMarker( AreaOffX()+AreaWidth()*Real(i)/8., TAreaOffY()+outer/2., outer/8., outer/4. ); DrawMarker( AreaOffX()+AreaWidth()*Real(i)/8., TAreaOffY()+TAreaHeight()-outer/2., outer/8., outer/4. ); // Draw Pockets for (i=0;ip1, &pcon[i].w2->p1, &pcon[(i+nPockets-1)%nPockets].w2->p2, &pcon[(i+nPockets-1)%nPockets].w3->p2 ); SetBgColor(pocket_col); FillCircle( p[i]->P(), p[i]->R() ); } for (i=0;ip, pcon[i].b1->r, pcon[i].b1->start, pcon[i].b1->angle ); FillArc( pcon[i].b2->p, pcon[i].b2->r, pcon[i].b2->start, pcon[i].b2->angle ); FillPoly(6, &pcon[i].w1->p1, &pcon[i].w1->p2, &pcon[i].w2->p1, &pcon[i].w2->p2, &pcon[i].w3->p1, &pcon[i].w3->p2 ); } } ////////////////////////////////////////////////////////////////////////////// void Pool::ResetGame() { cueball->SetPV( cuedef ); cue_in_pocket = 0; Billard::ResetGame(); } void Pool::InPocket( Ball *b ) { Billard::InPocket(b); if (b==cueball) cue_in_pocket = 1; } void Pool::AllBallsStopped() { Billard::AllBallsStopped(); (void)IsSelectable(cueball); // back on the table } int Pool::IsSelectable(Ball *b) { if (b==cueball) { if (cue_in_pocket) { Vec2 newpos; b->FitsNextTo(cuedef,Vec2(-1.0,RealZero),&newpos); cue_in_pocket = 0; b->SetP(newpos); b->ChgV(Vec2Zero); return 0; } else { return 1; } } return Billard::IsSelectable(b); }