Dawn progress

This commit is contained in:
2024-11-07 18:28:54 -06:00
parent 6a0ffd4a45
commit 53dc496f2f
17 changed files with 191 additions and 19 deletions

View File

@ -8,6 +8,7 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
drawbattle.c
drawstatemainmenu.c
drawstateoverworld.c
drawmap.c

View File

@ -0,0 +1,17 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "drawbattle.h"
#include "display/draw/drawshape.h"
#include "display/draw/drawui.h"
void drawBattle() {
drawClear(' ', COLOR_WHITE);
// Draw UI
drawUITextbox();
}

View File

@ -0,0 +1,13 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
/**
* Draws the battle state.
*/
void drawBattle();

View File

@ -12,6 +12,7 @@
#include "display/draw/drawtext.h"
#include "display/draw/drawstateoverworld.h"
#include "display/draw/drawstatemainmenu.h"
#include "display/draw/drawbattle.h"
char_t FRAME_BUFFER[FRAME_HEIGHT * FRAME_WIDTH];
uint8_t FRAME_COLOR[FRAME_HEIGHT * FRAME_WIDTH];
@ -41,6 +42,10 @@ void frameUpdate() {
case GAME_STATE_MAIN_MENU:
drawStateMainMenu();
break;
case GAME_STATE_BATTLE:
drawBattle();
break;
default:
printf("Rendering unknown game state: %d\n", GAME.state);

View File

@ -18,6 +18,7 @@
#include "game/state/mainmenu.h"
#include "game/state/mapchange.h"
#include "game/state/overworld.h"
#include "game/state/battle.h"
#include "rpg/conversation/conversation.h"
#include "asset/assetlanguage.h"
@ -68,6 +69,10 @@ gameupdateresult_t gameUpdate(const float_t delta) {
gameStateMainMenuUpdate();
break;
case GAME_STATE_BATTLE:
gameStateBattleUpdate();
break;
default:
printf("Updating unknown state %d\n", GAME.state);
}

View File

@ -18,7 +18,8 @@ typedef enum {
GAME_STATE_OVERWORLD = 1,
GAME_STATE_PAUSED = 2,
GAME_STATE_MAP_CHANGE = 3,
GAME_STATE_MAIN_MENU = 4
GAME_STATE_MAIN_MENU = 4,
GAME_STATE_BATTLE = 5
} gamestate_t;
typedef struct {

View File

@ -8,6 +8,7 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
battle.c
mainmenu.c
mapchange.c
overworld.c

View File

@ -0,0 +1,17 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "battle.h"
#include "game/game.h"
#include "ui/textbox.h"
#include "rpg/battle/battle.h"
void gameStateBattleUpdate() {
battleUpdate();
textboxUpdate();
}

View File

@ -0,0 +1,13 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
/**
* Updates the battle state.
*/
void gameStateBattleUpdate();

View File

@ -4,6 +4,7 @@
# https://opensource.org/licenses/MIT
# Subdirs
add_subdirectory(battle)
add_subdirectory(conversation)
add_subdirectory(entity)
add_subdirectory(world)

View File

@ -0,0 +1,12 @@
# Copyright (c) 2024 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Subdirs
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
battle.c
)

View File

@ -0,0 +1,37 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "assert/assert.h"
#include "battle.h"
#include "util/memory.h"
#include "game/game.h"
#include "ui/textbox.h"
battle_t BATTLE;
void battleInit() {
memorySet(&BATTLE, 0, sizeof(battle_t));
}
void battleStart() {
GAME.state = GAME_STATE_BATTLE;
BATTLE.state = BATTLE_STATE_INITIAL;
textboxSetText(NULL, "battle.start");
}
void battleUpdate() {
switch(BATTLE.state) {
case BATTLE_STATE_INITIAL:
if(textboxIsOpen()) return;
break;
default:
assertUnreachable("Unknown battle state.");
break;
}
}

View File

@ -0,0 +1,40 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dawn.h"
typedef enum {
BATTLE_STATE_INITIAL
} battlestate_t;
typedef struct {
} battlefighter_t;
typedef struct {
battlestate_t state;
} battle_t;
extern battle_t BATTLE;
/**
* Initializes the battle system.
*/
void battleInit();
/**
* Starts a battle.
*/
void battleStart(
);
/**
* Updates the battle system.
*/
void battleUpdate();

View File

@ -11,6 +11,7 @@
#include "locale/language.h"
#include "rpg/conversation/conversationinteractentity.h"
#include "rpg/conversation/conversationinteracttile.h"
#include "rpg/battle/battle.h"
void entityInteractEntity(
entity_t *source,
@ -37,6 +38,11 @@ void entityInteractEntity(
return;
case ENTITY_TYPE_SIGN:
battleStart(
);
return;
conversationSet(
conversationInteractEntityInit,
conversationInteractEntityUpdate,

View File

@ -38,7 +38,7 @@ void mainMenuSelectCallback(
) {
// New Game
if(y == 0) {
GAME.mapNext = MAP_LIST_TRAIN_STATION;
GAME.mapNext = MAP_LIST_TEST;
GAME.state = GAME_STATE_MAP_CHANGE;
return;
}