-
Notifications
You must be signed in to change notification settings - Fork 3
/
MarioKartObjects.c
179 lines (143 loc) · 4.88 KB
/
MarioKartObjects.c
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include "MainInclude.h"
unsigned short CheckBump2Simple(Object *InputObject)
{
return CheckBump2((Bump*)&InputObject->bump, InputObject->radius, InputObject->position[0], InputObject->position[1], InputObject->position[2], InputObject->position[0] - InputObject->velocity[0], InputObject->position[1] - InputObject->velocity[1], InputObject->position[2] - InputObject->velocity[2] );
}
short MasterCreateObject(float localPosition[], short localRotation[], float localVelocity[], short localID, float radius)
{
GlobalShortA = addObjectBuffer(localPosition,localRotation,objectVelocity,localID);
GlobalAddressA = (long)(&g_SimpleObjectArray) + (GlobalShortA * 0x70);
GlobalObjectA = (Object*)(GlobalAddressA);
GlobalObjectA->flag = 0xC000;
GlobalObjectA->radius = radius;
return GlobalShortA;
}
short CreateObjectRotation(float localPosition[], short localRotation[], short localID)
{
objectVelocity[0] = 0;
objectVelocity[1] = 0;
objectVelocity[2] = 0;
GlobalShortA = MasterCreateObject(localPosition,localRotation,objectVelocity,localID, 5.0);
return GlobalShortA;
}
short CreateObjectRadius(float localPosition[], short localRotation[], short localID, float localRadius)
{
objectVelocity[0] = 0;
objectVelocity[1] = 0;
objectVelocity[2] = 0;
GlobalShortA = MasterCreateObject(localPosition,localRotation,objectVelocity,localID, localRadius);
return GlobalShortA;
}
short CreateObject(float localPosition[], short localID)
{
objectAngle[0] = 0;
objectAngle[1] = 0;
objectAngle[2] = 0;
objectVelocity[0] = 0;
objectVelocity[1] = 0;
objectVelocity[2] = 0;
return MasterCreateObject(localPosition,objectAngle,objectVelocity,localID, 5.0);
}
short CreateObjectSimple(int XPosition, int YPosition, int ZPosition, int localRotation, int localID)
{
objectPosition[0] = (float)XPosition;
objectPosition[1] = (float)YPosition;
objectPosition[2] = (float)ZPosition;
objectAngle[0] = 0;
objectAngle[1] = (short)localRotation;
objectAngle[2] = 0;
objectVelocity[0] = 0;
objectVelocity[1] = 0;
objectVelocity[2] = 0;
return MasterCreateObject(objectPosition,objectAngle,objectVelocity,localID, 5.0);
}
void UpdateObjectVelocity(Object* InputObject)
{
InputObject->position[0] += InputObject->velocity[0];
InputObject->position[1] += InputObject->velocity[1];
InputObject->position[2] += InputObject->velocity[2];
}
void UpdateObjectAngle(Object* InputObject, short InputAngle[])
{
InputObject->angle[0] += InputAngle[0];
InputObject->angle[1] += InputAngle[1];
InputObject->angle[2] += InputAngle[2];
}
void UpdateObjectGravity(Object* InputObject)
{
InputObject->velocity[1] -= 0.5;
/*
if (InputObject->velocity[1] > -2)
{
InputObject->velocity[1] -= 0.5;
}
else
{
InputObject->velocity[1] = -2;
}
*/
}
void ManualBump(Bump* BumpData, Vector Position )
{
float dist;
dist = BumpData->distance_zx;
if ((BumpData->distance_zx < 0) && (BumpData->flag_zx == TRUE))
{
Position[0] -= BumpData->bump_zx[0] * dist;
Position[1] -= BumpData->bump_zx[1] * dist;
Position[2] -= BumpData->bump_zx[2] * dist;
}
dist = BumpData->distance_xy;
if ((BumpData->distance_xy < 0) && (BumpData->flag_xy == TRUE))
{
Position[0] -= BumpData->bump_xy[0] * dist;
Position[1] -= BumpData->bump_xy[1] * dist;
Position[2] -= BumpData->bump_xy[2] * dist;
}
dist = BumpData->distance_yz;
if ((BumpData->distance_yz < 0) && (BumpData->flag_yz == TRUE))
{
Position[0] -= BumpData->bump_yz[0] * dist;
Position[1] -= BumpData->bump_yz[1] * dist;
Position[2] -= BumpData->bump_yz[2] * dist;
}
}
void ManualBounce(Vector BumpDistance, Vector Velocity)
{
float fx, fy, fz;
float vx, vy, vz;
float m, LocalVelo, vv, LocalVelo2;
vx = Velocity[0];
vy = Velocity[1];
vz = Velocity[2];
LocalVelo = sqrtf(vx * vx + vy * vy + vz * vz);
m = BumpDistance[0] * vx + BumpDistance[1] * vy + BumpDistance[2] * vz;
fx = vx - m * BumpDistance[0];
fy = vy - m * BumpDistance[1];
fz = vz - m * BumpDistance[2];
vx = fx - m * BumpDistance[0];
vy = fy - m * BumpDistance[1];
vz = fz - m * BumpDistance[2];
LocalVelo2 = sqrtf(vx * vx + vy * vy + vz * vz);
vv = 1 / LocalVelo2 * LocalVelo;
Velocity[0] = vx * vv;
Velocity[1] = vy * vv;
Velocity[2] = vz * vv;
}
void UpdateObjectBump(Object* InputObject)
{
CheckBump2Simple(InputObject);
BumpObject(InputObject);
}
void UpdateObjectFriction(Object* InputObject, float Friction)
{
InputObject->velocity[0] -= Friction;
InputObject->velocity[1] -= Friction;
InputObject->velocity[2] -= Friction;
}
void UpdateObjectFrictionScale(Object* InputObject, float FrictionScale)
{
InputObject->velocity[0] *= (1.0 - (FrictionScale / 30));
InputObject->velocity[1] *= (1.0 - (FrictionScale / 30));
InputObject->velocity[2] *= (1.0 - (FrictionScale / 30));
}