File: mover.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 (137 lines) | stat: -rw-r--r-- 2,484 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
#ifndef _global_h
#	include "global.h"
#endif

#ifndef _mover_h
#	include "mover.h"
#endif
#ifndef _vec2_h
#	include "vec2.h"
#endif
#ifndef _graph_h
#	include "graph.h"
#endif

/*----------------------------------------------------------------------------*/

#ifndef __TURBOC__
#	include "xmover.C"
#else
#	include "dosmover.C"
#endif

/*----------------------------------------------------------------------------*/

BallStateTop::BallStateTop()										{}
BallStateTop::~BallStateTop()										{}
void BallStateTop::Redraw()										{}
void BallStateTop::Show()											{}
void BallStateTop::MoveTo( const Vec2& /*new_pos*/ )	{}
void BallStateTop::Hide()											{}

/*----------------------------------------------------------------------------*/


BallState::BallState( BallMover *m_in, ColorId col_in, const Vec2 &pos ) {
	vis = 0;
	m   = m_in;
	if (!m) {
		printf( "BallState: Error: BallMover not initialized\n" );
	}
	col = col_in;
	for (col_x=0;col_x<nball_ids;col_x++) {
		if (col==ball_ids[col_x])					break;
	}
	x = (int)(pos.X()*w2n);
	y = (int)(pos.Y()*w2n);
	DBG3( BState, "BallState(%ld,<%d,%d>)", col_in, x,y );
}

BallState::~BallState() {
}


void BallState::Redraw() {
	vis=1;
	m->DrawBallAt(x,y,col_x);
}

void BallState::Show() {
	if (!vis) {
		vis=1;
		m->DrawBallAt(x,y,col_x);
	}
}


void BallState::MoveTo( const Vec2 &pos ) {
int	newx;
int	newy;

	newx = (int)(pos.X()*w2n);
	newy = (int)(pos.Y()*w2n);
	if (newx!=x||newy!=y) {
		m->MoveBallOnScreen(x,y,newx,newy,col_x);
		x = newx;
		y = newy;
	}
}


void BallState::Hide() {
	if (vis) {
		vis=0;
		m->DrawBallAt(x,y,col_x);
	}
}

/*----------------------------------------------------------------------------*/


HalfBallState::HalfBallState( BallMover *m_in, ColorId col_in, const Vec2 &pos ) :
	BallState( m_in, col_in, pos )
{
	mh = (HalfBallMover *)m_in;
#ifndef __TURBOC__
	st=mh->AngVec2St(rand()%mh->vecs_l,rand()%mh->vecs_b);
#endif
}

HalfBallState::~HalfBallState() {
}

void HalfBallState::Redraw() {
	vis=1;
	mh->RollBallAt(x,y,st,col_x);
}

void HalfBallState::Show() {
	if (!vis) {
		vis=1;
		mh->RollBallAt(x,y,st,col_x);
	}
}


void HalfBallState::MoveTo( const Vec2 &pos ) {
int			newx;
int			newy;
RingState	nst;

	newx = (int)(pos.X()*w2n);
	newy = (int)(pos.Y()*w2n);
	if (newx!=x||newy!=y) {
		mh->RollBallOnScreen(x,y,st,newx,newy,&nst,col_x);
		x	= newx;
		y	= newy;
		st = nst;
	}
}


void HalfBallState::Hide() {
	if (vis) {
		vis=0;
		mh->RollBallAt(x,y,st,col_x);
	}
}