aboutsummaryrefslogtreecommitdiff
path: root/src/sdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdl')
-rw-r--r--src/sdl/action.c2
-rw-r--r--src/sdl/draw.c11
-rw-r--r--src/sdl/main.c9
-rw-r--r--src/sdl/util.h2
4 files changed, 17 insertions, 7 deletions
diff --git a/src/sdl/action.c b/src/sdl/action.c
index 8bc01f7..415c3f5 100644
--- a/src/sdl/action.c
+++ b/src/sdl/action.c
@@ -23,7 +23,7 @@
case SDLK_k: \
case SDLK_l:
-static const sok_dir_t
+static sok_dir_t
keycode_to_dir(const SDL_Keycode code) {
switch (code) {
case SDLK_UP: return SOK_DIR_UP;
diff --git a/src/sdl/draw.c b/src/sdl/draw.c
index 0d2b17a..5bb8de7 100644
--- a/src/sdl/draw.c
+++ b/src/sdl/draw.c
@@ -79,6 +79,7 @@ draw_on_size(
const sok_pos_t level_size,
void * const data
) {
+ UNUSED(ctx);
draw_ctx_t * const draw_ctx = data;
const size_t cell_size = get_cell_size(draw_ctx);
@@ -98,7 +99,7 @@ draw_on_size(
// draw floor
for (size_t y = 0; y < level_size.y; y++) {
for (size_t x = 0; x < level_size.x; x++) {
- if (x > 0 && y > 0 && x < level_size.x - 1 && y < level_size.y - 1) {
+ if (x && y && x < (size_t) (level_size.x - 1) && y < (size_t) (level_size.y - 1)) {
const sok_pos_t pos = { x, y };
draw_cell(draw_ctx, pos, SPRITE_FLOOR, 0);
}
@@ -114,6 +115,7 @@ draw_on_wall(
const sok_pos_t pos,
void * const data
) {
+ UNUSED(ctx);
draw_ctx_t * const draw_ctx = data;
draw_cell(draw_ctx, pos, SPRITE_WALL, 0);
return true;
@@ -127,6 +129,9 @@ draw_on_goal(
const bool has_box,
void * const data
) {
+ UNUSED(ctx);
+ UNUSED(has_player);
+ UNUSED(has_box);
draw_ctx_t * const draw_ctx = data;
draw_cell(draw_ctx, pos, SPRITE_GOAL, 0);
return true;
@@ -139,6 +144,8 @@ draw_on_home(
const bool has_goal,
void * const data
) {
+ UNUSED(ctx);
+ UNUSED(has_goal);
draw_ctx_t * const draw_ctx = data;
const double angle = sok_ctx_is_done(draw_ctx->ctx) ? (10 * sin(draw_ctx->ticks * M_2_PI / 1000.0)) : 0;
@@ -154,6 +161,8 @@ draw_on_box(
const bool has_goal,
void * const data
) {
+ UNUSED(ctx);
+ UNUSED(has_goal);
draw_ctx_t * const draw_ctx = data;
const double angle = sok_ctx_is_done(draw_ctx->ctx) ? (5 * sin((100 * (pos.y + pos.x) + draw_ctx->ticks) * M_2_PI / 1000.0)) : 0;
diff --git a/src/sdl/main.c b/src/sdl/main.c
index ca0574d..46f30c3 100644
--- a/src/sdl/main.c
+++ b/src/sdl/main.c
@@ -37,7 +37,7 @@ load_font(
const asset_id_t id
) {
// get asset
- const asset_t * const asset = asset_get(ASSET_ROBOTO_TTF);
+ const asset_t * const asset = asset_get(id);
if (!asset) {
die("asset_get()");
}
@@ -67,7 +67,6 @@ solve_on_error(
static void
set_level(
- SDL_Window * const win,
draw_ctx_t * const draw_ctx,
sok_ctx_t * const ctx,
const size_t level_num
@@ -156,7 +155,7 @@ int main(int argc, char *argv[]) {
};
// set level
- set_level(win, &draw_ctx, &ctx, level_num);
+ set_level(&draw_ctx, &ctx, level_num);
// init sprites, load font
sprites_init(renderer, draw_ctx.sprites);
@@ -198,7 +197,7 @@ int main(int argc, char *argv[]) {
level_num++;
// set level
- set_level(win, &draw_ctx, &ctx, level_num);
+ set_level(&draw_ctx, &ctx, level_num);
} else {
warn("cannot advance to next level");
}
@@ -214,7 +213,7 @@ int main(int argc, char *argv[]) {
case ACTION_WARP:
if (warp_buf_get(&warp_buf, &level_num)) {
// load level
- set_level(win, &draw_ctx, &ctx, level_num);
+ set_level(&draw_ctx, &ctx, level_num);
// clear warp buf
warp_buf_clear(&warp_buf);
diff --git a/src/sdl/util.h b/src/sdl/util.h
index 8d7e130..da347e3 100644
--- a/src/sdl/util.h
+++ b/src/sdl/util.h
@@ -1,6 +1,8 @@
#ifndef UTIL_H
#define UTIL_H
+#define UNUSED(a) ((void) (a))
+
#define warn(...) do { \
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
} while (0)