Uniform indentation

This commit is contained in:
KikooDX 2020-05-17 14:13:48 +02:00
parent a921a8cb99
commit 5609d244c0
6 changed files with 80 additions and 80 deletions

View File

@ -1,6 +1,6 @@
char collide(int x, int y, char level[], char tile);
char collide_spike(int x, int y, char level[]);
char collide_solid(int x, int y, char level[], char polarity,
char test_semi_solid);
char test_semi_solid);
char collide_point(int x, int y, char level[], char tile);
char collide_and_erase(int x, int y, char level[], char tile);

View File

@ -1,3 +1,3 @@
char menu(int *level_id, char *disable_up_key, char *game_loop,
unsigned int step);
unsigned int step);
char menu_level_selection(int *level_id);

View File

@ -1,5 +1,5 @@
enum { UP, DOWN, LEFT, RIGHT };
void jump_test(char *jump_pressed, char *jump_buffer, unsigned int *jump_hold,
char enable_up_key);
char enable_up_key);
void set_start_pos(int *start_x, int *start_y, int x, int y);
void reset_old_pos(int *old_x, int *old_y);

View File

@ -33,14 +33,14 @@ char collide_solid(int x, int y, char level[], char polarity,
char collided;
if (polarity) collided = collide(x, y, level, 'b');
else collided = collide(x, y, level, 'r');
if (!collided && test_semi_solid && ((y + PLAYER_H) % 16) <= 5)
{
collided = (collide_point(x, y + PLAYER_H, level, '/') ||
collide_point(x + PLAYER_W, y + PLAYER_H, level, '/'));
}
return (collided ||
if (!collided && test_semi_solid && ((y + PLAYER_H) % 16) <= 5)
{
collided = (collide_point(x, y + PLAYER_H, level, '/') ||
collide_point(x + PLAYER_W, y + PLAYER_H, level, '/'));
}
return (collided ||
collide(x, y, level, '0') ||
collide(x, y, level, '1') ||
collide(x, y, level, '1') ||
collide(x, y, level, '^') ||
collide(x, y, level, '~'));
}

View File

@ -27,12 +27,12 @@ extern image_t img_dust; //dust texture, 16x16
void draw_anim_speed(int x, int y, image_t *image, int step, int speed)
{
dsubimage(x + DRAW_OFFSET_X, y + DRAW_OFFSET_Y, image,
((step/speed) % (image->width / 16)) * 16, 0, 16, 16, DIMAGE_NONE);
dsubimage(x + DRAW_OFFSET_X, y + DRAW_OFFSET_Y, image,
((step/speed) % (image->width / 16)) * 16, 0, 16, 16, DIMAGE_NONE);
}
void draw_anim(int x, int y, image_t *image, int step)
{
draw_anim_speed(x, y, image, step, 1);
draw_anim_speed(x, y, image, step, 1);
}
void draw_player(int x, int y)
@ -66,7 +66,7 @@ int *start_y, int tp_positions[])
else draw_anim(x, y, &img_blue_dot, step);
break;
case 'v':
draw_anim(x, y, &img_spike, step);
draw_anim(x, y, &img_spike, step);
break;
case '*':
draw_anim(x, y, &img_bouncer, step);
@ -79,11 +79,11 @@ int *start_y, int tp_positions[])
draw_anim(x, y, &img_semi_solid, step);
break;
case '^':
draw_anim_speed(x, y, &img_elevator, step, 2); //half speed
break;
case 'd':
draw_anim(x, y, &img_dust, step);
break;
draw_anim_speed(x, y, &img_elevator, step, 2); //half speed
break;
case 'd':
draw_anim(x, y, &img_dust, step);
break;
case 'S':
erase_tile(x, y, level);
*start_x = x + 2;
@ -96,13 +96,13 @@ int *start_y, int tp_positions[])
draw_anim(x, y, &img_water, step);
break;
case 't': //teleporter 0
draw_anim(x, y, &img_teleporter_0, step);
tp_positions[0] = x;
draw_anim(x, y, &img_teleporter_0, step);
tp_positions[0] = x;
tp_positions[1] = y;
break;
case 'T': //teleporter 1
draw_anim(x, y, &img_teleporter_1, step);
tp_positions[2] = x;
draw_anim(x, y, &img_teleporter_1, step);
tp_positions[2] = x;
tp_positions[3] = y;
break;
}
@ -127,7 +127,7 @@ void erase_tile(int x, int y, char level[])
void draw_timer(unsigned int step)
{
dprint(0, 0, C_WHITE, C_BLACK, "%u.%02u", (step*2)/FPS, (step*2)%FPS);
dprint(0, 0, C_WHITE, C_BLACK, "%u.%02u", (step*2)/FPS, (step*2)%FPS);
}
void just_breathe(unsigned int step)

