Skip to content

Commit 578bdbf

Browse files
author
pimathbrainiac
committed
Got rid of useless braces
Optimized for speed a bit
1 parent 2a58a08 commit 578bdbf

File tree

1 file changed

+8
-56
lines changed

1 file changed

+8
-56
lines changed

VVVVVV.c

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,20 @@ void flip_player()
4646
int can_move_x()
4747
{
4848
int i;
49-
for(i = 0; i < 20; ++i)
49+
for(i = 2; i < 18; ++i)
5050
{
5151
if(map1_data[(player_point.y + i) / 8][player_point.x / 8] > 20)
52-
{
5352
return 0;
54-
}
5553
if(map1_data[(player_point.y + i) / 8][(player_point.x + 9) / 8] > 20)
56-
{
5754
return 0;
58-
}
5955
}
6056
return 1;
6157
}
6258

6359
int can_move_y()
6460
{
6561
int i;
66-
for(i = 0; i < 10; ++i)
62+
for(i = 1; i < 9; ++i)
6763
{
6864
if(map1_data[player_point.y / 8][(player_point.x + i) / 8] > 20)
6965
{
@@ -83,26 +79,18 @@ int can_move_y()
8379
int detect_spike()
8480
{
8581
int i;
86-
for(i = 0; i < 21; ++i)
82+
for(i = 1; i < 19; ++i)
8783
{
8884
if(map1_data[(player_point.y + i) / 8][player_point.x / 8] <= 3)
89-
{
9085
return 1;
91-
}
9286
if(map1_data[(player_point.y + i) / 8][(player_point.x + 9) / 8] <= 3)
93-
{
9487
return 1;
95-
}
96-
if(i < 10)
88+
if(i < 9)
9789
{
9890
if(map1_data[player_point.y / 8][(player_point.x + i) / 8] <= 3)
99-
{
10091
return 1;
101-
}
10292
if(map1_data[(player_point.y + 19) / 8][(player_point.x + i) / 8] <= 3)
103-
{
10493
return 1;
105-
}
10694
}
10795
}
10896
return 0;
@@ -111,29 +99,21 @@ int detect_spike()
11199
int detect_flip()
112100
{
113101
int i;
114-
for(i = 0; i < 21; ++i)
102+
for(i = 1; i < 17; ++i)
115103
{
116-
if ((i < 17) && (i > 2))
104+
if (i > 2)
117105
{
118106
if((map1_data[(player_point.y + i) / 8][player_point.x / 8] == 4) && !(is_in_flip))
119-
{
120107
return 1;
121-
}
122108
if((map1_data[(player_point.y + i) / 8][(player_point.x + 9) / 8] == 4) && !(is_in_flip))
123-
{
124109
return 1;
125-
}
126110
}
127-
if(i < 10)
111+
if(i < 9)
128112
{
129113
if((map1_data[(player_point.y + 3) / 8][(player_point.x + i) / 8] == 4) && !(is_in_flip))
130-
{
131114
return 1;
132-
}
133-
if((map1_data[(player_point.y + 16) / 8][(player_point.x + i) / 8] == 4) && !(is_in_flip))
134-
{
115+
if((map1_data[(player_point.y + 15) / 8][(player_point.x + i) / 8] == 4) && !(is_in_flip))
135116
return 1;
136-
}
137117
}
138118
}
139119
is_in_flip = 1;
@@ -144,7 +124,6 @@ int main()
144124
{
145125
int prev_x;
146126
int prev_y;
147-
int future_y;
148127
int keep_playing = 1;
149128
Rect player_sprite = {25,76,21,10};
150129
Rect inverted_player_sprite = {59,76,21,10};
@@ -157,57 +136,30 @@ int main()
157136
prev_x = player_point.x;
158137
prev_y = player_point.y;
159138
if(K_7)
160-
{
161139
player_point.x -= 2;
162-
}
163140
if(K_9)
164-
{
165141
player_point.x += 2;
166-
}
167142
if(K_8)
168-
{
169143
if(!is_in_air)
170-
{
171144
flip_player();
172-
}
173-
}
174145
if(K_ESC)
175-
{
176146
keep_playing = 0;
177-
}
178147
player_point.y = player_point.y + gravity;
179148
if(detect_spike())
180-
{
181149
player_point = checkpoint;
182-
}
183150
if(detect_flip())
184-
{
185151
flip_player();
186-
}
187152
else
188-
{
189153
is_in_flip = 0;
190-
}
191-
future_y = player_point.y;
192-
player_point.y = prev_y;
193154
if(!can_move_x())
194-
{
195155
player_point.x = prev_x;
196-
}
197-
player_point.y = future_y;
198156
if(!can_move_y())
199-
{
200157
player_point.y = prev_y;
201-
}
202158
draw_tile_map();
203159
if(gravity == 2)
204-
{
205160
drawSpritePart(image_VVVVVV, player_point.x, player_point.y, &player_sprite);
206-
}
207161
if(gravity == -2)
208-
{
209162
drawSpritePart(image_VVVVVV, player_point.x, player_point.y, &inverted_player_sprite);
210-
}
211163
updateScreen();
212164
//sleep(10);
213165
}

0 commit comments

Comments
 (0)