Work Life (Visual Novel / Game)
|
visual-novel library More...
Classes | |
struct | MenuChoice |
struct passed to a vnlib::menu More... | |
struct | MenuOptions |
struct pass to vnlib::menu More... | |
struct | SayOptions |
options passed to vnlib::say More... | |
Typedefs | |
typedef void(* | story_fx) () |
a function used to store part of a story | |
typedef void(* | end_fx) (EndingType) |
called when an end happens. should queue or reset gameplay | |
Enumerations | |
enum | AnimationSlot { SLOT_8_1 = 0 , SLOT_8_2 = 1 , SLOT_8_3 = 2 , SLOT_8_4 = 3 , SLOT_8_5 = 4 , SLOT_8_6 = 5 , SLOT_8_7 = 6 , SLOT_8_8 = 7 , SLOT_8_9 = 8 , SLOT_8_10 = 9 , SLOT_32_1 = 24 , SLOT_32_2 = 25 } |
animation slot to save to (workaround vector of animation bug) | |
enum | EndingType { BAD_END = 0 , GOOD_END = 1 , PERFECT_END = 2 } |
type of ending. these options may or may not stop gameplay More... | |
Functions | |
void | bg (bn::regular_bg_item item) |
show a bg. see Design: Sprite Sizes | |
void | fade_out_to_black () |
bg => black | |
void | fade_in_from_black () |
black => bg | |
void | show (bn::regular_bg_item who) |
show a person stored in bg. see Design: Sprite Sizes | |
void | hide () |
hide a person if shown | |
void | play_music (std::initializer_list< bn::sound_item > items) |
queue a list of musical sounds | |
void | stop_music () |
stop all music instantly | |
void | say (bn::string_view who, std::initializer_list< bn::string_view > what) |
say function using default SayOptions | |
void | say (bn::string_view who, std::initializer_list< bn::string_view > what, SayOptions options) |
open the textbox with "who" as heading and "what" lines | |
void | hide_say () |
hide the dialog box | |
MenuChoice | choice (bn::string_view option, story_fx) |
convenience factory function for menu options | |
MenuOptions | default_MenuOptions () |
default MenuOptions | |
MenuOptions | dense_MenuOptions () |
brief dense MenuOptions (used for playtest menus) | |
void | menu (std::initializer_list< MenuChoice > choices) |
prompt the player for a menu choice (menu options on screen) | |
void | menu (std::initializer_list< MenuChoice > choices, MenuOptions *options) |
prompt the player for a menu choice, toggling various options (menu options on screen) | |
bn::string< 8 > | keyboard_input_8 () |
prompt the player for text input (keyboard on screen) | |
bn::string< 8 > | keyboard_input_8 (bn::string< 8 > starting_from) |
prompt the player for text input starting from the string provided | |
void | text (bn::string_view text, bn::fixed x, bn::fixed y) |
ad-hoc text display | |
void | sprite (bn::sprite_item item, bn::fixed x, bn::fixed y) |
ad-hoc sprite display | |
void | animate_8 (bn::sprite_item item, bn::fixed x, bn::fixed y, AnimationSlot slot, int, int, int, int, int, int, int, int) |
ad-hoc sprite display using 8 frames | |
void | animate_32 (bn::sprite_item item, bn::fixed x, bn::fixed y, AnimationSlot slot, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) |
ad-hoc sprite display using 32 frames | |
void | free (AnimationSlot slot) |
destroy animation at slot | |
void | end (EndingType type) |
end the story run | |
void | free () |
destroy all element in the scene manage by vnlib | |
bool | wait_save_screen () |
trigger the save/load screen where a selection should persist data from Global Game State => Global Save State => SRAM | |
bool | wait_load_screen () |
trigger the save/load screen where a selection should load data from SRAM => Global Save State => Global Game State | |
void | set_save_screen (bn::regular_bg_item bg_save_screen_item) |
used when save/load. see Design: Sprite Sizes | |
void | set_bg_textbox (bn::regular_bg_item bg_textbox_item) |
textbox used when displaying dialog. see Design: Sprite Sizes | |
void | set_keyboard (bn::regular_bg_item bg_keyboard_item) |
keyboard used when prompting for keyboard input. see Design: Sprite Sizes | |
void | set_cursor (bn::sprite_item cursor_item) |
cursor used for main menu, keyboard, save screen, and in-game menu prompts. see Design: Sprite Sizes | |
void | set_menu_option_left (bn::sprite_item menu_option_item) |
set sprite behind menu options (left) see Design: Sprite Sizes | |
void | set_menu_option_right (bn::sprite_item menu_option_item) |
set sprite behind menu options (right) see Design: Sprite Sizes | |
void | set_story_init (story_fx) |
set the story called when game is initialized (usually a title or splash screen) | |
void | set_read_all_saves (void(*read_all_saves)()) |
callback function used to read all save functions from SRAM (read SRAM into global save state) | |
void | set_save_slot_selected (void(*save_slot_selected)(int slot)) |
callback function used when a save slot is selected (load slot into global game state) | |
void | set_write_to_slot (void(*write_to_slot)(int slot)) |
callback function used when a slot is selected to write to (global game state => global save state => SRAM) | |
void | set_render_save_slot (void(*render)(int slot, bn::fixed x, bn::fixed y, bn::sprite_text_generator gen, bn::vector< bn::sprite_ptr, 96 > *sprites)) |
callback function used to paint the save slot on Save Screen. x and y are used to denote top-left corner of save slot | |
void | set_end_fx (end_fx) |
set the end_fx when vnlib::end is called | |
void | set_fade_times (int times) |
control the global fade count when fading in or out | |
void | maybe_handle_ending () |
if global end state is set, run the end_fx | |
void | main () |
control loop that will run the story_fx stored in vnlib::next | |
void | next (story_fx) |
queue the next story function onto a size-1 stack. will overwrite if a value exists! | |
void | maybe_animate () |
maybe advance animation frames | |
void | maybe_play_queue () |
maybe play running music | |
void | wait_times (int times) |
wait a variable amount | |
void | wait_for_a_not_held (bool enable_fastforward) |
internal function to wait until a key not held | |
void | wait_for_key_press (bool enable_fastforward) |
internal function to wait until a key is held | |
int | wait_for_menu_item (int item_count, void(*render)(int)) |
internal function to wait until a menu item is selected | |
int | wait_for_grid_any (int item_count, int cols, int selection, void(*render)(int)) |
internal function to wait until the final item in a grid is selected | |
void | wait_for_grid_last (int item_count, int cols, void(*render)(int), void(*pressed)(int)) |
internal function to wait until the final item in a grid is selected | |
void | create_cursor () |
create and store the cursor sprite | |
void | free_cursor () |
free cursor and animation | |
void | render_menu_cursor (int selection) |
render the cursor when a menu is prompted and when menu choice changes | |
void | render_keyboard_cursor (int selection) |
render the cursor when a keyboard input changes | |
void | keyboard_input (void(*selected)(int)) |
render keyboard and cursor and wait for input | |
void | keyboard_input_8_selection (int selection) |
render keyboard cursor selection change | |
void | render_save_cursor (int choice) |
render cursor when choosing save/load slots | |
int | wait_save_load_screen () |
generic render and wait for the save and load screen | |
void | wait_credits_screen () |
render credits and wait for input to close | |
void | render_title_cursor (int choice) |
render cursor when at the title screen | |
Variables | |
bn::fixed | alpha = 0 |
global alpha for tracking fading state | |
int | music_index = 0 |
global variable used for music | |
constexpr int | max_volume_level = 1.0 |
max volume level | |
constexpr bn::fixed | init_volume_level = max_volume_level |
volume level music should start at | |
int | alpha_index = 0 |
global alpha_index to record if faded in/out | |
bn::fixed | alphas [] = {0.0, 0.2, 0.4, 0.6, 0.8, 1.0} |
alpha levels per _fade_times | |
MenuOptions | menu_options |
internal | |
const char | alphabet [27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
alphabet used for keyboard input | |
bn::string< 8 > | output_8 |
global variable used for keyboard input | |
int | write_pos |
global variable used for keyboard input | |
visual-novel library
this includes common game components and state management.
just enough to get started with the most basic of games. though advanced games will use it more like a library than a framework.
typedef void(* vnlib::story_fx) () |
a function used to store part of a story
can be defined in-line using lambdas (common for a vnlib::choice) or as a normal named function.
example lambda: vnlib::story_fx my_story = [](){ vnlib::say("MyChar", {"inside lambda"}); }
given that games will reference a global game state, lambdas can avoid using the capture clause (the []
part) and the args (the ()
part). more information on lambdas: https://en.cppreference.com/w/cpp/language/lambda
enum vnlib::EndingType |
type of ending. these options may or may not stop gameplay
MenuChoice vnlib::choice | ( | bn::string_view | option, |
story_fx | story ) |
convenience factory function for menu options
usually constructed with the following:
example preprocessor define for readability:
bn::string< 8 > vnlib::keyboard_input_8 | ( | bn::string< 8 > | starting_from | ) |
prompt the player for text input starting from the string provided
render keyboard and wait for 8 characters of input
void vnlib::say | ( | bn::string_view | who, |
std::initializer_list< bn::string_view > | what, | ||
SayOptions | options ) |
open the textbox with "who" as heading and "what" lines
usually used like the following:
example preprocessor define for readability: