-
Notifications
You must be signed in to change notification settings - Fork 0
/
tweak.cpp
129 lines (106 loc) · 2.87 KB
/
tweak.cpp
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
// tweak.c
#include "stdafx.h"
#include <math.h>
#include "main.h"
#include "tweak.h"
#include "gworld.h"
#include "moving.h"
#include "gameticks.h"
#include "graphics.h"
#include "players.h"
int xTweakTime[2], yTweakTime[2], rTweakTime[2];
int yTweak[2], xTweak[2], xDirection[2], rTweak[2], rDirection[2];
int lastShadow[2];
int tweakOffsetX[4][11], tweakOffsetY[4][11];
void InitTweak( void )
{
int rTweakValues[] = { 0, 5, 10, 30, 50, 70, 90, 110, 130, 150, 170 };
int count, rotate;
double tweakRad;
for( rotate = 0; rotate<2; rotate++ )
{
for( count=0; count<=10; count++ )
{
tweakRad = d2r( (90*rotate) - rTweakValues[count] );
tweakOffsetX[rotate][count] = (int) floor( 0.5 + cos( tweakRad ) * kBlobHorizSize );
tweakOffsetY[rotate][count] = (int) floor( 0.5 + sin( tweakRad ) * kBlobVertSize );
tweakOffsetX[rotate+2][count] = -tweakOffsetX[rotate][count];
tweakOffsetY[rotate+2][count] = -tweakOffsetY[rotate][count];
}
}
}
void TweakFirstBlob( int player, MRect *first )
{
int tweakValues[] = {0, -1, -2, -3, -6, -12};
if( xTweak[player] > 0 )
{
OffsetMRect( first, xDirection[player] * tweakValues[xTweak[player]], 0 );
}
if( yTweak[player] > 0 )
{
OffsetMRect( first, 0, tweakValues[yTweak[player]] );
}
}
void TweakSecondBlob( int player, MRect *second )
{
int x, y;
CalcSecondBlobOffset( player, &x, &y );
OffsetMRect( second,
tweakOffsetX[blobR[player]][rTweak[player]],
tweakOffsetY[blobR[player]][rTweak[player]] );
}
void StartTweak( int player, int direction, int rotate, int fall )
{
if( fall != 0 )
{
yTweak[player] = 3;
yTweakTime[player] = GameTickCount() + kTweakDelay;
}
if( direction != 0 )
{
xDirection[player] = direction;
xTweak[player] = 5;
xTweakTime[player] = GameTickCount() + kTweakDelay;
}
if( rotate != 0 )
{
rTweak[player] = rotate * 5;
rDirection[player] = rotate;
rTweakTime[player] = GameTickCount() + kTweakDelay;
}
}
void UpdateTweak( int player, int animation )
{
MBoolean isXTweaked, isYTweaked, isRTweaked, isAnimTweaked = false;
if( GameTickCount( ) >= animTime[player] )
{
isAnimTweaked = true;
animTime[player] += 2;
anim[player]++;
HandleMagic( player );
}
isXTweaked = ( (GameTickCount() >= xTweakTime[player]) && (xTweak[player] > 0) );
isYTweaked = ( (GameTickCount() >= yTweakTime[player]) && (yTweak[player] > 0) );
isRTweaked = ( (GameTickCount() >= rTweakTime[player]) && (rTweak[player] > 0) );
if( isXTweaked || isRTweaked || isYTweaked ||
isAnimTweaked || (shadowDepth[player] != lastShadow[player]) )
{
EraseSpriteBlobs( player );
if( isXTweaked )
{
xTweak[player]--;
xTweakTime[player] += kTweakDelay;
}
if( isYTweaked )
{
yTweak[player]--;
yTweakTime[player] += kTweakDelay;
}
if( isRTweaked )
{
rTweak[player]--;
rTweakTime[player] += kTweakDelay;
}
DrawSpriteBlobs( player, animation );
}
}