momento/src/levelselection/update.c

27 lines
707 B
C

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright (C) 2021 KikooDX */
#include "filepaths.h"
#include "input.h"
#include "levelselection.h"
#include <gint/keyboard.h>
/* Return 1 if game state should change. */
int
levelselection_update(struct LevelSelection *levelselection, struct Input input)
{
/* decrease selected pack id */
if (input.keystates[K_LEFT] == KS_PRESS &&
levelselection->pack_cursor > 0)
levelselection->pack_cursor -= 1;
/* increase selected pack id */
if (input.keystates[K_RIGHT] == KS_PRESS &&
levelselection->pack_cursor < PACK_COUNT - 1)
levelselection->pack_cursor += 1;
/* confirm */
if (input.keystates[K_A] == KS_PRESS)
return 1;
return 0;
}