View File

@ -66,8 +66,8 @@ int main(void)
char exit_buffer = 0;
char tp_buffer = 0;
int tp_positions[4] = { 0, 0, 0, 0 };
char directions[4] = { 0, 0, 0, 0 };
char last_direction = RIGHT;
char directions[4] = { 0, 0, 0, 0 };
char last_direction = RIGHT;
set_level(level_id, level);
DRAW_LEVEL();
player_x = start_x;
@ -80,61 +80,61 @@ int main(void)
has_ticked = 0;
//START DRAW
step++;
if (!(step % 2))
{
DRAW_LEVEL();
draw_player(player_x, player_y);
//drill
int drill_x = player_x;
int drill_y = player_y;
switch (last_direction)
{
case UP:
drill_y -= 12;
break;
case DOWN:
drill_y += 12;
break;
case LEFT:
drill_x -= 12;
break;
case RIGHT:
drill_x += 12;
break;
}
draw_player(drill_x, drill_y);
collide_and_erase(drill_x, drill_y, level, 'd');
draw_timer(step/2);
dupdate();
}
//END DRAW
if (!(step % 2))
{
DRAW_LEVEL();
draw_player(player_x, player_y);
//drill
int drill_x = player_x;
int drill_y = player_y;
switch (last_direction)
{
case UP:
drill_y -= 12;
break;
case DOWN:
drill_y += 12;
break;
case LEFT:
drill_x -= 12;
break;
case RIGHT:
drill_x += 12;
break;
}
draw_player(drill_x, drill_y);
collide_and_erase(drill_x, drill_y, level, 'd');
draw_timer(step/2);
dupdate();
}
//END DRAW
clearevents();
//direction inputs
if (keydown(KEY_LEFT))
{
if (!directions[LEFT]) last_direction = LEFT;
directions[LEFT] += 1;
}
else directions[LEFT] = 0;
if (keydown(KEY_RIGHT))
{
if (!directions[RIGHT]) last_direction = RIGHT;
directions[RIGHT] += 1;
}
else directions[RIGHT] = 0;
if (keydown(KEY_UP))
{
if (!directions[UP]) last_direction = UP;
directions[UP] += 1;
}
else directions[UP] = 0;
if (keydown(KEY_DOWN))
{
if (!directions[DOWN]) last_direction = DOWN;
directions[DOWN] += 1;
}
else directions[DOWN] = 0;
//direction inputs END
//direction inputs
if (keydown(KEY_LEFT))
{
if (!directions[LEFT]) last_direction = LEFT;
directions[LEFT] += 1;
}
else directions[LEFT] = 0;
if (keydown(KEY_RIGHT))
{
if (!directions[RIGHT]) last_direction = RIGHT;
directions[RIGHT] += 1;
}
else directions[RIGHT] = 0;
if (keydown(KEY_UP))
{
if (!directions[UP]) last_direction = UP;
directions[UP] += 1;
}
else directions[UP] = 0;
if (keydown(KEY_DOWN))
{
if (!directions[DOWN]) last_direction = DOWN;
directions[DOWN] += 1;
}
else directions[DOWN] = 0;
//direction inputs END
//polarity swap first
if (keydown(KEY_OPTN))
{