bunch of stuff for pre-alpha build
authorhgn <hgodden00@gmail.com>
Tue, 30 Nov 2021 17:03:33 +0000 (17:03 +0000)
committerhgn <hgodden00@gmail.com>
Tue, 30 Nov 2021 17:03:33 +0000 (17:03 +0000)
fishladder.c
vg/vg_console.h
vg/vg_ui.h

index 461731df105000130099fc37309ab36d9cb887b6..da57230e80267f4264bc9d238ba2a3101d080907 100644 (file)
@@ -463,6 +463,7 @@ static int map_load( const char *str, const char *name )
                        // Tile initialization
                        // row[ cx ] .. etc
                        struct cell *cell = &row[ cx ];
+                       cell->config = 0xF;
                        
                        if( *c == '+' || *c == '-' )
                        {
@@ -643,7 +644,18 @@ static void map_serialize( FILE *stream )
 
 int main( int argc, char *argv[] )
 {
-       vg_init( argc, argv, "Fish (Marbles Computer) Ladder Simulator 2022 | N,M: change level | SPACE: Test | LeftClick: Toggle tile" );
+       vg_init( argc, argv, "Marble Computing | SPACE: Test | LeftClick: Toggle tile | RightClick: Drag wire" );
+}
+
+static int console_credits( int argc, char const *argv[] )
+{
+       vg_info( "Aknowledgements:\n" );
+       vg_info( "  GLFW         zlib/libpng  glfw.org\n" );
+       vg_info( "  miniaudio    MIT0         miniaud.io\n" );
+       vg_info( "  QOI          MIT          phoboslab.org\n" );
+       vg_info( "  STB library  MIT          nothings.org\n" );
+       vg_info( "  Weiholmir font            justfredrik.itch.io\n" );
+       return 0;
 }
 
 static int console_save_map( int argc, char const *argv[] )
@@ -784,6 +796,11 @@ void vg_start(void)
                .name = "map",
                .function = console_changelevel
        });
+       
+       vg_function_push( (struct vg_cmd){
+               .name = "credits",
+               .function = console_credits
+       });
 
        // Quad mesh
        {
@@ -1052,7 +1069,7 @@ static void map_reclassify( v2i start, v2i end, int update_texbuffer )
                for( int x = px0; x < px1; x ++ )
                {
                        struct cell *cell = pcell((v2i){x,y});
-               
+
                        v2i dirs[] = {{1,0},{0,1},{-1,0},{0,-1}};
                        
                        u8 height = 0;
@@ -1084,6 +1101,30 @@ static void map_reclassify( v2i start, v2i end, int update_texbuffer )
                        info_px[1] = cell->state & FLAG_WALL? 0: 255;
                        info_px[2] = 0;
                        info_px[3] = 0;
+                       
+                       if( 
+                               (
+                                       ((cell->state & FLAG_IS_TRIGGER) && (cell->config == 0xF || cell->config == k_cell_type_split)) || 
+                                       ((cell->state & FLAG_TARGETED) && (cell->config != k_cell_type_split)) 
+                               ) && update_texbuffer
+                       ){
+                               cell->state &= ~(FLAG_TARGETED|FLAG_IS_TRIGGER);
+                               for( u32 i = 0; i < 2; i ++ )
+                               {
+                                       if( cell->links[i] )
+                                       {
+                                               struct cell *other_ptr = &world.data[ cell->links[i] ];
+                                               other_ptr->links[ i ] = 0;
+                                               other_ptr->state &= ~FLAG_IS_TRIGGER;
+                                               
+                                               if( other_ptr->links[ i ^ 0x1 ] == 0 )
+                                                       other_ptr->state &= ~FLAG_TARGETED;
+                                       }
+                               }
+                               
+                               cell->links[0] = 0;
+                               cell->links[1] = 0;
+                       }
                }
        }
        
@@ -1166,35 +1207,18 @@ void vg_update(void)
                                
                                if( cell_ptr->state & FLAG_CANAL )
                                {
+                                       cell_ptr->links[0] = 0;
+                                       cell_ptr->links[1] = 0;
+                                       
                                        sfx_set_playrnd( &audio_tile_mod, &audio_system_sfx, 3, 6 );
                                        world.score ++;
                                }
                                else
-                               {
-                                       if( cell_ptr->state & (FLAG_IS_TRIGGER|FLAG_TARGETED) )
-                                       {
-                                               cell_ptr->state &= ~(FLAG_IS_TRIGGER|FLAG_TARGETED);
-                                               for( u32 i = 0; i < 2; i ++ )
-                                               {
-                                                       if( cell_ptr->links[i] )
-                                                       {
-                                                               struct cell *other_ptr = &world.data[ cell_ptr->links[i] ];
-                                                               other_ptr->links[ i ] = 0;
-                                                               other_ptr->state &= ~FLAG_IS_TRIGGER;
-                                                               
-                                                               if( other_ptr->links[ i ^ 0x1 ] == 0 )
-                                                                       other_ptr->state &= ~(FLAG_TARGETED);
-                                                       }
-                                               }
-                                       }
-                                       
+                               {                                       
                                        sfx_set_playrnd( &audio_tile_mod, &audio_system_sfx, 0, 3 );
                                        world.score --;
                                }
 
-                               cell_ptr->links[0] = 0;
-                               cell_ptr->links[1] = 0;
-                                       
                                map_reclassify(         (v2i){ world.tile_x -2, world.tile_y -2 }, 
                                                                                (v2i){ world.tile_x +2, world.tile_y +2 }, 1 );
                        }
