// Tile initialization
// row[ cx ] .. etc
struct cell *cell = &row[ cx ];
+ cell->config = 0xF;
if( *c == '+' || *c == '-' )
{
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[] )
.name = "map",
.function = console_changelevel
});
+
+ vg_function_push( (struct vg_cmd){
+ .name = "credits",
+ .function = console_credits
+ });
// Quad mesh
{
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;
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;
+ }
}
}
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 );
}
}
// 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 ++ )
{
};
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 );
void vg_ui(void)
{
- //ui_test();
+ ui_test();
}
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;
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)
}
}
- 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] );
}
// =============================================================================================================================
ui_set_mouse( &ui_global_ctx, vg_mouse[0], vg_mouse[1], mouse_state );
+ /*
static struct ui_window window =
{
.transform = { 20, 20, 500, 350 },
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 );
}