Fix warnings and clang-format

This commit is contained in:
attilavs2 2024-08-01 17:48:10 +02:00
parent 322610d723
commit 5cc9216155
7 changed files with 40 additions and 30 deletions

View file

@ -1,7 +1,7 @@
#include <gint/display.h>
#include "animation.h"
#include <gint/display.h>
void animation_new(Animation *animation, bopti_image_t *image,
unsigned char len, unsigned short frame_ms) {
animation->image = image;

View file

@ -1,11 +1,11 @@
#ifndef GAME_H
#define GAME_H
#include "animation.h"
#include "events.h"
#include <gint/display.h>
#include <stdint.h>
#include "animation.h"
/* The direction where the player is going to. */
typedef enum { D_UP, D_DOWN, D_LEFT, D_RIGHT } Direction;

View file

@ -34,9 +34,18 @@ extern bopti_image_t tiny_npc_male;
extern Map *worldRPG[];
/* Game data (defined in "game.h")*/
Game game = {
NULL,
{12 * PXSIZE, 36 * PXSIZE, 0, 0, 100, SPEED, false, 0, false, false, true,
Game game = {NULL,
{12 * PXSIZE,
36 * PXSIZE,
0,
0,
100,
SPEED,
false,
0,
false,
false,
true,
{}},
{{}, {}, 0},
false,

View file

@ -180,8 +180,8 @@ void map_render_by_layer(Game *game, int layer) {
for(x = 0; x < dw; x++) {
/* I get the tile number if his position is inside the map. Then
* I draw it. */
if(tx + x >= 0 && tx + x < map_level->w && ty + y >= 0 &&
ty + y < map_level->h) {
if((tx + x >= 0) && (tx + x < (int)map_level->w) && (ty + y >= 0) &&
(ty + y < (int)map_level->h)) {
/* index of the current tile */
int currentIndex = (y + ty) * map_level->w + tx + x;
/* we get the ID of the tile in the current drawable layers

View file

@ -292,7 +292,8 @@ void npc_draw_single(NPC *npc, Game *game) {
int16_t delY = ((npc->cury * PXSIZE) >> PRECISION) - (int16_t)pl->y;
game->npc_animation.image = npc_sprites[npc->face];
unsigned char frame = game->npc_animation.frame;
if(npc->paused || !npc->hasPath) game->npc_animation.frame = 0;
if(npc->paused || !npc->hasPath)
game->npc_animation.frame = 0;
animation_draw(&game->npc_animation, pl->px - P_WIDTH / 2 + delX,
pl->py - P_HEIGHT / 2 + delY);
game->npc_animation.frame = frame;

View file

@ -50,8 +50,8 @@ void player_draw(Game *game) {
!keydown(KEY_DOWN)) {
game->player.animation.frame = 0;
}
player->animation.image = player->is_male ? &player_male_img :
&player_female_img;
player->animation.image =
player->is_male ? &player_male_img : &player_female_img;
animation_draw(&player->animation, player->px - P_WIDTH / 2,
player->py - P_HEIGHT / 2);
}