File: cannon.C

package info (click to toggle)
flying 6.20-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 752 kB
  • ctags: 1,873
  • sloc: cpp: 10,966; makefile: 189
file content (83 lines) | stat: -rw-r--r-- 1,931 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _global_h
#	include "global.h"
#endif

#ifndef _cannon_h
#	include "cannon.h"
#endif
#ifndef _ball_h
#	include "ball.h"
#endif
#ifndef _wall_h
#	include "wall.h"
#endif
#ifndef _graph_h
#	include "graph.h"
#endif
#ifndef _mover_h
#	include "mover.h"
#endif

//
// Voreinstellungen
//

Cannon::Cannon(double wx, double wy) :
Billard(wx,wy)
{
	w1 = w2 = r = 0;

	InitArea( TableWidth, TableHeight );
	SelectTable(-1);
	red_col		= AddBallColor( "red4" );
	white_col	= AddBallColor( "bisque" );
	yellow_col	= AddBallColor( "DarkGoldenrod1" );
}

Cannon::~Cannon() {
	if (w1)		delete w1;
	if (w2)		delete w2;
	if (r)		delete r;
}

const Real & Cannon::GetNormalBallSize() const {
	return BallRadius;
}



void Cannon::InitPlayground() {

	Billard::InitPlayground();
	BallRadius = m->GetActRadius();
	Billard::InitTable();			// Wandbegrenzung

	w1_p = Vec2( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()/2.0 );
	w1 = new Ball( w1_p, BallRadius );
	w1->state = new BallState( m, white_col, w1_p );

	w2_p = Vec2( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()/4.0 );
	w2 = new Ball( w2_p, BallRadius );
	w2->state = new BallState( m, yellow_col, w2_p );
	r_p  = Vec2( AreaOffX()+AreaWidth()*0.75, AreaOffY()+AreaHeight()/2.0 );
	r  = new Ball( r_p, BallRadius );
	r->state = new BallState( m, red_col, r_p );
}

void Cannon::DrawBackground() const {
	Billard::DrawBackground();
	SetBgColor(table_line_col);
	FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.25, 1.0 );
	FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.50, 1.0 );
	FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.75, 1.0 );
	FillCircle( AreaOffX()+AreaWidth()*0.50, AreaOffY()+AreaHeight()*0.50, 1.0 );
	FillCircle( AreaOffX()+AreaWidth()*0.75, AreaOffY()+AreaHeight()*0.50, 1.0 );
}

void Cannon::ResetGame() {
	w2->SetPV( w2_p );
	w1->SetPV( w1_p );
	r ->SetPV( r_p );

	Billard::ResetGame();
}