@@ -2107,6 +2131,8 @@ void vg_render(void)
        }
        
        // Level scores
+       glUniform4f( SHADER_UNIFORM( shader_tile_colour, "uColour" ), 0.4f*1.25f, 0.39f*1.25f, 0.45f*1.25f, 1.0f );
+       
        use_mesh( &world.numbers );
        for( int i = 0; i < level_count; i ++ )
        {
@@ -2119,9 +2145,11 @@ void vg_render(void)
                };
                
                if( clevel->completed )
-               {
                        draw_numbers( level_ui_space, clevel->score );
-               }
+                       
+               level_ui_space[0] = -0.975f;
+               level_ui_space[1] -= 0.01f;
+               draw_numbers( level_ui_space, i );
        }
        
        //use_mesh( &world.numbers );
@@ -2130,5 +2158,5 @@ void vg_render(void)
 
 void vg_ui(void)
 {
-       //ui_test();
+       ui_test();
 }
index 612e81552e1465d543decad078d54dcde617f48f..0e974f83b0223e2d87f257a0cd41b7357aa81467 100644 (file)
@@ -121,6 +121,25 @@ void vg_console_println( const char *str )
                vg_console.current = 0;
 }
 
+static int vg_console_list( int argc, char const *argv[] )
+{
+       for( int i = 0; i < arrlen( vg_console.functions ); i ++ )
+       {
+               struct vg_cmd *cmd = &vg_console.functions[ i ];
+               vg_info( "* %s\n", cmd->name );
+       }
+       
+       vg_info( "* snowsound\n" );
+       
+       for( int i = 0; i < arrlen( vg_console.convars ); i ++ )
+       {
+               struct vg_convar *cv = &vg_console.convars[ i ];
+               vg_info( "%s\n", cv->name );
+       }
+       
+       return 0;
+}
+
 static void vg_console_init(void)
 {
        vg_log_callback = vg_console_println;
@@ -128,6 +147,11 @@ static void vg_console_init(void)
        vg_convar_push( (struct vg_convar)
        { .name = "console_scale", .data = &vg_console.scale, .data_type = k_convar_dtype_i32, 
                .opt_i32 = { .clamp = 1, .min = 1, .max = 7 } } );
+       
+       vg_function_push( (struct vg_cmd){
+               .name = "list",
+               .function = vg_console_list
+       });
 }
 
 static void vg_console_free(void)
@@ -223,7 +247,7 @@ static void execute_console_input( const char *cmd )
                }
        }
        
-       vg_error( "No command/variable named '%s'\n", args[0] );
+       vg_error( "No command/variable named '%s'. Use 'list' to view all\n", args[0] );
 }
 
 // =============================================================================================================================
index da50e081c3b53c39aa59297297e1340fb8946299..bf9adc85549d761ecbd833c5df438aa1ad1c3b31 100644 (file)
@@ -684,6 +684,7 @@ static void ui_test(void)
                
        ui_set_mouse( &ui_global_ctx, vg_mouse[0], vg_mouse[1], mouse_state );
        
+       /*
        static struct ui_window window =
        {
                .transform = { 20, 20, 500, 350 },
@@ -727,13 +728,25 @@ static void ui_test(void)
                ui_end_right( &ui_global_ctx );
        }
        ui_end( &ui_global_ctx );
-
+       */
+       
+       ui_rect rbf;
+       ui_rect_copy( ui_global_ctx.cursor, rbf );
+       
+       ui_global_ctx.cursor[0] = 6;
+       ui_global_ctx.cursor[3] = 21;
+       ui_fill_x( &ui_global_ctx );
+       ui_align_bottom( &ui_global_ctx );
+       ui_text( &ui_global_ctx, "Marble computer build 2 -- development version -- (C) Harry Godden 2021\nAknowledgements: 'credits' in console (`)", 1, 0 );
+       
        ui_resolve( &ui_global_ctx );
        
        m3x3f view = M3X3_IDENTITY;
        m3x3_translate( view, (v3f){ -1.0f, 1.0f, 0.0f } );
        m3x3_scale( view, (v3f){ 1.0f/((float)vg_window_x*0.5f), -1.0f/((float)vg_window_y*0.5f), 1.0f } );
-       vg_lines_drawall( (float*)view );
+       //vg_lines_drawall( (float*)view );
        
        ui_draw( &ui_global_ctx );
+       
+       ui_rect_copy( rbf, ui_global_ctx.cursor );
 }