From d15415d2cd176f0bc8e4cb794c013c61b0f8d62f Mon Sep 17 00:00:00 2001 From: hgn Date: Tue, 11 Jan 2022 02:11:07 +0000 Subject: [PATCH] cmp_plot3x3 --- fishladder.c | 55 +++++++++++++++++++++++++++++++++++++----- fishladder_resources.h | 9 +++++++ maps/cmp_plot3x3.map | 25 +++++++++++++++++++ 3 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 maps/cmp_plot3x3.map diff --git a/fishladder.c b/fishladder.c index 0a27172..08406bc 100644 --- a/fishladder.c +++ b/fishladder.c @@ -65,6 +65,12 @@ enum e_world_button k_world_button_settings = 3 }; +enum e_game_state +{ + k_game_state_main, + k_game_state_settings +}; + #define FLAG_CANAL 0x1 #define FLAG_IS_TRIGGER 0x2 #define FLAG_RESERVED0 0x4 @@ -187,10 +193,17 @@ text_buffers; static struct world { + // Things that are 'static', aka, initialized once struct { struct world_button buttons[4]; float zoom; + enum e_game_state state; + + struct cmp_level *lvl_to_load; + float lvl_load_time; + + float world_transition; } st; @@ -206,7 +219,6 @@ static struct world #pragma pack(pop) int initialzed; - int sim_run, max_runs; int sim_frame, sim_target; @@ -267,7 +279,6 @@ static struct world int num_fishes; char map_name[64]; - //struct career_level *ptr_career_level; struct cmp_level *pCmpLevel; u32 score; @@ -967,6 +978,10 @@ static int map_load( const char *str, const char *name ) v2i turtle; v2i turtle_dir; int original_y; + + // Only make breakouts for terminals on the edge + if( !(term->pos[1] == 1 || term->pos[1] == world.h-2) ) + continue; turtle[0] = 16+term->pos[0]; turtle[1] = 16+term->pos[1]; @@ -1471,6 +1486,27 @@ static int cell_interactive( v2i co ) static void vg_update(void) { + // Async events + if( world.st.lvl_to_load ) + { + world.st.world_transition = (world.st.lvl_load_time-vg_time) * 4.0f; + + if( vg_time > world.st.lvl_load_time ) + { + if( console_changelevel( 1, &world.st.lvl_to_load->map_name ) ) + { + world.pCmpLevel = world.st.lvl_to_load; + gen_level_text( world.pCmpLevel ); + } + + world.st.lvl_to_load = NULL; + } + } + else + { + world.st.world_transition = vg_minf( 1.0f, (vg_time-world.st.lvl_load_time) * 4.0f ); + } + // Camera // ======================================================================================================== @@ -2368,11 +2404,17 @@ static void level_selection_buttons(void) if( switch_level_to ) { + world.st.lvl_to_load = switch_level_to; + world.st.lvl_load_time = vg_time + 0.25f; + world.st.world_transition = 1.0f; + + /* if( console_changelevel( 1, &switch_level_to->map_name ) ) { world.pCmpLevel = switch_level_to; gen_level_text( world.pCmpLevel ); } + */ } } @@ -2413,7 +2455,7 @@ void vg_render(void) glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, world.random_samples ); glUniform1i( SHADER_UNIFORM( shader_background, "uSamplerNoise" ), 1 ); - glUniform1f( SHADER_UNIFORM( shader_background, "uVisibility" ), 1.0f ); // (sinf( vg_time ) + 1.0f) * 0.5f ); + glUniform1f( SHADER_UNIFORM( shader_background, "uVisibility" ), 1.0f ); //world.st.world_transition ); draw_mesh( 0, 2 ); @@ -2428,7 +2470,7 @@ void vg_render(void) glUniformMatrix3fv( SHADER_UNIFORM( shader_tile_main, "uPv" ), 1, GL_FALSE, (float *)vg_pv ); glUniform1f( SHADER_UNIFORM( shader_tile_main, "uGhost" ), 0.0f ); glUniform1f( SHADER_UNIFORM( shader_tile_main, "uForeground" ), 0.0f ); - glUniform1f( SHADER_UNIFORM( shader_tile_main, "uVisibility" ), 2.0f ); // sinf( vg_time ) + 1.0f ); + glUniform1f( SHADER_UNIFORM( shader_tile_main, "uVisibility" ), world.st.world_transition * 2.0f ); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -2638,7 +2680,7 @@ void vg_render(void) if( world_button_exec( &world.st.buttons[k_world_button_settings], (v2f){ 1.0f, 2.0f }, btn_orange, &stat )) { - //world.st.state = k_game_settings; + world.st.state = stat == k_world_button_on_enable? k_game_state_settings: k_game_state_main; } level_selection_buttons(); @@ -3117,9 +3159,10 @@ static int console_changelevel( int argc, char const *argv[] ) { // Save current level console_save_map( 0, NULL ); + if( console_load_map( argc, argv ) ) { - world_static.zoom = 0.0f; + world.st.zoom = 0.0f; simulation_stop(); return 1; } diff --git a/fishladder_resources.h b/fishladder_resources.h index f0371c1..82efc47 100644 --- a/fishladder_resources.h +++ b/fishladder_resources.h @@ -463,6 +463,7 @@ SHADER_DEFINE( shader_background, "vec4 data_this_tile = texture( uTexMain, aTexCoords );" "ao_accum -= data_this_tile.r;" + "ao_accum *= uVisibility;" "vec3 colour_main = mix( vec3( 0.369768, 0.3654, 0.42 ), vec3( 0.275, 0.388, 0.553 ), data_this_tile.g * uVisibility );" @@ -927,6 +928,14 @@ static struct cmp_level cmp_levels_computer[] = .serial_id = 24, .title = "3 BIT ADDITION", .map_name = "cmp_add3b", + .description = "", + + ._unlock = 25 + }, + { + .serial_id = 25, + .title = "3x3 PLOT", + .map_name = "cmp_plot3x3", .description = "" } }; diff --git a/maps/cmp_plot3x3.map b/maps/cmp_plot3x3.map new file mode 100644 index 0000000..cfb4d01 --- /dev/null +++ b/maps/cmp_plot3x3.map @@ -0,0 +1,25 @@ +#####################; +#####-####-####-#####;:::::b,:::b::,:b:::: +### ###; +## ##; +## ### ### ### ##; +## ### ### ### ##; +## #-# #-# #-# ##;:::::,b:::::,::::: +## ##; +## ##; +## ### ### ### ##; +## ### ### ### ##; +## #-# #-# #-# ##;::b:::,::::b:,::::: +## ##; +## ##; +## ##; +## ##; +## ##; +### ###; +### ###; +## ##; +## ##; +## ##; +### ###; +####+###+#+###+#+####;b:b:b:b:b:b,:a::::,a:::a:a:,::a::a:,a::::: +#####################; -- 2.25.1