mirror of https://git.sr.ht/~kikoodx/momento
parent
b99611e526
commit
a11b9d1c52
|
@ -56,6 +56,9 @@ set(SOURCES
|
|||
src/mainmenu/init.c
|
||||
src/mainmenu/update.c
|
||||
src/mainmenu/draw.c
|
||||
src/pause/init.c
|
||||
src/pause/update.c
|
||||
src/pause/draw.c
|
||||
)
|
||||
|
||||
set(ASSETS
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Copyright (C) 2021 KikooDX */
|
||||
#pragma once
|
||||
|
||||
#include "input.h"
|
||||
|
||||
struct Pause {
|
||||
int cursor;
|
||||
};
|
||||
|
||||
struct Pause pause_init(void);
|
||||
/* Return 1 if game state should change. */
|
||||
int pause_update(struct Pause *pause, struct Input input);
|
||||
void pause_draw(struct Pause pause);
|
|
@ -7,3 +7,4 @@ float square(float x);
|
|||
float isquare(float x);
|
||||
float abs(float x);
|
||||
int sign(float x);
|
||||
void darken_vram(void);
|
||||
|
|
|
@ -8,7 +8,8 @@ struct Input
|
|||
input_init(void)
|
||||
{
|
||||
struct Input input = {
|
||||
.keycodes = {KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_SHIFT},
|
||||
.keycodes = {KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_SHIFT,
|
||||
KEY_MENU},
|
||||
};
|
||||
int i = KEYS_COUNT;
|
||||
while (i-- > 0)
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "input.h"
|
||||
#include "levelselection.h"
|
||||
#include "util.h"
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
/* Return 1 if game state should change. */
|
||||
int
|
||||
|
|
21
src/main.c
21
src/main.c
|
@ -8,6 +8,7 @@
|
|||
#include "levelselection.h"
|
||||
#include "mainmenu.h"
|
||||
#include "particles.h"
|
||||
#include "pause.h"
|
||||
#include "player.h"
|
||||
#include "titlescreen.h"
|
||||
#include "trail.h"
|
||||
|
@ -53,6 +54,7 @@ main(void)
|
|||
int i;
|
||||
int timer;
|
||||
int player_return_code;
|
||||
int draw_pause;
|
||||
int frameskip = 0;
|
||||
/* int level_pack_beaten; */
|
||||
enum TransitionMode transition_previous_mode;
|
||||
|
@ -64,6 +66,7 @@ main(void)
|
|||
struct TitleScreen titlescreen = titlescreen_init();
|
||||
struct LevelSelection levelselection = levelselection_init();
|
||||
struct MainMenu mainmenu = mainmenu_init();
|
||||
struct Pause pause = pause_init();
|
||||
struct Transition transition =
|
||||
transition_init(0.0, ZX_BLACK, TransitionNone);
|
||||
particles_init();
|
||||
|
@ -189,7 +192,13 @@ main(void)
|
|||
}
|
||||
break;
|
||||
case GamePause:
|
||||
game_state = Playing;
|
||||
if (pause_update(&pause, input)) {
|
||||
game_state = Playing;
|
||||
/* pause draw takes is _very_ slow,
|
||||
* reset frameskip to compensate */
|
||||
frameskip = 0;
|
||||
has_ticked = 0;
|
||||
}
|
||||
break;
|
||||
case PackDone:
|
||||
game_state = LevelSelection;
|
||||
|
@ -200,6 +209,7 @@ main(void)
|
|||
}
|
||||
}
|
||||
/* draw */
|
||||
draw_pause = 0;
|
||||
dclear(ZX_BLACK);
|
||||
switch (game_state) {
|
||||
case TitleScreen:
|
||||
|
@ -211,6 +221,9 @@ main(void)
|
|||
case LevelSelection:
|
||||
levelselection_draw(levelselection);
|
||||
break;
|
||||
case GamePause:
|
||||
draw_pause = 1;
|
||||
/* fallthrough */
|
||||
case Playing:
|
||||
level_draw();
|
||||
trail_draw();
|
||||
|
@ -218,8 +231,10 @@ main(void)
|
|||
trail_draw();
|
||||
player_draw(player);
|
||||
transition_draw(transition);
|
||||
break;
|
||||
case GamePause:
|
||||
if (!draw_pause)
|
||||
break;
|
||||
/* GamePause */
|
||||
pause_draw(pause);
|
||||
break;
|
||||
case PackDone:
|
||||
break;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "filepaths.h"
|
||||
#include "input.h"
|
||||
#include "mainmenu.h"
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
/* Return 1 if game state should change. */
|
||||
int
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "pause.h"
|
||||
#include "util.h"
|
||||
#include "zxcolors.h"
|
||||
#include <gint/display.h>
|
||||
|
||||
void
|
||||
pause_draw(struct Pause pause)
|
||||
{
|
||||
darken_vram();
|
||||
dprint_opt(DWIDTH / 2, DHEIGHT * 1 / 2, ZX_WHITE, ZX_BLACK,
|
||||
DTEXT_CENTER, DTEXT_MIDDLE, "GAME PAUSED");
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "pause.h"
|
||||
|
||||
struct Pause
|
||||
pause_init(void)
|
||||
{
|
||||
return (struct Pause){.cursor = 0};
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "input.h"
|
||||
#include "pause.h"
|
||||
|
||||
/* Return 1 if game state should change. */
|
||||
int
|
||||
pause_update(struct Pause *pause, struct Input input)
|
||||
{
|
||||
if (input.keystates[K_START] == KS_PRESS) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
#include "player.h"
|
||||
#include "tiles.h"
|
||||
#include "util.h"
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
static void player_move(struct Player *player, int x, int y);
|
||||
static void player_set_anim(struct Player *player, enum AnimState new_anim);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "input.h"
|
||||
#include "titlescreen.h"
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
/* Return 1 if game state should change. */
|
||||
int
|
||||
|
|
10
src/util.c
10
src/util.c
|
@ -2,6 +2,7 @@
|
|||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "util.h"
|
||||
#include <gint/display.h>
|
||||
|
||||
float
|
||||
square(float x)
|
||||
|
@ -26,3 +27,12 @@ sign(float x)
|
|||
{
|
||||
return 1 * (x > 0) - 1 * (x < 0);
|
||||
}
|
||||
|
||||
/* courtesy of Lephenixnoir */
|
||||
void
|
||||
darken_vram(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < DWIDTH * DHEIGHT; i++)
|
||||
gint_vram[i] = (gint_vram[i] & 0xf7de) >> 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue