bunch of stuff for pre-alpha build
[fishladder.git] / fishladder.c
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();
 }