@@ -46,24 +46,20 @@ void flip_player()
46
46
int can_move_x ()
47
47
{
48
48
int i ;
49
- for (i = 0 ; i < 20 ; ++ i )
49
+ for (i = 2 ; i < 18 ; ++ i )
50
50
{
51
51
if (map1_data [(player_point .y + i ) / 8 ][player_point .x / 8 ] > 20 )
52
- {
53
52
return 0 ;
54
- }
55
53
if (map1_data [(player_point .y + i ) / 8 ][(player_point .x + 9 ) / 8 ] > 20 )
56
- {
57
54
return 0 ;
58
- }
59
55
}
60
56
return 1 ;
61
57
}
62
58
63
59
int can_move_y ()
64
60
{
65
61
int i ;
66
- for (i = 0 ; i < 10 ; ++ i )
62
+ for (i = 1 ; i < 9 ; ++ i )
67
63
{
68
64
if (map1_data [player_point .y / 8 ][(player_point .x + i ) / 8 ] > 20 )
69
65
{
@@ -83,26 +79,18 @@ int can_move_y()
83
79
int detect_spike ()
84
80
{
85
81
int i ;
86
- for (i = 0 ; i < 21 ; ++ i )
82
+ for (i = 1 ; i < 19 ; ++ i )
87
83
{
88
84
if (map1_data [(player_point .y + i ) / 8 ][player_point .x / 8 ] <= 3 )
89
- {
90
85
return 1 ;
91
- }
92
86
if (map1_data [(player_point .y + i ) / 8 ][(player_point .x + 9 ) / 8 ] <= 3 )
93
- {
94
87
return 1 ;
95
- }
96
- if (i < 10 )
88
+ if (i < 9 )
97
89
{
98
90
if (map1_data [player_point .y / 8 ][(player_point .x + i ) / 8 ] <= 3 )
99
- {
100
91
return 1 ;
101
- }
102
92
if (map1_data [(player_point .y + 19 ) / 8 ][(player_point .x + i ) / 8 ] <= 3 )
103
- {
104
93
return 1 ;
105
- }
106
94
}
107
95
}
108
96
return 0 ;
@@ -111,29 +99,21 @@ int detect_spike()
111
99
int detect_flip ()
112
100
{
113
101
int i ;
114
- for (i = 0 ; i < 21 ; ++ i )
102
+ for (i = 1 ; i < 17 ; ++ i )
115
103
{
116
- if (( i < 17 ) && ( i > 2 ) )
104
+ if (i > 2 )
117
105
{
118
106
if ((map1_data [(player_point .y + i ) / 8 ][player_point .x / 8 ] == 4 ) && !(is_in_flip ))
119
- {
120
107
return 1 ;
121
- }
122
108
if ((map1_data [(player_point .y + i ) / 8 ][(player_point .x + 9 ) / 8 ] == 4 ) && !(is_in_flip ))
123
- {
124
109
return 1 ;
125
- }
126
110
}
127
- if (i < 10 )
111
+ if (i < 9 )
128
112
{
129
113
if ((map1_data [(player_point .y + 3 ) / 8 ][(player_point .x + i ) / 8 ] == 4 ) && !(is_in_flip ))
130
- {
131
114
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 ))
135
116
return 1 ;
136
- }
137
117
}
138
118
}
139
119
is_in_flip = 1 ;
@@ -144,7 +124,6 @@ int main()
144
124
{
145
125
int prev_x ;
146
126
int prev_y ;
147
- int future_y ;
148
127
int keep_playing = 1 ;
149
128
Rect player_sprite = {25 ,76 ,21 ,10 };
150
129
Rect inverted_player_sprite = {59 ,76 ,21 ,10 };
@@ -157,57 +136,30 @@ int main()
157
136
prev_x = player_point .x ;
158
137
prev_y = player_point .y ;
159
138
if (K_7 )
160
- {
161
139
player_point .x -= 2 ;
162
- }
163
140
if (K_9 )
164
- {
165
141
player_point .x += 2 ;
166
- }
167
142
if (K_8 )
168
- {
169
143
if (!is_in_air )
170
- {
171
144
flip_player ();
172
- }
173
- }
174
145
if (K_ESC )
175
- {
176
146
keep_playing = 0 ;
177
- }
178
147
player_point .y = player_point .y + gravity ;
179
148
if (detect_spike ())
180
- {
181
149
player_point = checkpoint ;
182
- }
183
150
if (detect_flip ())
184
- {
185
151
flip_player ();
186
- }
187
152
else
188
- {
189
153
is_in_flip = 0 ;
190
- }
191
- future_y = player_point .y ;
192
- player_point .y = prev_y ;
193
154
if (!can_move_x ())
194
- {
195
155
player_point .x = prev_x ;
196
- }
197
- player_point .y = future_y ;
198
156
if (!can_move_y ())
199
- {
200
157
player_point .y = prev_y ;
201
- }
202
158
draw_tile_map ();
203
159
if (gravity == 2 )
204
- {
205
160
drawSpritePart (image_VVVVVV , player_point .x , player_point .y , & player_sprite );
206
- }
207
161
if (gravity == -2 )
208
- {
209
162
drawSpritePart (image_VVVVVV , player_point .x , player_point .y , & inverted_player_sprite );
210
- }
211
163
updateScreen ();
212
164
//sleep(10);
213
165
}
0 commit comments