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
|
#include "SDL_gfxPrimitives.h"
#include "constants.h"
#include "flyterrain.h"
#include "random.h"
int FlyTerrain :: flyScoreZones[][3] = { { 0, 20, 5 },
{ 20, 30, 2 },
{ 30, 40, 0 },
{ 40, 100, -1 },
{ 100, 300, -2 },
{ -1, -1, -1 } };
FlyTerrain :: FlyTerrain( int w, int h )
: Terrain( w, h, false, true )
{
showScoreZones = true;
}
FlyTerrain :: ~FlyTerrain()
{
}
void FlyTerrain :: setPoint( int point )
{
static int fly_difficulty_levels[] = { 5, 10, 15 };
if ( nextInt(100) >= 75 )
dir *= -1;
int prevPoint = mapBottom[point-1];
int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[0] ) );
if ( nextPoint > sHeight )
{
nextPoint = sHeight;
dir *= -1;
}
else if ( nextPoint < maxHeight )
{
nextPoint = maxHeight;
dir *= 1;
}
mapBottom[point] = nextPoint;
}
void FlyTerrain :: drawTerrain( SDL_Surface *screen )
{
Terrain::drawTerrain( screen );
int tmpOffset = offset + speed*segSize;
for ( int i = 0 ; i < MAPSIZE -1; ++i )
{
if ( showScoreZones )
{
int r = 0;
int g = 0;
int b = 0;
for ( int j = 1 ; flyScoreZones[j][0] != -1 ; ++j )
{
if ( flyScoreZones[j][2] == 0 )
{
g = 255;
b = r = 0;
}
else if ( flyScoreZones[j][2] < 0 )
{
r = 255;
b = g = 0;
}
else
{
b = 255;
r = g = 0;
}
lineRGBA( screen, (i*segSize) - tmpOffset, mapBottom[i]-flyScoreZones[j][0], ((i+1)*segSize)-tmpOffset, mapBottom[i+1]-flyScoreZones[j][0], r, g, b, 255 );
}
}
}
}
int FlyTerrain :: getScore( int difficulty, int dist )
{
int score = 0;
for ( int i = 0 ; flyScoreZones[i][0] != -1 ; ++i )
{
if ( flyScoreZones[i][0] <= dist && flyScoreZones[i][1] > dist )
{
score = flyScoreZones[i][2];
break;
}
}
return score;
}
|