Dawn progress
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
drawbattle.c
|
||||
drawstatemainmenu.c
|
||||
drawstateoverworld.c
|
||||
drawmap.c
|
||||
|
17
src/dawn/display/draw/drawbattle.c
Normal file
17
src/dawn/display/draw/drawbattle.c
Normal 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();
|
||||
}
|
13
src/dawn/display/draw/drawbattle.h
Normal file
13
src/dawn/display/draw/drawbattle.h
Normal 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();
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -8,6 +8,7 @@
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
battle.c
|
||||
mainmenu.c
|
||||
mapchange.c
|
||||
overworld.c
|
||||
|
17
src/dawn/game/state/battle.c
Normal file
17
src/dawn/game/state/battle.c
Normal 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();
|
||||
}
|
13
src/dawn/game/state/battle.h
Normal file
13
src/dawn/game/state/battle.h
Normal 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();
|
@ -4,6 +4,7 @@
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(battle)
|
||||
add_subdirectory(conversation)
|
||||
add_subdirectory(entity)
|
||||
add_subdirectory(world)
|
||||
|
12
src/dawn/rpg/battle/CMakeLists.txt
Normal file
12
src/dawn/rpg/battle/CMakeLists.txt
Normal 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
|
||||
)
|
37
src/dawn/rpg/battle/battle.c
Normal file
37
src/dawn/rpg/battle/battle.c
Normal 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;
|
||||
}
|
||||
}
|
40
src/dawn/rpg/battle/battle.h
Normal file
40
src/dawn/rpg/battle/battle.h
Normal 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();
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user