1 #ifndef _global_h
2 #	include "global.h"
3 #endif
4 
5 #ifndef _cannon_h
6 #	include "cannon.h"
7 #endif
8 #ifndef _ball_h
9 #	include "ball.h"
10 #endif
11 #ifndef _wall_h
12 #	include "wall.h"
13 #endif
14 #ifndef _graph_h
15 #	include "graph.h"
16 #endif
17 #ifndef _mover_h
18 #	include "mover.h"
19 #endif
20 
21 //
22 // Voreinstellungen
23 //
24 
Cannon(double wx,double wy)25 Cannon::Cannon(double wx, double wy) :
26 Billard(wx,wy)
27 {
28 	w1 = w2 = r = 0;
29 
30 	InitArea( TableWidth, TableHeight );
31 	SelectTable(-1);
32 	red_col		= AddBallColor( "red4" );
33 	white_col	= AddBallColor( "bisque" );
34 	yellow_col	= AddBallColor( "DarkGoldenrod1" );
35 }
36 
~Cannon()37 Cannon::~Cannon() {
38 	if (w1)		delete w1;
39 	if (w2)		delete w2;
40 	if (r)		delete r;
41 }
42 
GetNormalBallSize()43 const Real & Cannon::GetNormalBallSize() const {
44 	return BallRadius;
45 }
46 
47 
48 
InitPlayground()49 void Cannon::InitPlayground() {
50 
51 	Billard::InitPlayground();
52 	BallRadius = m->GetActRadius();
53 	Billard::InitTable();			// Wandbegrenzung
54 
55 	w1_p = Vec2( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()/2.0 );
56 	w1 = new Ball( w1_p, BallRadius );
57 	w1->state = new BallState( m, white_col, w1_p );
58 
59 	w2_p = Vec2( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()/4.0 );
60 	w2 = new Ball( w2_p, BallRadius );
61 	w2->state = new BallState( m, yellow_col, w2_p );
62 	r_p  = Vec2( AreaOffX()+AreaWidth()*0.75, AreaOffY()+AreaHeight()/2.0 );
63 	r  = new Ball( r_p, BallRadius );
64 	r->state = new BallState( m, red_col, r_p );
65 }
66 
DrawBackground()67 void Cannon::DrawBackground() const {
68 	Billard::DrawBackground();
69 	SetBgColor(table_line_col);
70 	FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.25, 1.0 );
71 	FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.50, 1.0 );
72 	FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.75, 1.0 );
73 	FillCircle( AreaOffX()+AreaWidth()*0.50, AreaOffY()+AreaHeight()*0.50, 1.0 );
74 	FillCircle( AreaOffX()+AreaWidth()*0.75, AreaOffY()+AreaHeight()*0.50, 1.0 );
75 }
76 
ResetGame()77 void Cannon::ResetGame() {
78 	w2->SetPV( w2_p );
79 	w1->SetPV( w1_p );
80 	r ->SetPV( r_p );
81 
82 	Billard::ResetGame();
83 }
84