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

@ -17,6 +17,9 @@
} }
}, },
"entities": { "entities": {
"sign": {
"name": "Sign"
}
}, },
"maps": { "maps": {
"testmap": { "testmap": {
@ -32,5 +35,8 @@
"0": "Stairs slippery when wet.\n\n<- West to Town.\n-> East to lakefront." "0": "Stairs slippery when wet.\n\n<- West to Town.\n-> East to lakefront."
} }
} }
},
"battle": {
"start": "Battle Start!"
} }
} }

View File

@ -3,11 +3,10 @@
"height": 4300, "height": 4300,
"width": 2 "width": 2
}, },
"activeFile": "tilemaps/entities.tsx", "activeFile": "maps/testmap.tmx",
"expandedProjectPaths": [ "expandedProjectPaths": [
"maps",
".", ".",
"tilemaps" "maps"
], ],
"file.lastUsedOpenFilter": "All Files (*)", "file.lastUsedOpenFilter": "All Files (*)",
"fileStates": { "fileStates": {
@ -22,8 +21,8 @@
"scale": 4.9072, "scale": 4.9072,
"selectedLayer": 0, "selectedLayer": 0,
"viewCenter": { "viewCenter": {
"x": 49.31529181610695, "x": 39.94131072709489,
"y": 54.002282360612995 "y": 40.0432018258885
} }
}, },
"maps/testmap.tmx": { "maps/testmap.tmx": {
@ -33,8 +32,8 @@
"scale": 3.404166666666667, "scale": 3.404166666666667,
"selectedLayer": 1, "selectedLayer": 1,
"viewCenter": { "viewCenter": {
"x": 120.1468788249694, "x": 95.17747858017135,
"y": 79.75520195838433 "y": 86.80538555691552
} }
}, },
"maps/testmap2.tmx": { "maps/testmap2.tmx": {
@ -44,7 +43,7 @@
"scale": 5.0383, "scale": 5.0383,
"selectedLayer": 1, "selectedLayer": 1,
"viewCenter": { "viewCenter": {
"x": 19.94720441418733, "x": 19.84796459123116,
"y": 19.947204414187325 "y": 19.947204414187325
} }
}, },
@ -55,8 +54,8 @@
"scale": 2.7603, "scale": 2.7603,
"selectedLayer": 1, "selectedLayer": 1,
"viewCenter": { "viewCenter": {
"x": 85.49795312103754, "x": 160.48980183313407,
"y": 157.22928667173855 "y": 120.4579212404449
} }
}, },
"testmap.tmx": { "testmap.tmx": {
@ -95,18 +94,16 @@
"map.tileWidth": 8, "map.tileWidth": 8,
"map.width": 10, "map.width": 10,
"openFiles": [ "openFiles": [
"maps/train_station.tmx", "maps/testmap.tmx"
"tilemaps/entities.tsx",
"maps/downtown.tmx"
], ],
"project": "tiled_project.tiled-project", "project": "tiled_project.tiled-project",
"property.type": "string", "property.type": "string",
"recentFiles": [ "recentFiles": [
"maps/train_station.tmx",
"maps/downtown.tmx",
"tilemaps/entities.tsx",
"maps/testmap.tmx", "maps/testmap.tmx",
"maps/testmap2.tmx" "maps/downtown.tmx",
"maps/testmap2.tmx",
"maps/train_station.tmx",
"tilemaps/entities.tsx"
], ],
"tileset.lastUsedFilter": "All Files (*)", "tileset.lastUsedFilter": "All Files (*)",
"tileset.lastUsedFormat": "tsx", "tileset.lastUsedFormat": "tsx",

View File

@ -8,6 +8,7 @@
# Sources # Sources
target_sources(${DAWN_TARGET_NAME} target_sources(${DAWN_TARGET_NAME}
PRIVATE PRIVATE
drawbattle.c
drawstatemainmenu.c drawstatemainmenu.c
drawstateoverworld.c drawstateoverworld.c
drawmap.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/drawtext.h"
#include "display/draw/drawstateoverworld.h" #include "display/draw/drawstateoverworld.h"
#include "display/draw/drawstatemainmenu.h" #include "display/draw/drawstatemainmenu.h"
#include "display/draw/drawbattle.h"
char_t FRAME_BUFFER[FRAME_HEIGHT * FRAME_WIDTH]; char_t FRAME_BUFFER[FRAME_HEIGHT * FRAME_WIDTH];
uint8_t FRAME_COLOR[FRAME_HEIGHT * FRAME_WIDTH]; uint8_t FRAME_COLOR[FRAME_HEIGHT * FRAME_WIDTH];
@ -41,6 +42,10 @@ void frameUpdate() {
case GAME_STATE_MAIN_MENU: case GAME_STATE_MAIN_MENU:
drawStateMainMenu(); drawStateMainMenu();
break; break;
case GAME_STATE_BATTLE:
drawBattle();
break;
default: default:
printf("Rendering unknown game state: %d\n", GAME.state); printf("Rendering unknown game state: %d\n", GAME.state);

View File

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

View File

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

View File

@ -8,6 +8,7 @@
# Sources # Sources
target_sources(${DAWN_TARGET_NAME} target_sources(${DAWN_TARGET_NAME}
PRIVATE PRIVATE
battle.c
mainmenu.c mainmenu.c
mapchange.c mapchange.c
overworld.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 # https://opensource.org/licenses/MIT
# Subdirs # Subdirs
add_subdirectory(battle)
add_subdirectory(conversation) add_subdirectory(conversation)
add_subdirectory(entity) add_subdirectory(entity)
add_subdirectory(world) 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 "locale/language.h"
#include "rpg/conversation/conversationinteractentity.h" #include "rpg/conversation/conversationinteractentity.h"
#include "rpg/conversation/conversationinteracttile.h" #include "rpg/conversation/conversationinteracttile.h"
#include "rpg/battle/battle.h"
void entityInteractEntity( void entityInteractEntity(
entity_t *source, entity_t *source,
@ -37,6 +38,11 @@ void entityInteractEntity(
return; return;
case ENTITY_TYPE_SIGN: case ENTITY_TYPE_SIGN:
battleStart(
);
return;
conversationSet( conversationSet(
conversationInteractEntityInit, conversationInteractEntityInit,
conversationInteractEntityUpdate, conversationInteractEntityUpdate,

View File

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