1 #ifndef _carrom_h
2 #define _carrom_h
3 
4 #ifndef _real_h
5 #	include "real.h"
6 #endif
7 #ifndef _vec2_h
8 #	include "vec2.h"
9 #endif
10 #ifndef _game_h
11 #	include "game.h"
12 #endif
13 
14 class StaticArc;
15 class StaticBall;
16 class Wall;
17 class Ball;
18 class BallMover;		// forward
19 
20 class Carrom : public Game {
21 	public:
22 		static Real TableWidth;
23 		static Real TableHeight;
24 
25 		Carrom(double wx=TableWidth, double wy=TableHeight);
26 		virtual ~Carrom();
27 
28 		virtual const Real & GetPresetA() const;
29 		virtual const Real & GetPresetHaft() const;
30 		virtual const Real & GetSlowGranularity() const;
31 
32 		virtual const Real & GetNormalBallSize() const;
33 
34 		virtual void InitPlayground();
35 		virtual void DrawBackground() const;
36 
37 		virtual const Real AreaOffX() const;
38 		virtual const Real AreaOffY() const;
39 		virtual const Real AreaWidth() const;
40 		virtual const Real AreaHeight() const;
41 
42 		virtual const Real TAreaOffX() const;
43 		virtual const Real TAreaOffY() const;
44 		virtual const Real TAreaWidth() const;
45 		virtual const Real TAreaHeight() const;
46 
47 		virtual const Real& GetChargeGranularity()	const;
48 		virtual const Real& GetChargeSpeed()			const;
49 		virtual const Real& GetMaxCharge()				const;
50 		virtual const Real& GetShootTime()				const;
51 
52 		virtual void AllBallsStopped();
53 		virtual void InPocket( Ball *b );
54 	private:
55 				  void ResetToCenter(Ball *b);
56 	public:
57 		virtual int  IsSelectable(Ball *b);
58 
59 	public:
60 		static Real Offset;
61 
62 		static Real PresetA;
63 		static Real PresetHaft;
64 		static Real SlowGranularity;
65 
66 		static Real FrameOffset;
67 		static Real ToPocket;
68 		static Real Cushion;
69 		static Real	PocketRadius;
70 		static Real StoneRadius;
71 		static Real StrikerRadius;
72 		static Real StoneWeight;
73 		static Real StrikerWeight;
74 
75 		static Real PocketFrame;
76 		static Real PocketWidth;
77 
78 		static Real	ChargeGranularity;	// L�nge eines Ladeschritts
79 		static Real ChargeSpeed;			// Einheiten pro Sekunde (Aufladen)
80 		static Real	MaxCharge;				// maximale Ladung
81 		static Real ShootTime;				// Zeit der Entladeanimation
82 
83 	protected:
84 		void InitArea( double width, double height );
85 		void Setup(double px, double py);			// Steine verteilen
86 
87 		Real area_off_x;
88 		Real area_off_y;
89 		Real area_width;
90 		Real area_height;
91 
92 		BallMover	*mstone;
93 		BallMover	*mstriker;
94 
95 		ColorId		table_col;
96 
97 		ColorId		table_red;
98 		ColorId		table_green;
99 		ColorId		table_black;
100 
101 		ColorId		pocket_col;
102 
103 	protected:
104 		StaticArc	*p[4];			// Taschenobjekte
105 		StaticBall	*e[4][2];		// Ecken am Taschenrand
106 		Wall			*w[4];			// W�nde zwischen Ecken am Taschenrand
107 
108 		Ball			*white[9];		// Spielsteine
109 		Ball			*black[9];
110 		Ball			*queen;
111 		Ball			*striker;
112 
113 		int			striker_in_pocket;
114 		int			queen_in_pocket;
115 		int			whites_in_pocket;
116 		int			blacks_in_pocket;
117 
118 		Vec2		mid;				// Mittelpunktvektor
119 		Vec2		base[4][2];		// Begrenzung der Grundlinien
120 
121 		ColorId		white_col;
122 		ColorId		black_col;
123 		ColorId		striker_col;
124 		ColorId		queen_col;
125 
126 
127 	private:
Carrom(const Carrom &)128 		Carrom(const Carrom &)	{}	// to overcome a BUG in 2.6.0 of g++
129 		Carrom &operator=( const Carrom& /*obj*/ )	{ return *this; }
130 };
131 
132 class CarromDemo : public Carrom {
133 	public:
shot_speed(s)134 		CarromDemo( double s=40.0 ) : shot_speed(s)	{}
135 		virtual ~CarromDemo();
136 
137 		virtual const Real &GetPresetA() const;
138 		virtual const Real &GetSlowGranularity() const;
139 
140 		virtual void InitPlayground();
141 		virtual void DrawBackground() const;
142 
143 	private:
144 		Real			shot_speed;
145 
146 	public:
147 		static Real	PresetA;
148 		static Real	SlowGranularity;
149 };
150 
151 #endif
152 
153