File: carrom.h

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 (152 lines) | stat: -rw-r--r-- 3,413 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#ifndef _carrom_h
#define _carrom_h

#ifndef _real_h
#	include "real.h"
#endif
#ifndef _vec2_h
#	include "vec2.h"
#endif
#ifndef _game_h
#	include "game.h"
#endif

class StaticArc;
class StaticBall;
class Wall;
class Ball;
class BallMover;		// forward

class Carrom : public Game {
	public:
		static Real TableWidth;
		static Real TableHeight;

		Carrom(double wx=TableWidth, double wy=TableHeight);
		virtual ~Carrom();

		virtual const Real & GetPresetA() const;
		virtual const Real & GetPresetHaft() const;
		virtual const Real & GetSlowGranularity() const;

		virtual const Real & GetNormalBallSize() const;

		virtual void InitPlayground();
		virtual void DrawBackground() const;

		virtual const Real AreaOffX() const;
		virtual const Real AreaOffY() const;
		virtual const Real AreaWidth() const;
		virtual const Real AreaHeight() const;

		virtual const Real TAreaOffX() const;
		virtual const Real TAreaOffY() const;
		virtual const Real TAreaWidth() const;
		virtual const Real TAreaHeight() const;

		virtual const Real& GetChargeGranularity()	const;
		virtual const Real& GetChargeSpeed()			const;
		virtual const Real& GetMaxCharge()				const;
		virtual const Real& GetShootTime()				const;

		virtual void AllBallsStopped();
		virtual void InPocket( Ball *b );
	private:
				  void ResetToCenter(Ball *b);
	public:
		virtual int  IsSelectable(Ball *b);

	public:
		static Real Offset;

		static Real PresetA;
		static Real PresetHaft;
		static Real SlowGranularity;

		static Real FrameOffset;
		static Real ToPocket;
		static Real Cushion;
		static Real	PocketRadius;
		static Real StoneRadius;
		static Real StrikerRadius;
		static Real StoneWeight;
		static Real StrikerWeight;

		static Real PocketFrame;
		static Real PocketWidth;

		static Real	ChargeGranularity;	// L�nge eines Ladeschritts
		static Real ChargeSpeed;			// Einheiten pro Sekunde (Aufladen)
		static Real	MaxCharge;				// maximale Ladung
		static Real ShootTime;				// Zeit der Entladeanimation

	protected:
		void InitArea( double width, double height );
		void Setup(double px, double py);			// Steine verteilen

		Real area_off_x;
		Real area_off_y;
		Real area_width;
		Real area_height;

		BallMover	*mstone;
		BallMover	*mstriker;

		ColorId		table_col;

		ColorId		table_red;
		ColorId		table_green;
		ColorId		table_black;

		ColorId		pocket_col;

	protected:
		StaticArc	*p[4];			// Taschenobjekte
		StaticBall	*e[4][2];		// Ecken am Taschenrand
		Wall			*w[4];			// W�nde zwischen Ecken am Taschenrand

		Ball			*white[9];		// Spielsteine
		Ball			*black[9];
		Ball			*queen;
		Ball			*striker;

		int			striker_in_pocket;
		int			queen_in_pocket;
		int			whites_in_pocket;
		int			blacks_in_pocket;

		Vec2		mid;				// Mittelpunktvektor
		Vec2		base[4][2];		// Begrenzung der Grundlinien

		ColorId		white_col;
		ColorId		black_col;
		ColorId		striker_col;
		ColorId		queen_col;


	private:
		Carrom(const Carrom &)	{}	// to overcome a BUG in 2.6.0 of g++
		Carrom &operator=( const Carrom& /*obj*/ )	{ return *this; }
};

class CarromDemo : public Carrom {
	public:
		CarromDemo( double s=40.0 ) : shot_speed(s)	{}
		virtual ~CarromDemo();

		virtual const Real &GetPresetA() const;
		virtual const Real &GetSlowGranularity() const;

		virtual void InitPlayground();
		virtual void DrawBackground() const;

	private:
		Real			shot_speed;

	public:
		static Real	PresetA;
		static Real	SlowGranularity;
};

#endif