// 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;
+ }
}
}
float const curve_7_linear_section = 0.1562f;
+u16 id_drag_from = 0;
+v2f drag_from_co;
+v2f drag_to_co;
+
void vg_update(void)
{
// Fit within screen
world.tile_x = floorf( world.tile_pos[0] );
world.tile_y = floorf( world.tile_pos[1] );
- static u16 id_drag_from = 0;
- static v2f drag_from_co;
- static v2f drag_to_co;
-
// Tilemap editing
if( !world.simulating )
{
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 );
}
else
world.selected = -1;
- if( vg_get_button("secondary") && id_drag_from )
- {
- vg_line2( drag_from_co, drag_to_co, 0xff00ff00, 0xffffff00 );
- }
- else
- {
+ if( !(vg_get_button("secondary") && id_drag_from) )
id_drag_from = 0;
- }
}
else
{
}
// Edit overlay
- if( world.selected != -1 && !(world.data[ world.selected ].state & FLAG_CANAL) )
+ if( world.selected != -1 && !(world.data[ world.selected ].state & FLAG_CANAL) && !id_drag_from )
{
v2i new_begin = { world.tile_x - 2, world.tile_y - 2 };
v2i new_end = { world.tile_x + 2, world.tile_y + 2 };
glUniformMatrix3fv( SHADER_UNIFORM( shader_wire, "uPv" ), 1, GL_FALSE, (float *)vg_pv );
glUniform4f( SHADER_UNIFORM( shader_wire, "uColour" ), 0.2f, 0.2f, 0.2f, 1.0f );
+ if( id_drag_from )
+ {
+ glUniform1f( SHADER_UNIFORM( shader_wire, "uCurve" ), 0.4f );
+ glUniform3f( SHADER_UNIFORM( shader_wire, "uStart" ), drag_from_co[0], drag_from_co[1], 0.06f );
+ glUniform3f( SHADER_UNIFORM( shader_wire, "uEnd" ), drag_to_co[0], drag_to_co[1], 0.06f );
+ glDrawElements( GL_TRIANGLES, world.wire.em, GL_UNSIGNED_SHORT, (void*)(0) );
+ }
+
float rp_x1 = world.frame_lerp*9.0f;
float rp_x2 = 1.0f-rp_x1*expf(1.0f-rp_x1)* 0.36f;
}
// 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();
}