1 // Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
5 #include "fishladder_resources.h"
7 const char *level_pack_1
[] = {
28 levels
[ vg_list_size( level_pack_1
) ];
30 career
= { .version
= 1 };
33 static void career_serialize(void)
35 vg_asset_write( "sav/game.sav", &career
, sizeof( struct career_state
) );
38 static void career_load(void)
41 struct career_state
*cr
= vg_asset_read_s( "sav/game.sav", &sz
);
43 memset( (void*)career
.levels
, 0, vg_list_size(level_pack_1
) * sizeof(struct career_level
) );
47 if( sz
> sizeof( struct career_state
) )
48 vg_warn( "This save file is too big! Some levels will be lost\n" );
50 if( sz
<= offsetof( struct career_state
, levels
) )
52 vg_error( "This save file is too small to have a header\n" );
57 u32
const size_header
= offsetof(struct career_state
, levels
);
58 u32
const size_levels
= sizeof(struct career_state
)-size_header
;
59 u32
const size_levels_input
= sz
- size_header
;
61 memcpy( (void*)career
.levels
, (void*)cr
->levels
, size_levels_input
);
63 if( sz
< sizeof( struct career_state
) )
65 memset( ((void*)career
.levels
) + size_levels_input
, 0, size_levels
-size_levels_input
);
69 vg_success( "Loaded save file... Info:\n" );
71 for( int i
= 0; i
< vg_list_size( career
.levels
); i
++ )
73 struct career_level
*lvl
= &career
.levels
[i
];
74 vg_info( "Score: %u, Time: %u, Completed: %u\n", lvl
->score
, lvl
->time
, lvl
->completed
);
79 vg_info( "No save file... Using blank one\n" );
87 #define FLAG_INPUT 0x1
88 #define FLAG_OUTPUT 0x2
89 #define FLAG_CANAL 0x4
91 #define FLAG_FLIP_FLOP 0x100
92 #define FLAG_FLIP_ROTATING 0x200
95 0000 0 | 0001 1 | 0010 2 | 0011 3
99 0100 4 | 0101 5 | 0110 6 | 0111 7
103 1000 8 | 1001 9 | 1010 10 | 1011 11
107 1100 12 | 1101 13 | 1110 14 | 1111 15
115 k_cell_type_ramp_right
= 3,
116 k_cell_type_ramp_left
= 6,
117 k_cell_type_split
= 7,
118 k_cell_type_merge
= 13
122 { { 0.9f
, 0.6f
, 0.20f
},
123 { 0.2f
, 0.9f
, 0.14f
},
124 { 0.4f
, 0.8f
, 1.00f
} };
126 static void colour_code_v3( char cc
, v3f target
)
128 if( cc
>= 'a' && cc
<= 'z' )
132 if( id
< vg_list_size( colour_sets
) )
134 v3_copy( colour_sets
[ id
], target
);
139 v3_copy( (v3f
){0.0f
,0.0f
,0.0f
}, target
);
148 static void init_mesh( struct mesh
*m
, float const *tris
, u32 length
)
150 m
->elements
= length
/3;
151 glGenVertexArrays( 1, &m
->vao
);
152 glGenBuffers( 1, &m
->vbo
);
154 glBindVertexArray( m
->vao
);
155 glBindBuffer( GL_ARRAY_BUFFER
, m
->vbo
);
156 glBufferData( GL_ARRAY_BUFFER
, length
*sizeof(float), tris
, GL_STATIC_DRAW
);
158 glVertexAttribPointer( 0, 2, GL_FLOAT
, GL_FALSE
, 2 * sizeof(float), (void*)0 );
159 glEnableVertexAttribArray( 0 );
164 static void free_mesh( struct mesh
*m
)
166 glDeleteVertexArrays( 1, &m
->vao
);
167 glDeleteBuffers( 1, &m
->vbo
);
170 static void draw_mesh( int const start
, int const count
)
172 glDrawArrays( GL_TRIANGLES
, start
*3, count
*3 );
175 static void use_mesh( struct mesh
*m
)
177 glBindVertexArray( m
->vao
);
208 int condition_count
, recv_count
;
220 struct mesh tile
, circle
, numbers
;
222 GLuint background_data
;
223 GLuint random_samples
;
225 int selected
, tile_x
, tile_y
;
243 struct career_level
*ptr_career_level
;
251 static void map_free(void)
253 arrfree( world
.data
);
265 static void map_reclassify( v2i start
, v2i end
, int update_texbuffer
);
266 static int map_load( const char *str
, const char *name
)
275 if( str
[world
.w
] == ';' )
277 else if( !str
[world
.w
] )
279 vg_error( "Unexpected EOF when parsing level\n" );
284 struct cell
*row
= arraddnptr( world
.data
, world
.w
);
286 int reg_start
= 0, reg_end
= 0;
302 if( reg_start
< reg_end
)
304 struct cell_terminal
*terminal
= &world
.io
[ reg_start
];
305 struct terminal_run
*run
= &terminal
->runs
[ terminal
->run_count
-1 ];
307 if( *c
>= 'a' && *c
<= 'z' )
309 run
->conditions
[ run
->condition_count
++ ] = *c
;
313 if( *c
== ',' || *c
== '\n' )
322 terminal
->runs
[ terminal
->run_count
].condition_count
= 0;
323 terminal
->run_count
++;
327 vg_error( "Unkown attribute '%c' (row: %u)\n", *c
, world
.h
);
334 vg_error( "Too many values to assign (row: %u)\n", world
.h
);
342 if( reg_start
!= reg_end
)
344 vg_error( "Not enough values assigned (row: %u, %u of %u)\n", world
.h
, reg_start
, reg_end
);
350 vg_error( "Not enough cells to match previous row definition (row: %u, %u<%u)\n", world
.h
, cx
, world
.w
);
354 row
= arraddnptr( world
.data
, world
.w
);
357 reg_end
= reg_start
= arrlen( world
.io
);
363 vg_error( "Too many cells to match previous row definition (row: %u, %u>%u)\n", world
.h
, cx
, world
.w
);
367 // Tile initialization
369 struct cell
*cell
= &row
[ cx
];
371 if( *c
== '+' || *c
== '-' )
373 struct cell_terminal
*term
= arraddnptr( world
.io
, 1 );
374 term
->id
= cx
+ world
.h
*world
.w
;
376 term
->runs
[0].condition_count
= 0;
378 cell
->state
= *c
== '+'? FLAG_INPUT
: FLAG_OUTPUT
;
381 else if( *c
== '#' ) cell
->state
= FLAG_WALL
;
382 else if( *c
== '*' ) { cell
->state
= FLAG_CANAL
; world
.score
++; }
383 else cell
->state
= 0x00;
391 // Update data texture to fill out the background
393 u8 info_buffer
[64*64*4];
394 for( int i
= 0; i
< 64*64; i
++ )
396 u8
*px
= &info_buffer
[i
*4];
403 glBindTexture( GL_TEXTURE_2D
, world
.background_data
);
404 glTexSubImage2D( GL_TEXTURE_2D
, 0, 0, 0, 64, 64, GL_RGBA
, GL_UNSIGNED_BYTE
, info_buffer
);
407 map_reclassify( NULL
, NULL
, 1 );
408 vg_success( "Map '%s' loaded! (%u:%u)\n", name
, world
.w
, world
.h
);
410 strncpy( world
.map_name
, name
, vg_list_size( world
.map_name
)-1 );
414 static struct cell
*pcell( v2i pos
)
416 return &world
.data
[ pos
[1]*world
.w
+ pos
[0] ];
419 static void map_serialize( FILE *stream
)
421 for( int y
= 0; y
< world
.h
; y
++ )
423 for( int x
= 0; x
< world
.w
; x
++ )
425 struct cell
*cell
= pcell( (v2i
){ x
, y
} );
427 if( cell
->state
& FLAG_WALL
) fputc( '#', stream
);
428 else if( cell
->state
& FLAG_INPUT
) fputc( '+', stream
);
429 else if( cell
->state
& FLAG_OUTPUT
) fputc( '-', stream
);
430 else if( cell
->state
& FLAG_CANAL
) fputc( '*', stream
);
431 else fputc( ' ', stream
);
434 fputc( ';', stream
);
436 int terminal_write_count
= 0;
438 for( int x
= 0; x
< world
.w
; x
++ )
440 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
442 struct cell_terminal
*term
= &world
.io
[i
];
443 if( term
->id
== y
*world
.w
+x
)
445 if( terminal_write_count
)
446 fputc( ',', stream
);
447 terminal_write_count
++;
449 for( int j
= 0; j
< term
->run_count
; j
++ )
451 struct terminal_run
*run
= &term
->runs
[j
];
453 for( int k
= 0; k
< run
->condition_count
; k
++ )
454 fputc( run
->conditions
[k
], stream
);
456 if( j
< term
->run_count
-1 )
457 fputc( ':', stream
);
463 fputc( '\n', stream
);
467 int main( int argc
, char *argv
[] )
469 vg_init( argc
, argv
, "Fish (Marbles Computer) Ladder Simulator 2022 | N,M: change level | SPACE: Test | LeftClick: Toggle tile" );
472 static int console_save_map( int argc
, char const *argv
[] )
474 char map_path
[ 256 ];
476 strcpy( map_path
, "sav/" );
477 strcat( map_path
, world
.map_name
);
478 strcat( map_path
, ".map" );
480 FILE *test_writer
= fopen( map_path
, "wb" );
483 map_serialize( test_writer
);
485 fclose( test_writer
);
490 vg_error( "Unable to open stream for writing\n" );
495 static int console_load_map( int argc
, char const *argv
[] )
497 char map_path
[ 256 ];
502 strcpy( map_path
, "sav/" );
503 strcat( map_path
, argv
[0] );
504 strcat( map_path
, ".map" );
506 char *text_source
= vg_textasset_read( map_path
);
510 strcpy( map_path
, "maps/" );
511 strcat( map_path
, argv
[0] );
512 strcat( map_path
, ".map" );
514 text_source
= vg_textasset_read( map_path
);
519 if( !map_load( text_source
, argv
[0] ) )
524 // Update career link
525 world
.ptr_career_level
= NULL
;
527 for( int i
= 0; i
< vg_list_size( level_pack_1
); i
++ )
529 if( !strcmp( level_pack_1
[i
], argv
[0] ) )
531 world
.ptr_career_level
= career
.levels
+ i
;
540 vg_error( "Missing maps '%s'\n", argv
[0] );
546 vg_error( "Missing argument <map_path>\n" );
551 static void io_reset(void)
553 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
555 struct cell_terminal
*term
= &world
.io
[i
];
557 for( int j
= 0; j
< term
->run_count
; j
++ )
558 term
->runs
[j
].recv_count
= 0;
562 static void simulation_stop(void)
564 world
.simulating
= 0;
565 world
.num_fishes
= 0;
570 sfx_system_fadeout( &audio_system_balls_rolling
, 44100 );
572 vg_info( "Stopping simulation!\n" );
575 static int console_changelevel( int argc
, char const *argv
[] )
579 // Save current level
580 if( console_save_map( 0, NULL
) )
581 if( console_load_map( argc
, argv
) )
589 vg_error( "Missing argument <map_path>\n" );
597 vg_function_push( (struct vg_cmd
){
599 .function
= console_save_map
602 vg_function_push( (struct vg_cmd
){
604 .function
= console_load_map
607 vg_function_push( (struct vg_cmd
){
608 .name
= "changelevel",
609 .function
= console_changelevel
616 0.0f
, 0.0f
, 0.0f
, 1.0f
, 1.0f
, 1.0f
,
617 0.0f
, 0.0f
, 1.0f
, 1.0f
, 1.0f
, 0.0f
,
619 0.0f
, 0.0f
, 0.0f
, 1.0f
, 4.0f
, 1.0f
,
620 0.0f
, 0.0f
, 4.0f
, 1.0f
, 4.0f
, 0.0f
623 init_mesh( &world
.tile
, quad_mesh
, vg_list_size(quad_mesh
) );
628 float circle_mesh
[32*6*3];
629 int res
= vg_list_size( circle_mesh
) / (6*3);
631 for( int i
= 0; i
< res
; i
++ )
633 v2f v0
= { sinf( ((float)i
/(float)res
)*VG_TAUf
), cosf( ((float)i
/(float)res
)*VG_TAUf
) };
634 v2f v1
= { sinf( ((float)(i
+1)/(float)res
)*VG_TAUf
), cosf( ((float)(i
+1)/(float)res
)*VG_TAUf
) };
636 circle_mesh
[ i
*6+0 ] = 0.0f
;
637 circle_mesh
[ i
*6+1 ] = 0.0f
;
639 v2_copy( v0
, circle_mesh
+ 32*6 + i
*12 );
640 v2_muls( v0
, 0.8f
, circle_mesh
+ 32*6 + i
*12+2 );
641 v2_copy( v1
, circle_mesh
+ 32*6 + i
*12+4 );
643 v2_copy( v1
, circle_mesh
+ 32*6 + i
*12+6 );
644 v2_muls( v1
, 0.8f
, circle_mesh
+ 32*6 + i
*12+8 );
645 v2_muls( v0
, 0.8f
, circle_mesh
+ 32*6 + i
*12+10 );
647 v2_copy( v0
, circle_mesh
+ i
*6+4 );
648 v2_copy( v1
, circle_mesh
+ i
*6+2 );
649 v2_copy( v0
, circle_mesh
+i
*6+4 );
650 v2_copy( v1
, circle_mesh
+i
*6+2 );
653 init_mesh( &world
.circle
, circle_mesh
, vg_list_size( circle_mesh
) );
658 init_mesh( &world
.numbers
,
660 vg_list_size( MESH_NUMBERS_BUFFER
)
663 for( int i
= 0; i
< 10; i
++ )
665 vg_info( "offset: %u, length: %u\n", MESH_NUMBERS_OFFSETS
[i
][0], MESH_NUMBERS_OFFSETS
[i
][1] );
669 // Create info data texture
671 glGenTextures( 1, &world
.background_data
);
672 glBindTexture( GL_TEXTURE_2D
, world
.background_data
);
673 glTexImage2D( GL_TEXTURE_2D
, 0, GL_RGBA
, 64, 64, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, NULL
);
677 // Create random smaples texture
679 u8
*data
= malloc(512*512*2);
680 for( int i
= 0; i
< 512*512*2; i
++ )
681 data
[ i
] = rand()/(RAND_MAX
/255);
683 glGenTextures( 1, &world
.random_samples
);
684 glBindTexture( GL_TEXTURE_2D
, world
.random_samples
);
685 glTexImage2D( GL_TEXTURE_2D
, 0, GL_RG
, 512, 512, 0, GL_RG
, GL_UNSIGNED_BYTE
, data
);
692 resource_load_main();
696 console_load_map( 1, level_pack_1
);
701 console_save_map( 0, NULL
);
704 resource_free_main();
706 glDeleteTextures( 1, &world
.background_data
);
707 glDeleteTextures( 1, &world
.random_samples
);
709 free_mesh( &world
.tile
);
710 free_mesh( &world
.circle
);
711 free_mesh( &world
.numbers
);
716 static int cell_interactive( v2i co
)
719 if( co
[0] < 2 || co
[0] >= world
.w
-2 || co
[1] < 2 || co
[1] >= world
.h
-2 )
723 if( world
.data
[ world
.w
*co
[1] + co
[0] ].state
& (FLAG_WALL
|FLAG_INPUT
|FLAG_OUTPUT
) )
726 // List of 3x3 configurations that we do not allow
727 static u32 invalid_src
[][9] =
759 // Statically compile invalid configurations into bitmasks
760 static u32 invalid
[ vg_list_size(invalid_src
) ];
762 for( int i
= 0; i
< vg_list_size(invalid_src
); i
++ )
766 for( int j
= 0; j
< 3; j
++ )
767 for( int k
= 0; k
< 3; k
++ )
768 comped
|= invalid_src
[i
][ j
*3+k
] << ((j
*5)+k
);
773 // Extract 5x5 grid surrounding tile
775 for( int y
= co
[1]-2; y
< co
[1]+3; y
++ )
776 for( int x
= co
[0]-2; x
< co
[0]+3; x
++ )
778 struct cell
*cell
= pcell((v2i
){x
,y
});
780 if( cell
&& (cell
->state
& (FLAG_CANAL
|FLAG_INPUT
|FLAG_OUTPUT
)) )
781 blob
|= 0x1 << ((y
-(co
[1]-2))*5 + x
-(co
[0]-2));
784 // Run filter over center 3x3 grid to check for invalid configurations
785 int kernel
[] = { 0, 1, 2, 5, 6, 7, 10, 11, 12 };
786 for( int i
= 0; i
< vg_list_size(kernel
); i
++ )
788 if( blob
& (0x1 << (6+kernel
[i
])) )
790 u32 window
= blob
>> kernel
[i
];
792 for( int j
= 0; j
< vg_list_size(invalid
); j
++ )
793 if((window
& invalid
[j
]) == invalid
[j
])
801 static void map_reclassify( v2i start
, v2i end
, int update_texbuffer
)
803 v2i full_start
= { 1,1 };
804 v2i full_end
= { world
.w
-1, world
.h
-1 };
813 u8 info_buffer
[64*64*4];
816 int px0
= vg_max( start
[0], full_start
[0] ),
817 px1
= vg_min( end
[0], full_end
[0] ),
818 py0
= vg_max( start
[1], full_start
[1] ),
819 py1
= vg_min( end
[1], full_end
[1] );
821 for( int y
= py0
; y
< py1
; y
++ )
823 for( int x
= px0
; x
< px1
; x
++ )
825 struct cell
*cell
= pcell((v2i
){x
,y
});
827 v2i dirs
[] = {{1,0},{0,1},{-1,0},{0,-1}};
832 if( cell
->state
& (FLAG_CANAL
|FLAG_INPUT
|FLAG_OUTPUT
) )
834 for( int i
= 0; i
< vg_list_size( dirs
); i
++ )
836 struct cell
*neighbour
= pcell((v2i
){x
+dirs
[i
][0], y
+dirs
[i
][1]});
837 if( neighbour
->state
& (FLAG_CANAL
|FLAG_INPUT
|FLAG_OUTPUT
) )
845 if( cell
->state
& FLAG_WALL
)
851 pcell((v2i
){x
,y
})->config
= config
;
853 u8
*info_px
= &info_buffer
[ (pixel_id
++)*4 ];
855 info_px
[1] = cell
->state
& FLAG_WALL
? 0: 255;
861 if( update_texbuffer
)
863 glBindTexture( GL_TEXTURE_2D
, world
.background_data
);
864 glTexSubImage2D( GL_TEXTURE_2D
, 0, px0
+ 16, py0
+ 16, px1
-px0
, py1
-py0
, GL_RGBA
, GL_UNSIGNED_BYTE
, info_buffer
);
868 v2f
const curve_3
[] = {{0.5f
,1.0f
},{0.5f
,0.625f
},{0.625f
,0.5f
},{1.0f
,0.5f
}};
869 v2f
const curve_6
[] = {{0.5f
,1.0f
},{0.5f
,0.625f
},{0.375f
,0.5f
},{0.0f
,0.5f
}};
870 v2f
const curve_9
[] = {{1.0f
,0.5f
},{0.625f
,0.5f
},{0.5f
,0.375f
},{0.5f
,0.0f
}};
871 v2f
const curve_12
[]= {{0.0f
,0.5f
},{0.375f
,0.5f
},{0.5f
,0.375f
},{0.5f
,0.0f
}};
873 v2f
const curve_2
[] = {{0.5f
,1.0f
},{0.5f
,0.8f
},{0.5f
,0.3f
},{0.5f
,0.2f
}};
874 v2f
const curve_8
[] = {{0.5f
,0.8f
},{0.5f
,0.5f
},{0.5f
,0.3f
},{0.5f
,0.0f
}};
876 v2f
const curve_7
[] = {{0.5f
,0.8438f
},{0.875f
,0.8438f
},{0.625f
,0.5f
},{1.0f
,0.5f
}};
877 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
}};
879 float const curve_7_linear_section
= 0.1562f
;
885 float r1
= (float)vg_window_y
/ (float)vg_window_x
,
886 r2
= (float)world
.h
/ (float)world
.w
,
889 size
= ( r2
< r1
? (float)world
.w
* 0.5f
: ((float)world
.h
* 0.5f
) / r1
) + 2.5f
;
890 m3x3_projection( m_projection
, -size
, size
, -size
*r1
, size
*r1
);
893 origin
[0] = floorf( -0.5f
* world
.w
);
894 origin
[1] = floorf( -0.5f
* world
.h
);
897 m3x3_identity( m_view
);
898 m3x3_translate( m_view
, origin
);
899 m3x3_mul( m_projection
, m_view
, vg_pv
);
900 vg_projection_update();
903 v2_copy( vg_mouse_ws
, world
.tile_pos
);
905 world
.tile_x
= floorf( world
.tile_pos
[0] );
906 world
.tile_y
= floorf( world
.tile_pos
[1] );
909 if( !world
.simulating
)
911 if( cell_interactive( (v2i
){ world
.tile_x
, world
.tile_y
} ))
913 world
.selected
= world
.tile_y
* world
.w
+ world
.tile_x
;
915 static u32 modify_state
= 0;
917 struct cell
*cell_ptr
= &world
.data
[world
.selected
];
919 if( vg_get_button_down("primary") )
921 modify_state
= (cell_ptr
->state
& FLAG_CANAL
) ^ FLAG_CANAL
;
924 if( vg_get_button("primary") && ((cell_ptr
->state
& FLAG_CANAL
) != modify_state
) )
926 cell_ptr
->state
&= ~FLAG_CANAL
;
927 cell_ptr
->state
|= modify_state
;
929 if( cell_ptr
->state
& FLAG_CANAL
)
931 sfx_set_playrnd( &audio_tile_mod
, &audio_system_sfx
, 3, 6 );
936 sfx_set_playrnd( &audio_tile_mod
, &audio_system_sfx
, 0, 3 );
940 map_reclassify( (v2i
){ world
.tile_x
-2, world
.tile_y
-2 },
941 (v2i
){ world
.tile_x
+2, world
.tile_y
+2 }, 1 );
947 else world
.selected
= -1;
949 // Simulation stop/start
950 if( vg_get_button_down("go") )
952 if( world
.simulating
)
958 vg_success( "Starting simulation!\n" );
960 sfx_set_playrnd( &audio_rolls
, &audio_system_balls_rolling
, 0, 1 );
962 world
.simulating
= 1;
963 world
.num_fishes
= 0;
965 world
.sim_start
= vg_time
;
967 for( int i
= 0; i
< world
.w
*world
.h
; i
++ )
968 world
.data
[ i
].state
&= ~FLAG_FLIP_FLOP
;
975 if( world
.simulating
)
977 while( world
.sim_frame
< (int)((vg_time
-world
.sim_start
)*2.0f
) )
979 //vg_info( "frame: %u\n", world.sim_frame );
980 sfx_set_playrnd( &audio_random
, &audio_system_balls_switching
, 0, 9 );
982 // Update splitter deltas
983 for( int i
= 0; i
< world
.h
*world
.w
; i
++ )
985 struct cell
*cell
= &world
.data
[i
];
986 if( cell
->config
== k_cell_type_split
)
988 cell
->state
&= ~FLAG_FLIP_ROTATING
;
994 // Update fish positions
995 for( int i
= 0; i
< world
.num_fishes
; i
++ )
997 struct fish
*fish
= &world
.fishes
[i
];
998 struct cell
*cell_current
= pcell( fish
->pos
);
1000 if( fish
->alive
== -1 )
1003 if( fish
->alive
!= 1 )
1007 if( cell_current
->state
& FLAG_OUTPUT
)
1009 for( int j
= 0; j
< arrlen( world
.io
); j
++ )
1011 struct cell_terminal
*term
= &world
.io
[j
];
1013 if( term
->id
== fish
->pos
[1]*world
.w
+ fish
->pos
[0] )
1015 struct terminal_run
*run
= &term
->runs
[ world
.sim_run
];
1016 if( run
->recv_count
< vg_list_size( run
->recieved
) )
1017 run
->recieved
[ run
->recv_count
++ ] = fish
->payload
;
1027 if( cell_current
->config
== k_cell_type_split
)
1030 fish
->dir
[0] = cell_current
->state
&FLAG_FLIP_FLOP
?1:-1;
1033 cell_current
->state
^= FLAG_FLIP_FLOP
;
1035 else if( cell_current
->config
== k_cell_type_merge
)
1043 struct cell
*cell_next
= pcell( (v2i
){ fish
->pos
[0]+fish
->dir
[0], fish
->pos
[1]+fish
->dir
[1] } );
1044 if( !(cell_next
->state
& (FLAG_CANAL
|FLAG_OUTPUT
)) )
1046 // Try other directions for valid, so down, left, right..
1047 v2i dirs
[] = {{1,0},{-1,0},{0,-1}};
1048 vg_info( "Trying some other directions...\n" );
1050 for( int j
= 0; j
< vg_list_size(dirs
); j
++ )
1052 if( (dirs
[j
][0] == -fish
->dir
[0]) && (dirs
[j
][1] == -fish
->dir
[1]) )
1055 if( pcell( (v2i
){ fish
->pos
[0]+dirs
[j
][0], fish
->pos
[1]+dirs
[j
][1] } )->state
& (FLAG_CANAL
|FLAG_OUTPUT
) )
1057 fish
->dir
[0] = dirs
[j
][0];
1058 fish
->dir
[1] = dirs
[j
][1];
1064 fish
->pos
[0] += fish
->dir
[0];
1065 fish
->pos
[1] += fish
->dir
[1];
1067 struct cell
*cell_entry
= pcell( fish
->pos
);
1069 if( !(cell_entry
->state
& (FLAG_INPUT
|FLAG_CANAL
|FLAG_OUTPUT
) ))
1075 if( cell_entry
->config
== k_cell_type_split
||
1076 cell_entry
->config
== k_cell_type_ramp_right
||
1077 cell_entry
->config
== k_cell_type_ramp_left
)
1079 // Special death (FALL)
1080 v2_sub( fish
->physics_co
, fish
->physics_v
, fish
->physics_v
);
1081 v2_divs( fish
->physics_v
, vg_time_delta
, fish
->physics_v
);
1084 vg_warn( "Special death (fall)\n" );
1089 if( cell_entry
->config
== k_cell_type_split
)
1091 sfx_set_playrnd( &audio_splitter
, &audio_system_balls_important
, 0, 1 );
1092 cell_entry
->state
|= FLAG_FLIP_ROTATING
;
1100 // Check for collisions
1101 for( int i
= 0; i
< world
.num_fishes
; i
++ )
1103 if( world
.fishes
[i
].alive
== 1 )
1105 for( int j
= i
+1; j
< world
.num_fishes
; j
++ )
1107 if( (world
.fishes
[j
].alive
== 1) && (world
.fishes
[i
].pos
[0] == world
.fishes
[j
].pos
[0]) &&
1108 (world
.fishes
[i
].pos
[1] == world
.fishes
[j
].pos
[1]) )
1110 // Shatter death (+0.5s)
1111 world
.fishes
[i
].alive
= -1;
1112 world
.fishes
[j
].alive
= -1;
1113 world
.fishes
[i
].death_time
= 0.5f
;
1114 world
.fishes
[j
].death_time
= 0.5f
;
1121 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
1123 struct cell_terminal
*term
= &world
.io
[ i
];
1124 int posx
= term
->id
% world
.w
;
1125 int posy
= (term
->id
- posx
)/world
.w
;
1126 int is_input
= world
.data
[ term
->id
].state
& FLAG_INPUT
;
1130 if( world
.sim_frame
< term
->runs
[ world
.sim_run
].condition_count
)
1132 struct fish
*fish
= &world
.fishes
[world
.num_fishes
++];
1133 fish
->pos
[0] = posx
;
1134 fish
->pos
[1] = posy
;
1136 fish
->payload
= term
->runs
[ world
.sim_run
].conditions
[ world
.sim_frame
];
1140 v2i dirs
[] = {{1,0},{-1,0},{0,-1}};
1141 for( int j
= 0; j
< vg_list_size(dirs
); j
++ )
1142 if( pcell( (v2i
){ posx
+dirs
[j
][0], posy
+dirs
[j
][1] } )->state
& FLAG_CANAL
)
1144 fish
->dir
[0] = dirs
[j
][0];
1145 fish
->dir
[1] = dirs
[j
][1];
1158 if( alive_count
== 0 )
1160 world
.completed
= 1;
1162 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
1164 struct cell_terminal
*term
= &world
.io
[ i
];
1165 int is_input
= world
.data
[ term
->id
].state
& FLAG_INPUT
;
1169 struct terminal_run
*run
= &term
->runs
[ world
.sim_run
];
1171 if( run
->recv_count
== run
->condition_count
)
1173 for( int j
= 0; j
< run
->condition_count
; j
++ )
1175 if( run
->recieved
[j
] != run
->conditions
[j
] )
1177 world
.completed
= 0;
1184 world
.completed
= 0;
1190 if( world
.completed
)
1192 vg_success( "Level passed!\n" );
1195 for( int i
= 0; i
< world
.w
*world
.h
; i
++ )
1196 if( world
.data
[ i
].state
& FLAG_CANAL
)
1199 world
.score
= score
;
1200 world
.time
= world
.sim_frame
;
1204 vg_error( "Level failed :(\n" );
1207 // Copy into career data
1208 if( world
.ptr_career_level
)
1210 world
.ptr_career_level
->score
= world
.score
;
1211 world
.ptr_career_level
->time
= world
.time
;
1212 world
.ptr_career_level
->completed
= world
.completed
;
1215 simulation_stop(); // TODO: Async?
1222 float scaled_time
= 0.0f
;
1223 scaled_time
= (vg_time
-world
.sim_start
)*2.0f
;
1224 world
.frame_lerp
= scaled_time
- (float)world
.sim_frame
;
1227 for( int i
= 0; i
< world
.num_fishes
; i
++ )
1229 struct fish
*fish
= &world
.fishes
[i
];
1231 if( fish
->alive
== 0 )
1234 if( fish
->alive
== -1 && (world
.frame_lerp
> fish
->death_time
) )
1235 continue; // Todo: particle thing?
1237 if( fish
->alive
== -2 )
1239 v2_muladds( fish
->physics_v
, (v2f
){ 0.0, -9.8f
}, vg_time_delta
, fish
->physics_v
);
1240 v2_muladds( fish
->physics_co
, fish
->physics_v
, vg_time_delta
, fish
->physics_co
);
1244 struct cell
*cell
= pcell(fish
->pos
);
1247 float t
= world
.frame_lerp
;
1249 v2_copy( fish
->physics_co
, fish
->physics_v
);
1251 switch( cell
->config
)
1254 if( fish
->dir
[0] == 1 )
1259 case 2: curve
= curve_2
; break;
1260 case 8: curve
= curve_8
; break;
1261 case 3: curve
= curve_3
; break;
1262 case 6: curve
= curve_6
; break;
1263 case 9: curve
= curve_9
; break;
1264 case 12: curve
= curve_12
; break;
1266 if( t
> curve_7_linear_section
)
1268 t
-= curve_7_linear_section
;
1269 t
*= (1.0f
/(1.0f
-curve_7_linear_section
));
1271 curve
= cell
->state
& FLAG_FLIP_FLOP
? curve_7
: curve_7_1
;
1275 default: curve
= NULL
; break;
1281 float t3
= t
* t
* t
;
1283 float cA
= 3.0f
*t2
- 3.0f
*t3
;
1284 float cB
= 3.0f
*t3
- 6.0f
*t2
+ 3.0f
*t
;
1285 float cC
= 3.0f
*t2
- t3
- 3.0f
*t
+ 1.0f
;
1287 fish
->physics_co
[0] = t3
*curve
[3][0] + cA
*curve
[2][0] + cB
*curve
[1][0] + cC
*curve
[0][0];
1288 fish
->physics_co
[1] = t3
*curve
[3][1] + cA
*curve
[2][1] + cB
*curve
[1][1] + cC
*curve
[0][1];
1289 fish
->physics_co
[0] += (float)fish
->pos
[0];
1290 fish
->physics_co
[1] += (float)fish
->pos
[1];
1295 origin
[0] = (float)fish
->pos
[0] + (float)fish
->dir
[0]*-0.5f
+ 0.5f
;
1296 origin
[1] = (float)fish
->pos
[1] + (float)fish
->dir
[1]*-0.5f
+ 0.5f
;
1298 fish
->physics_co
[0] = origin
[0] + (float)fish
->dir
[0]*t
;
1299 fish
->physics_co
[1] = origin
[1] + (float)fish
->dir
[1]*t
;
1306 static void render_tiles( v2i start
, v2i end
, v4f
const regular_colour
, v4f
const selected_colour
)
1308 v2i full_start
= { 0,0 };
1309 v2i full_end
= { world
.w
, world
.h
};
1311 if( !start
|| !end
)
1317 glUniform4fv( SHADER_UNIFORM( shader_tile_main
, "uColour" ), 1, regular_colour
);
1319 for( int y
= start
[1]; y
< end
[1]; y
++ )
1321 for( int x
= start
[0]; x
< end
[0]; x
++ )
1323 struct cell
*cell
= pcell((v2i
){x
,y
});
1324 int selected
= world
.selected
== y
*world
.w
+ x
;
1326 int tile_offsets
[][2] =
1328 {2, 0}, {0, 3}, {0, 2}, {2, 2},
1329 {1, 0}, {2, 3}, {3, 2}, {1, 3},
1330 {3, 1}, {0, 1}, {1, 2}, {2, 1},
1331 {1, 1}, {3, 3}, {2, 1}, {2, 1}
1334 int uv
[2] = { 3, 0 };
1336 if( cell
->state
& (FLAG_CANAL
|FLAG_INPUT
|FLAG_OUTPUT
) )
1338 uv
[0] = tile_offsets
[ cell
->config
][0];
1339 uv
[1] = tile_offsets
[ cell
->config
][1];
1342 glUniform4f( SHADER_UNIFORM( shader_tile_main
, "uOffset" ), (float)x
, (float)y
, uv
[0], uv
[1] );
1345 glUniform4fv( SHADER_UNIFORM( shader_tile_main
, "uColour" ), 1, selected_colour
);
1347 glUniform4fv( SHADER_UNIFORM( shader_tile_main
, "uColour" ), 1, regular_colour
);
1355 static void draw_numbers( v3f coord
, int number
)
1358 v3_copy( coord
, pos
);
1359 int digits
[8]; int i
= 0;
1361 while( number
> 0 && i
< 8 )
1363 digits
[i
++] = number
% 10;
1364 number
= number
/ 10;
1367 for( int j
= 0; j
< i
; j
++ )
1369 glUniform3fv( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), 1, pos
);
1370 draw_mesh( MESH_NUMBERS_OFFSETS
[digits
[i
-j
-1]][0], MESH_NUMBERS_OFFSETS
[digits
[i
-j
-1]][1] );
1371 pos
[0] += pos
[2] * 0.75f
;
1375 void vg_render(void)
1377 glViewport( 0,0, vg_window_x
, vg_window_y
);
1379 glDisable( GL_DEPTH_TEST
);
1380 glClearColor( 0.369768f
, 0.3654f
, 0.42f
, 1.0f
);
1381 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
1383 v4f
const colour_default
= {1.0f
, 1.0f
, 1.0f
, 1.0f
};
1384 v4f
const colour_selected
= {0.90f
, 0.92f
, 1.0f
, 1.0f
};
1386 // TILE SET RENDERING
1387 // todo: just slam everything into a mesh...
1388 // when user modifies a tile the neighbours can be easily uploaded to gpu mem
1390 // Currently we're uploading a fair amount of data every frame anyway.
1391 // NOTE: this is for final optimisations ONLY!
1392 // ======================================================================
1394 use_mesh( &world
.tile
);
1400 SHADER_USE( shader_background
);
1401 glUniformMatrix3fv( SHADER_UNIFORM( shader_background
, "uPv" ), 1, GL_FALSE
, (float *)vg_pv
);
1403 glActiveTexture( GL_TEXTURE0
);
1404 glBindTexture( GL_TEXTURE_2D
, world
.background_data
);
1405 glUniform1i( SHADER_UNIFORM( shader_background
, "uTexMain" ), 0 );
1407 glUniform3f( SHADER_UNIFORM( shader_background
, "uOffset" ), -16, -16, 64 );
1408 glUniform1f( SHADER_UNIFORM( shader_background
, "uVariance" ), 0.02f
);
1410 glActiveTexture( GL_TEXTURE1
);
1411 glBindTexture( GL_TEXTURE_2D
, world
.random_samples
);
1412 glUniform1i( SHADER_UNIFORM( shader_background
, "uSamplerNoise" ), 1 );
1419 SHADER_USE( shader_tile_main
);
1422 m2x2_identity( subtransform
);
1423 glUniformMatrix2fv( SHADER_UNIFORM( shader_tile_main
, "uSubTransform" ), 1, GL_FALSE
, (float *)subtransform
);
1424 glUniformMatrix3fv( SHADER_UNIFORM( shader_tile_main
, "uPv" ), 1, GL_FALSE
, (float *)vg_pv
);
1425 glUniform1f( SHADER_UNIFORM( shader_tile_main
, "uGhost" ), 0.0f
);
1426 glUniform1f( SHADER_UNIFORM( shader_tile_main
, "uForeground" ), 0.0f
);
1429 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1430 glBlendEquation(GL_FUNC_ADD
);
1433 vg_tex2d_bind( &tex_tile_data
, 0 );
1434 glUniform1i( SHADER_UNIFORM( shader_tile_main
, "uTexGlyphs" ), 0 );
1436 vg_tex2d_bind( &tex_wood
, 1 );
1437 glUniform1i( SHADER_UNIFORM( shader_tile_main
, "uTexWood" ), 1 );
1439 render_tiles( NULL
, NULL
, colour_default
, colour_default
);
1443 SHADER_USE( shader_ball
);
1444 glUniformMatrix3fv( SHADER_UNIFORM( shader_ball
, "uPv" ), 1, GL_FALSE
, (float *)vg_pv
);
1446 vg_tex2d_bind( &tex_ball
, 0 );
1447 glUniform1i( SHADER_UNIFORM( shader_ball
, "uTexMain" ), 0 );
1450 if( world
.simulating
)
1452 for( int i
= 0; i
< world
.num_fishes
; i
++ )
1454 struct fish
*fish
= &world
.fishes
[i
];
1456 if( fish
->alive
== 0 )
1459 if( fish
->alive
== -1 && (world
.frame_lerp
> fish
->death_time
) )
1462 v4f dot_colour
= { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
1463 colour_code_v3( fish
->payload
, dot_colour
);
1465 glUniform3fv( SHADER_UNIFORM( shader_ball
, "uColour" ), 1, dot_colour
);
1466 glUniform2fv( SHADER_UNIFORM( shader_ball
, "uOffset" ), 1, fish
->physics_co
);
1471 SHADER_USE( shader_tile_main
);
1474 vg_tex2d_bind( &tex_tile_data
, 0 );
1475 glUniform1i( SHADER_UNIFORM( shader_tile_main
, "uTexGlyphs" ), 0 );
1477 vg_tex2d_bind( &tex_wood
, 1 );
1478 glUniform1i( SHADER_UNIFORM( shader_tile_main
, "uTexWood" ), 1 );
1480 glUniform1f( SHADER_UNIFORM( shader_tile_main
, "uForeground" ), 1.0f
);
1481 render_tiles( NULL
, NULL
, colour_default
, colour_selected
);
1484 for( int y
= 2; y
< world
.h
-2; y
++ )
1486 for( int x
= 2; x
< world
.w
-2; x
++ )
1488 struct cell
*cell
= pcell((v2i
){x
,y
});
1490 if( cell
->config
== k_cell_type_split
)
1492 float rotation
= cell
->state
& FLAG_FLIP_FLOP
? vg_rad( -45.0f
): vg_rad( 45.0f
);
1494 if( cell
->state
& FLAG_FLIP_ROTATING
)
1496 if( (world
.frame_lerp
> curve_7_linear_section
) )
1498 float const rotation_speed
= 0.4f
;
1499 if( (world
.frame_lerp
< 1.0f
-rotation_speed
) )
1501 float t
= world
.frame_lerp
- curve_7_linear_section
;
1502 t
*= -2.0f
* (1.0f
/(1.0f
-(curve_7_linear_section
+rotation_speed
)));
1512 m2x2_create_rotation( subtransform
, rotation
);
1514 glUniformMatrix2fv( SHADER_UNIFORM( shader_tile_main
, "uSubTransform" ), 1, GL_FALSE
, (float *)subtransform
);
1515 glUniform4f( SHADER_UNIFORM( shader_tile_main
, "uOffset" ), (float)x
, (float)y
+ 0.125f
, 0.0f
, 0.0f
);
1522 if( world
.selected
!= -1 && !(world
.data
[ world
.selected
].state
& FLAG_CANAL
) )
1524 v2i new_begin
= { world
.tile_x
- 2, world
.tile_y
- 2 };
1525 v2i new_end
= { world
.tile_x
+ 2, world
.tile_y
+ 2 };
1527 world
.data
[ world
.selected
].state
^= FLAG_CANAL
;
1528 map_reclassify( new_begin
, new_end
, 0 );
1530 m2x2_identity( subtransform
);
1531 glUniform1f( SHADER_UNIFORM( shader_tile_main
, "uGhost" ), 1.0f
);
1532 glUniformMatrix2fv( SHADER_UNIFORM( shader_tile_main
, "uSubTransform" ), 1, GL_FALSE
, (float *)subtransform
);
1533 glUniform2fv( SHADER_UNIFORM( shader_tile_main
, "uMousePos" ), 1, world
.tile_pos
);
1535 render_tiles( new_begin
, new_end
, colour_default
, colour_default
);
1537 world
.data
[ world
.selected
].state
^= FLAG_CANAL
;
1538 map_reclassify( new_begin
, new_end
, 0 );
1541 //glDisable(GL_BLEND);
1543 glDisable(GL_BLEND
);
1545 SHADER_USE( shader_tile_colour
);
1546 glUniformMatrix3fv( SHADER_UNIFORM( shader_tile_colour
, "uPv" ), 1, GL_FALSE
, (float *)vg_pv
);
1547 use_mesh( &world
.circle
);
1549 int const filled_start
= 0;
1550 int const filled_count
= 32;
1551 int const empty_start
= 32;
1552 int const empty_count
= 32*2;
1555 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
1557 struct cell_terminal
*term
= &world
.io
[ i
];
1558 int posx
= term
->id
% world
.w
;
1559 int posy
= (term
->id
- posx
)/world
.w
;
1560 int is_input
= world
.data
[ term
->id
].state
& FLAG_INPUT
;
1562 v4f dot_colour
= { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
1564 // TODO: Iterate runs
1565 for( int j
= 0; j
< term
->runs
[0].condition_count
; j
++ )
1567 float y_offset
= is_input
? 1.2f
: -0.2f
;
1568 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), (float)posx
+ 0.2f
+ 0.2f
* (float)j
, (float)posy
+ y_offset
, 0.1f
);
1572 colour_code_v3( term
->runs
[0].conditions
[j
], dot_colour
);
1573 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, dot_colour
);
1575 // Draw filled if tick not passed, draw empty if empty
1576 if( world
.sim_frame
> j
)
1577 draw_mesh( empty_start
, empty_count
);
1579 draw_mesh( filled_start
, filled_count
);
1583 if( term
->runs
[0].recv_count
> j
)
1585 colour_code_v3( term
->runs
[0].recieved
[j
], dot_colour
);
1586 v3_muls( dot_colour
, 0.8f
, dot_colour
);
1587 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, dot_colour
);
1589 draw_mesh( filled_start
, filled_count
);
1592 colour_code_v3( term
->runs
[0].conditions
[j
], dot_colour
);
1593 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, dot_colour
);
1595 draw_mesh( empty_start
, empty_count
);
1600 if( world
.simulating
)
1602 glUniform4f( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 0.0f
, 0.0f
, 0.0f
, 1.0f
);
1603 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), -0.5f
+ cosf( vg_time
* 4.0f
) * 0.2f
, sinf( vg_time
* 4.0f
) * 0.2f
+ (float)world
.h
* 0.5f
, 0.05f
);
1604 draw_mesh( filled_start
, filled_count
);
1608 float const score_bright
= 1.25f
;
1609 glUniform4f( SHADER_UNIFORM( shader_tile_colour
, "uColour" ),
1610 0.4f
*score_bright
, 0.39f
*score_bright
, 0.45f
*score_bright
, 1.0f
);
1612 use_mesh( &world
.numbers
);
1613 draw_numbers( (v3f
){ 2.0f
, (float)world
.h
-1.875f
, 0.3333f
}, world
.score
);
1615 // Level selection UI
1616 use_mesh( &world
.circle
);
1617 float ratio
= ((float)vg_window_x
/(float)vg_window_y
);
1619 m3x3f ui_view
= M3X3_IDENTITY
;
1620 m3x3_scale( ui_view
, (v3f
){ 1.0f
, ratio
, 1.0f
} );
1621 glUniformMatrix3fv( SHADER_UNIFORM( shader_tile_colour
, "uPv" ), 1, GL_FALSE
, (float *)ui_view
);
1623 // Calculate mouse in UIsp
1624 v3f mouse_ui_space
= { ((float)vg_mouse
[0] / (float)(vg_window_x
)) * 2.0f
- 1.0f
,
1625 (((float)vg_mouse
[1] / (float)(vg_window_y
)) * 2.0f
- 1.0f
)*(-1.0f
/ratio
), 0.0125f
};
1627 // Get selected level
1628 const float selection_scale
= 0.05f
;
1629 int const level_count
= vg_list_size( level_pack_1
);
1630 int level_select
= -1;
1632 if( mouse_ui_space
[0] <= -0.8f
)
1634 float levels_range
= (float)level_count
*selection_scale
*0.6f
;
1635 float level_offset
= ((-mouse_ui_space
[1] + levels_range
) / levels_range
) * 0.5f
* (float)level_count
;
1636 level_select
= ceilf( level_offset
);
1639 if( level_select
>= 0 && level_select
< vg_list_size( level_pack_1
) )
1641 glUniform4f( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 0.369768f
, 0.3654f
, 0.42f
, 1.0f
);
1643 use_mesh( &world
.tile
);
1644 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ),
1646 ((float)level_count
- (float)level_select
* 2.0f
) * selection_scale
* 0.6f
,
1651 use_mesh( &world
.circle
);
1653 if( vg_get_button_down( "primary" ) )
1655 console_changelevel( 1, level_pack_1
+ level_select
);
1659 else mouse_ui_space
[1] = INFINITY
;
1661 glUniform4f( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 0.4f
, 0.39f
, 0.45f
, 1.0f
);
1664 for( int i
= 0; i
< level_count
; i
++ )
1666 struct career_level
*clevel
= &career
.levels
[i
];
1668 v3f level_ui_space
= {
1670 ((float)level_count
- (float)i
* 2.0f
) * selection_scale
* 0.6f
+ selection_scale
* 0.5f
,
1671 selection_scale
* 0.5f
1674 float scale
= vg_clampf( 1.0f
- fabsf(level_ui_space
[1] - mouse_ui_space
[1]) * 2.0f
, 0.9f
, 1.0f
);
1675 level_ui_space
[2] *= scale
;
1677 glUniform3fv( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), 1, level_ui_space
);
1679 if( clevel
->completed
)
1680 draw_mesh( filled_start
, filled_count
);
1682 draw_mesh( empty_start
, empty_count
);
1686 use_mesh( &world
.numbers
);
1687 for( int i
= 0; i
< level_count
; i
++ )
1689 struct career_level
*clevel
= &career
.levels
[i
];
1691 v3f level_ui_space
= {
1693 ((float)level_count
- (float)i
* 2.0f
) * selection_scale
* 0.6f
+ selection_scale
* 0.5f
,
1697 if( clevel
->completed
)
1699 draw_numbers( level_ui_space
, clevel
->score
);
1703 //use_mesh( &world.numbers );
1704 //draw_numbers( (v3f){ 0.0f, -0.5f, 0.1f }, 128765 );