File: object.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 (92 lines) | stat: -rw-r--r-- 1,839 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
#ifndef _global_h
#	include "global.h"
#endif

#ifndef _object_h
#	include "object.h"
#endif
#ifndef _ball_h
#	include "ball.h"
#endif
#ifndef _graph_h
#	include "graph.h"
#endif

//
// Statik der Object-Klasse
//
Object	*Object::stat_queue = 0L;		// globale Liste der statischen Obje
int		Object::id_count = 0;			// aktuelle Objekt-Id
Real		Object::min_time = MAX_TIME;	// Initialisierung



Object::Object() {
	type   = UnknownObj;
	id		 = id_count++;
	dyn_id = -1;
	next	 = stat_queue;		// alle Objekte zunaechst in statische Liste
	stat_queue = this;
}

Object::~Object() {
Object	*last;

	if ( stat_queue == this )		stat_queue = next;
	else {
		last = stat_queue;		// Element aus Statik-Liste entfernen
		while ( last->next && last->next != this )		last = last->next;
		last->next = next;		// Element ausketten
	}
Object	*obj;
	for (obj=stat_queue; obj; obj=obj->next ) {
		if (obj->id>id)		obj->id--;	// Object-Ids neu nummerieren
	}
	id_count--;
}

void Object::ForAll( ObjFun fun ) {
Object *obj;

	for (obj=stat_queue; obj; obj=obj->next ) 	(obj->*fun)();
}


Real Object::Collision()		{ return NO_HIT;	}

void Object::WasHit(Object*)	{ }

void Object::Info() {
	printf( "%02d: Static:     %08lx\n", id, (unsigned long)this );
}

void Object::Draw() {
#if (0)
	switch(type) {
	case StaticArcObj:
		StaticArc	*p = this;
		DrawArc( p->P(), p->r, p->start, p->angle );
		break;
	case StaticBallObj:
		StaticBall	*p = this
		DrawCircle( p->P(), p->R() );
		break;
	case WallObj:
		Wall			*p = this;
		DrawLine( p->p1, p->p2 );
		break;
	case PocketObj:
		Pocket		*p = this;
#ifndef __TURBOC__
		XSetLineAttributes(dpy,*ga,0,LineOnOffDash,CapRound,JoinRound);
#endif
		DrawCircle( p->P(), p->R() );
#ifndef __TURBOC__
		XSetLineAttributes(dpy,*ga,0,LineSolid,CapRound,JoinRound);
#endif
		break;
	case UnknownObj:
		break;
	}
#endif
}