File: arcs.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 (149 lines) | stat: -rw-r--r-- 3,716 bytes parent folder | download | duplicates (3)
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
#ifndef _arcs_h
#define _arcs_h

//
// In dem Modul 'arcs.h' sind alle Klassen vereint, die mit B�llen und B�gen
// zu tun haben. Dabei gelten die folgenden Ableitungen
//
//			   StaticArc			: Grundfunktionalit�t
//         /         \
//		 OuterArc	 InnerArc	: Bogen, der von au�en/innen reflektiert
//        |       \   |
//		    |       ArcWall	 	: beidseitig reflektierend (Ableitung nur symbolisch)
//		StaticBall					: 360 Grad Bogen, nicht beweglich
//******* | **************************************************************
//		  Ball						: Kugel (gleichzeitig ein DynObj)
//    (-->ball.c)
//

#ifndef _object_h
#	include "object.h"		// Oberklasse
#endif
#ifndef _vec2_h
#	include "vec2.h"		// Member-Klasse
#endif


//
// -------------------------------------------------------------------------
//   class StaticArc:  Bogen (analog zu Wall)
// -------------------------------------------------------------------------
//

class StaticArc : public Object {
	protected:
		Vec2	p;			// Mittelpunkt des Bogens, bzw. Position der Kugel
		Real		r;			// Radius der Kugel

	public:
		StaticArc( double x, double y, double r, double start=0.0, double angle=360.0 );
		StaticArc( const Vec2 &v, const Real &r, const Real &start, const Real &angle );

		virtual ~StaticArc();

		virtual void Info();

		const Vec2 &P() const				{ return p; }
		const Real   &PX() const			{ return p.X(); }
		const Real   &PY() const			{ return p.Y(); }
		const	Real   &R() const				{ return r; }

	protected:
		virtual Real HitFromBall( Ball *b ) = 0;
		virtual void CollideWithBall( Ball *b );


		int IsOnArc( const Vec2 &d );

		Real OuterHitFromBall( Ball *b, const Vec2 &dv );
		Real InnerHitFromBall( Ball *b, const Vec2 &dv );
		Real		start;
		Real		angle;

	private:
		int HitFromBallTwice( int outer_hit, Ball *b, const Vec2 &dv, Real md,
													Real *time );

friend class Pocket;
friend class Pool;
};


//
// -------------------------------------------------------------------------
//   class StaticArc:  Bogen (analog zu Wall)
// -------------------------------------------------------------------------
//

class OuterArc : public StaticArc {
	public:
		OuterArc( double x, double y, double ri, double st, double ang ) :
			StaticArc( x, y, ri, st, ang )		{}
		OuterArc( const Vec2 &v, const Real &ri, const Real &st, const Real &ang ) :
			StaticArc( v, ri, st, ang )			{}
		virtual ~OuterArc();

		virtual void Info();

	protected:
		virtual Real HitFromBall( Ball *b );

	private:
};


class InnerArc : public StaticArc {
	public:
		InnerArc( double x, double y, double ri, double st, double ang ) :
			StaticArc( x, y, ri, st, ang )		{}
		InnerArc( const Vec2 &v, const Real &ri, const Real &st, const Real &ang ) :
			StaticArc( v, ri, st, ang )			{}
		virtual ~InnerArc();

		virtual void Info();

	protected:
		virtual Real HitFromBall( Ball *b );

	private:
};



class ArcWall : public StaticArc {
	public:
		ArcWall( double x, double y, double ri, double st, double ang )
			:	StaticArc( x,y,ri, st, ang )											{ }
		virtual ~ArcWall();

		virtual void Info();

	protected:
		virtual Real HitFromBall( Ball *b );
};

//
// -------------------------------------------------------------------------
//   class Static Ball:  Statische Kugel
// -------------------------------------------------------------------------
//

class StaticBall : public OuterArc {
	public:
		StaticBall( double x, double y, double ri=2. )
			: OuterArc( x,y,ri,0.0,360.0 )			{ type=StaticBallObj; }
		StaticBall( const Vec2 &v, const Real &ri )
			: OuterArc( v,ri,0.0,360.0 )			{ type=StaticBallObj; }

		virtual ~StaticBall();

		virtual void Info();

	protected:

friend class Pocket;
friend class Goal;
};


#endif