clang-format: break after top level definitions

This commit is contained in:
KikooDX 2021-04-27 00:52:53 +02:00
parent b63bbd3148
commit d585e2db6f
28 changed files with 106 additions and 50 deletions

View File

@ -6,3 +6,4 @@ AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 80
AlignConsecutiveMacros: true
AlwaysBreakAfterReturnType: TopLevelDefinitions

View File

@ -4,7 +4,8 @@
#include "input.h"
#include <gint/keycodes.h>
struct Input input_init(void)
struct Input
input_init(void)
{
struct Input input = {
.keycodes = {KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_SHIFT},

View File

@ -4,7 +4,8 @@
#include "input.h"
#include <gint/keyboard.h>
void input_update(struct Input *input)
void
input_update(struct Input *input)
{
int i;

View File

@ -9,7 +9,8 @@
extern struct Level level;
extern const bopti_image_t bimg_tileset;
void level_draw(void)
void
level_draw(void)
{
int i;

View File

@ -6,7 +6,8 @@
extern struct Level level;
Tile level_get_tile(int x, int y)
Tile
level_get_tile(int x, int y)
{
if (x < 0 || y < 0 || x >= level.width || y >= level.height)
return TILE_OOB;

View File

@ -28,7 +28,8 @@ static Tile read_merge_bytes(int file, int size);
static int autotile_value(int x, int y);
/* Load level from storage memory. */
void level_load(void)
void
level_load(void)
{
int file;
int tile_size;
@ -126,7 +127,8 @@ void level_load(void)
}
/* Read a single byte. Negative value is BFile error code. */
static int read_byte(int file)
static int
read_byte(int file)
{
char byte;
const int error = BFile_Read(file, &byte, sizeof(char), -1);
@ -138,7 +140,8 @@ static int read_byte(int file)
/* Read multiple bytes and merge them as one integer.
* Return -1 on failure. */
static Tile read_merge_bytes(int file, int size)
static Tile
read_merge_bytes(int file, int size)
{
Tile merged = 0;
int byte = 0;
@ -155,7 +158,8 @@ static Tile read_merge_bytes(int file, int size)
return merged;
}
static int autotile_value(int x, int y)
static int
autotile_value(int x, int y)
{
return ((level_get_tile(x - 1, y) == TILE_SOLID) |
((level_get_tile(x + 1, y) == TILE_SOLID) << 1) |

View File

@ -6,7 +6,8 @@
#include "zxcolors.h"
#include <gint/display.h>
void levelselection_draw(struct LevelSelection levelselection)
void
levelselection_draw(struct LevelSelection levelselection)
{
dprint(0, 0, ZX_WHITE, ".pack_cursor=%d", levelselection.pack_cursor);
}

View File

@ -3,7 +3,8 @@
#include "levelselection.h"
struct LevelSelection levelselection_init(void)
struct LevelSelection
levelselection_init(void)
{
return (struct LevelSelection){.pack_cursor = 0};
}

View File

@ -7,8 +7,8 @@
#include <gint/keyboard.h>
/* Return 1 if game state should change. */
int levelselection_update(struct LevelSelection *levelselection,
struct Input input)
int
levelselection_update(struct LevelSelection *levelselection, struct Input input)
{
/* decrease selected pack id */
if (input.keystates[K_LEFT] == KS_PRESS &&

View File

@ -45,7 +45,8 @@ extern const font_t font_main;
static int callback(volatile int *arg);
int main(void)
int
main(void)
{
int i;
int timer;
@ -231,7 +232,8 @@ int main(void)
return 1;
}
static int callback(volatile int *arg)
static int
callback(volatile int *arg)
{
*arg += 1;
return 0;

View File

@ -6,7 +6,8 @@
#include "zxcolors.h"
#include <gint/display.h>
void mainmenu_draw(struct MainMenu mainmenu)
void
mainmenu_draw(struct MainMenu mainmenu)
{
int i = MENU_ENTRIES;
while (i-- > 0) {

View File

@ -3,4 +3,8 @@
#include "mainmenu.h"
struct MainMenu mainmenu_init(void) { return (struct MainMenu){.cursor = 0}; }
struct MainMenu
mainmenu_init(void)
{
return (struct MainMenu){.cursor = 0};
}

View File

@ -7,7 +7,8 @@
#include <gint/keyboard.h>
/* Return 1 if game state should change. */
int mainmenu_update(struct MainMenu *mainmenu, struct Input input)
int
mainmenu_update(struct MainMenu *mainmenu, struct Input input)
{
/* decrease selected pack id */
if (input.keystates[K_UP] == KS_PRESS ||

View File

@ -6,8 +6,9 @@
extern struct Particle particles[MAX_PARTICLES];
void particle_create(img_t *texture, int x, int y, int frame_width,
int frame_duration, int looping, int flip_h)
void
particle_create(img_t *texture, int x, int y, int frame_width,
int frame_duration, int looping, int flip_h)
{
/* find unused slot */
int i = MAX_PARTICLES;
@ -18,8 +19,9 @@ void particle_create(img_t *texture, int x, int y, int frame_width,
looping, flip_h);
}
struct Particle particle_init(img_t *texture, int x, int y, int frame_width,
int frame_duration, int looping, int flip_h)
struct Particle
particle_init(img_t *texture, int x, int y, int frame_width, int frame_duration,
int looping, int flip_h)
{
struct Particle particle;

View File

@ -6,14 +6,16 @@
extern struct Particle particles[MAX_PARTICLES];
void particles_draw(void)
void
particles_draw(void)
{
int i = MAX_PARTICLES;
while (i-- > 0)
particle_draw(particles[i]);
}
void particle_draw(struct Particle particle)
void
particle_draw(struct Particle particle)
{
if (!particle.life)
return;

View File

@ -5,7 +5,8 @@
struct Particle particles[MAX_PARTICLES];
void particles_init(void)
void
particles_init(void)
{
int i = MAX_PARTICLES;
while (i-- > 0) {

View File

@ -5,14 +5,16 @@
extern struct Particle particles[MAX_PARTICLES];
void particles_update(void)
void
particles_update(void)
{
int i = MAX_PARTICLES;
while (i-- > 0)
particle_update(&particles[i]);
}
void particle_update(struct Particle *particle)
void
particle_update(struct Particle *particle)
{
if (!particle->life)
return;

View File

@ -19,7 +19,8 @@ extern img_t img_exit_unlock_particle;
static Tile collide_single(int x, int y);
static int collide_sub_single(int x, int y, Tile sub, Tile rep);
void player_collide(Tile collisions[COLLIDE_POINTS], int x, int y, int margin)
void
player_collide(Tile collisions[COLLIDE_POINTS], int x, int y, int margin)
{
const int lx = x + margin;
const int rx = x + PLAYER_WIDTH - 1 - margin;
@ -31,8 +32,9 @@ void player_collide(Tile collisions[COLLIDE_POINTS], int x, int y, int margin)
collisions[DOWN_RIGHT] = collide_single(rx, dy);
}
int player_collide_tile(Tile collisions[COLLIDE_POINTS], int x, int y,
Tile tile, int margin, int update)
int
player_collide_tile(Tile collisions[COLLIDE_POINTS], int x, int y, Tile tile,
int margin, int update)
{
if (update)
player_collide(collisions, x, y, margin);
@ -45,7 +47,8 @@ int player_collide_tile(Tile collisions[COLLIDE_POINTS], int x, int y,
}
/* collide and replace tiles, return the number of tiles affecter */
int player_collide_sub(int x, int y, Tile sub, Tile rep, int margin)
int
player_collide_sub(int x, int y, Tile sub, Tile rep, int margin)
{
const int lx = x + margin;
const int rx = x + PLAYER_WIDTH - 1 - margin;
@ -57,13 +60,15 @@ int player_collide_sub(int x, int y, Tile sub, Tile rep, int margin)
collide_sub_single(rx, dy, sub, rep);
}
int player_collide_solid(int x, int y)
int
player_collide_solid(int x, int y)
{
Tile collisions[COLLIDE_POINTS];
return player_collide_tile(collisions, x, y, TILE_SOLID, 0, 1);
}
static Tile collide_single(int x, int y)
static Tile
collide_single(int x, int y)
{
const int tx = x / TILE_WIDTH;
const int ty = y / TILE_WIDTH;
@ -72,7 +77,8 @@ static Tile collide_single(int x, int y)
/* try collide and replace tile at pixel position, return 1 if tile
* replaced */
static int collide_sub_single(int x, int y, Tile sub, Tile rep)
static int
collide_sub_single(int x, int y, Tile sub, Tile rep)
{
if (collide_single(x, y) == sub) {
const int tile_index =

View File

@ -13,7 +13,8 @@ extern struct Level level;
extern bopti_image_t bimg_burst;
void player_draw(struct Player player)
void
player_draw(struct Player player)
{
/* set animation position */
struct Particle anim = player.anim;

View File

@ -15,7 +15,8 @@ extern img_t img_player_idle;
extern img_t img_player_jump;
extern img_t img_player_walk;
struct Player player_init(void)
struct Player
player_init(void)
{
int x = 0;
int y = 0;

View File

@ -15,7 +15,8 @@ extern struct Level level;
/* return -1 on pause, return 1 if exit reached, 2 on death/reset and 0
* otherwise */
int player_update(struct Player *player, struct Input input)
int
player_update(struct Player *player, struct Input input)
{
Tile collisions[COLLIDE_POINTS];
const int on_ground = player_collide_solid(player->x, player->y + 1);
@ -156,7 +157,8 @@ int player_update(struct Player *player, struct Input input)
return 0;
}
static void player_move(struct Player *player, int x, int y)
static void
player_move(struct Player *player, int x, int y)
{
const int sign_x = 1 * (x > 0) - 1 * (x < 0);
const int sign_y = 1 * (y > 0) - 1 * (y < 0);

View File

@ -6,7 +6,8 @@
#include "zxcolors.h"
#include <gint/display.h>
void titlescreen_draw(struct TitleScreen titlescreen)
void
titlescreen_draw(struct TitleScreen titlescreen)
{
dprint_opt(DWIDTH / 2, DHEIGHT * 1 / 3, ZX_WHITE, C_NONE, DTEXT_CENTER,
DTEXT_MIDDLE, GAME_NAME);

View File

@ -3,4 +3,8 @@
#include "titlescreen.h"
struct TitleScreen titlescreen_init(void) { return (struct TitleScreen){0}; }
struct TitleScreen
titlescreen_init(void)
{
return (struct TitleScreen){0};
}

View File

@ -6,7 +6,8 @@
#include <gint/keyboard.h>
/* Return 1 if game state should change. */
int titlescreen_update(struct TitleScreen *titlescreen, struct Input input)
int
titlescreen_update(struct TitleScreen *titlescreen, struct Input input)
{
if (input.keystates[K_A] == KS_PRESS) {
return 1;

View File

@ -3,7 +3,8 @@
#include "transition.h"
void transition_draw(struct Transition transition)
void
transition_draw(struct Transition transition)
{
switch (transition.mode) {
case TransitionNone:

View File

@ -8,7 +8,8 @@
static float square(float x);
static float isquare(float x);
void hfade_in(float step, color_t color)
void
hfade_in(float step, color_t color)
{
int line = isquare(step) * DWIDTH;
int x;
@ -18,7 +19,8 @@ void hfade_in(float step, color_t color)
}
}
void hfade_out(float step, color_t color)
void
hfade_out(float step, color_t color)
{
int line = square(step) * DWIDTH;
int x;
@ -28,7 +30,8 @@ void hfade_out(float step, color_t color)
}
}
void vfade_in(float step, color_t color)
void
vfade_in(float step, color_t color)
{
int line = isquare(step) * DHEIGHT;
int y;
@ -38,7 +41,8 @@ void vfade_in(float step, color_t color)
}
}
void vfade_out(float step, color_t color)
void
vfade_out(float step, color_t color)
{
int line = square(step) * DHEIGHT;
int y;
@ -48,6 +52,14 @@ void vfade_out(float step, color_t color)
}
}
static float square(float x) { return x * x; }
static float
square(float x)
{
return x * x;
}
static float isquare(float x) { return 1.0 - square(1.0 - x); }
static float
isquare(float x)
{
return 1.0 - square(1.0 - x);
}

View File

@ -3,8 +3,8 @@
#include "transition.h"
struct Transition transition_init(float speed, color_t color,
enum TransitionMode mode)
struct Transition
transition_init(float speed, color_t color, enum TransitionMode mode)
{
return (struct Transition){
.step = 0.0,

View File

@ -3,7 +3,8 @@
#include "transition.h"
enum TransitionMode transition_update(struct Transition *transition)
enum TransitionMode
transition_update(struct Transition *transition)
{
enum TransitionMode previous_transition_mode = TransitionNone;