return &world.data[ pos[1]*world.w + pos[0] ];
}
+static void map_serialize( FILE *stream )
+{
+ for( int y = 0; y < world.h; y ++ )
+ {
+ for( int x = 0; x < world.w; x ++ )
+ {
+ struct cell *cell = pcell( (v2i){ x, y } );
+
+ if( cell->state & FLAG_WALL ) fputc( '#', stream );
+ else if( cell->state & FLAG_INPUT ) fputc( '+', stream );
+ else if( cell->state & FLAG_OUTPUT ) fputc( '-', stream );
+ else if( cell->state & FLAG_CANAL ) fputc( '*', stream );
+ else fputc( ' ', stream );
+ }
+
+ fputc( ';', stream );
+
+ int terminal_write_count = 0;
+
+ for( int x = 0; x < world.w; x ++ )
+ {
+ for( int i = 0; i < arrlen( world.io ); i ++ )
+ {
+ struct cell_terminal *term = &world.io[i];
+ if( term->id == y*world.w+x )
+ {
+ if( terminal_write_count )
+ fputc( ',', stream );
+ terminal_write_count ++;
+
+ for( int j = 0; j < arrlen( term->conditions ); j ++ )
+ fputc( term->conditions[j], stream );
+ }
+ }
+ }
+
+ fputc( '\n', 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" );
}
+static void console_save_map( int argc, char *argv[] )
+{
+ if( argc >= 1 )
+ {
+ FILE *test_writer = fopen( argv[0], "w" );
+ if( test_writer )
+ {
+ map_serialize( test_writer );
+
+ fclose( test_writer );
+ }
+ }
+}
+
void vg_start(void)
{
+ vg_function_push( (struct vg_cmd){
+ .name = "save_map",
+ .function = console_save_map
+ });
+
// Quad mesh
{
float quad_mesh[] =
v2f const curve_9[] = {{1.0f,0.5f},{0.625f,0.5f},{0.5f,0.375f},{0.5f,0.0f}};
v2f const curve_12[]= {{0.0f,0.5f},{0.375f,0.5f},{0.5f,0.375f},{0.5f,0.0f}};
+v2f const curve_2[] = {{0.5f,1.0f},{0.5f,0.8f},{0.5f,0.3f},{0.5f,0.2f}};
+v2f const curve_8[] = {{0.5f,0.8f},{0.5f,0.5f},{0.5f,0.3f},{0.5f,0.0f}};
+
v2f const curve_7[] = {{0.5f,0.8438f},{0.875f,0.8438f},{0.625f,0.5f},{1.0f,0.5f}};
v2f const curve_7_1[] = {{0.5f,0.8438f},{1.0f-0.875f,0.8438f},{1.0-0.625f,0.5f},{0.0f,0.5f}};
else
curve = curve_9;
break;
+ case 2: curve = curve_2; break;
+ case 8: curve = curve_8; break;
case 3: curve = curve_3; break;
case 6: curve = curve_6; break;
case 9: curve = curve_9; break;