january update version 1.5
[fishladder.git] / fishladder_resources.h
1 // TEXTURES
2 // ===========================================================================================================
3
4 vg_tex2d tex_tile_data = { .path = "textures/tileset.qoi" };
5 vg_tex2d tex_tile_detail = { .path = "textures/tile_overlays.qoi" };
6
7 vg_tex2d tex_tiles_wood = { .path = "textures/tile_wood.qoi" };
8 vg_tex2d tex_tiles_min = { .path = "textures/tile_minimal.qoi" };
9 vg_tex2d tex_tiles_lab = { .path = "textures/tile_lab.qoi" };
10
11 vg_tex2d tex_ball_noise = { .path = "textures/bnoise.qoi" };
12 vg_tex2d tex_unkown = { .path = "textures/unkown.qoi" };
13 vg_tex2d tex_buttons = { .path = "textures/buttons.qoi" };
14 vg_tex2d tex_sprites = { .path = "textures/autocombine.qoi" };
15
16 vg_tex2d *texture_list[] = {
17 &tex_tile_detail,
18 &tex_tile_data,
19 &tex_tiles_wood,
20 &tex_tiles_min,
21 &tex_tiles_lab,
22 &tex_ball_noise,
23 &tex_unkown,
24 &tex_buttons,
25 &tex_sprites
26 };
27
28 #include "sprites_autocombine.h"
29
30 // AUDIO
31 // ===========================================================================================================
32
33 sfx_vol_control audio_volume_sfx = { .val = 1.0f, .name = "Sound effects" };
34 sfx_vol_control audio_volume_music = { .val = 1.0f, .name = "Music" };
35
36 sfx_system audio_system_sfx =
37 {
38 .vol = 1.f,
39 .ch = 1,
40 .vol_src = &audio_volume_sfx,
41 .name = "sfx"
42 };
43
44 sfx_set audio_tile_mod =
45 {
46 .sources = "\
47 sound/mod_01.ogg\0\
48 sound/mod_02.ogg\0\
49 sound/mod_03.ogg\0\
50 sound/mod_04.ogg\0\
51 sound/mod_05.ogg\0\
52 sound/mod_06.ogg\0",
53 .flags = 0
54 };
55
56 sfx_set audio_splitter =
57 {
58 .sources = "\
59 sound/splitter_01.ogg\0"
60 };
61
62 sfx_set audio_rolls =
63 {
64 .sources = "\
65 sound/rolling_01.ogg\0\
66 sound/rolling_02.ogg\0"
67 };
68
69 sfx_set audio_random =
70 {
71 .sources = "\
72 sound/random_01.ogg\0\
73 sound/random_02.ogg\0\
74 sound/random_03.ogg\0\
75 sound/random_04.ogg\0\
76 sound/random_05.ogg\0\
77 sound/random_06.ogg\0\
78 sound/random_07.ogg\0\
79 sound/random_08.ogg\0"
80 };
81
82 sfx_set audio_clicks =
83 {
84 .sources = "\
85 sound/click_a.ogg\0\
86 sound/click_b.ogg\0\
87 sound/click_c.ogg\0"
88 };
89
90 sfx_set audio_tones =
91 {
92 .sources = "\
93 sound/y0.ogg\0\
94 sound/y1.ogg\0\
95 sound/y2.ogg\0\
96 sound/y3.ogg\0\
97 sound/y4.ogg\0\
98 sound/y5.ogg\0\
99 sound/y6.ogg\0\
100 sound/y7.ogg\0\
101 sound/y8.ogg\0\
102 sound/win.ogg\0"
103 };
104
105 // One two or three layers of rolling noise
106 sfx_system audio_system_balls_rolling =
107 {
108 .vol = 0.7f, .ch = 1, .vol_src = &audio_volume_sfx,
109 .name = "Balls Rolling", .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT
110 };
111
112 // Various oneshots
113 sfx_system audio_system_balls_switching =
114 {
115 .vol = 0.2f, .ch = 1, .vol_src = &audio_volume_sfx,
116 .name = "Balls Switching"
117 };
118
119 // Gameplay critical sounds eg. splitter sound rocking
120 sfx_system audio_system_balls_important =
121 {
122 .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx,
123 .name = "Balls Gameplay"
124 };
125
126 // Suplemental sounds
127 sfx_system audio_system_balls_extra =
128 {
129 .vol = 0.27f, .ch = 1, .vol_src = &audio_volume_sfx,
130 .name = "Balls Extra"
131 };
132
133 sfx_system audio_system_ui =
134 {
135 .vol = 1.f, .ch = 1, .vol_src = &audio_volume_sfx,
136 .name = "UI"
137 };
138
139 static void resource_load_main(void)
140 {
141 // Textures // UI
142 vg_tex2d_init( texture_list, vg_list_size( texture_list ) );
143
144 // Audio
145 sfx_set_init( &audio_tile_mod, NULL );
146 sfx_set_init( &audio_splitter, NULL );
147 sfx_set_init( &audio_rolls, NULL );
148 sfx_set_init( &audio_random, NULL );
149 sfx_set_init( &audio_clicks, NULL );
150 sfx_set_init( &audio_tones, NULL );
151 }
152
153 static void resource_free_main(void)
154 {
155 vg_tex2d_free( texture_list, vg_list_size( texture_list ) );
156
157 sfx_set_free( &audio_tile_mod );
158 sfx_set_free( &audio_splitter );
159 sfx_set_free( &audio_rolls );
160 sfx_set_free( &audio_random );
161 sfx_set_free( &audio_clicks );
162 sfx_set_free( &audio_tones );
163 }
164
165 // SHADERS
166 // ===========================================================================================================
167
168 SHADER_DEFINE( shader_tile_colour,
169
170 // VERTEX
171 "layout (location=0) in vec2 a_co;"
172 "uniform mat3 uPv;"
173 "uniform vec3 uOffset;"
174 ""
175 "void main()"
176 "{"
177 "gl_Position = vec4( uPv * vec3( a_co * uOffset.z + uOffset.xy, 1.0 ), 1.0 );"
178 "}",
179
180 // FRAGMENT
181 "out vec4 FragColor;"
182 "uniform vec4 uColour;"
183 ""
184 "void main()"
185 "{"
186 "FragColor = uColour;"
187 "}"
188 ,
189 UNIFORMS({ "uPv", "uOffset", "uColour" })
190 )
191
192 SHADER_DEFINE( shader_ball,
193 // VERTEX
194 "layout (location=0) in vec2 a_co;"
195 "uniform vec3 uOffset;"
196 "uniform mat3 uPv;"
197 ""
198 "out vec4 aTexCoords;"
199 ""
200 "void main()"
201 "{"
202 // Vertex transform
203 "vec3 worldpos = vec3( (a_co * 0.5 - 0.25) * uOffset.z + uOffset.xy, 1.0 );"
204 "gl_Position = vec4( uPv * worldpos, 1.0 );"
205
206 // Create texture coords
207 "aTexCoords = vec4( a_co, worldpos.xy );"
208 "}",
209
210 // FRAGMENT
211 "out vec4 FragColor;"
212 ""
213 "uniform sampler2D uTexMain;"
214 "uniform vec3 uColour;"
215 "uniform vec2 uTexOffset;"
216 ""
217 "in vec4 aTexCoords;"
218 ""
219 "void main()"
220 "{"
221 "vec2 center_coords = aTexCoords.xy - 0.5;"
222 "vec2 center_coords_sqr = center_coords*center_coords;"
223 "float circle_factor = smoothstep( 0.07, 0.0625, center_coords_sqr.x+center_coords_sqr.y );"
224
225 "float bulge_amt = center_coords_sqr.x+center_coords_sqr.y;"
226 "vec2 warped_coords = aTexCoords.zw+uTexOffset - center_coords;"
227 "vec4 noise_sample = texture( uTexMain, warped_coords );"
228
229 "float rim_light = (center_coords_sqr.x+center_coords_sqr.y)*15.0;"
230
231 "vec2 shadow_coords = center_coords + vec2(0.02,0.07);"
232 "vec2 shadow_coords_sqr = shadow_coords*shadow_coords;"
233 "float shadow = exp(-((shadow_coords_sqr.x+shadow_coords_sqr.y)-0.0125)*15.0);"
234
235 "vec3 marble_comp = uColour*0.9 + (noise_sample.x*0.7+pow(rim_light,3.0)*2.0) * 0.1;"
236 //"vec4 colour_comp = mix( vec4(0.74,0.53,0.34,shadow), vec4(marble_comp,1.0), circle_factor );"
237 "vec4 colour_comp = mix( vec4(0.2,0.2,0.2,shadow), vec4(marble_comp,1.0), circle_factor );"
238
239 "FragColor = colour_comp;"
240 "}"
241 ,
242 UNIFORMS({ "uTexMain", "uColour", "uOffset", "uPv", "uTexOffset" })
243 )
244
245 SHADER_DEFINE( shader_tile_main,
246 // VERTEX
247 "layout (location=0) in vec2 a_co;"
248 "uniform vec4 uOffset;" // Tile x/y, uv x/y
249 "uniform mat3 uPv;"
250 "uniform mat2 uSubTransform;"
251 "uniform float uVisibility;"
252 ""
253 "out vec4 aTexCoords;"
254 "out vec2 aWorldCoords;"
255 ""
256 "vec2 hash22(vec2 p)"
257 "{"
258 "vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));"
259 "p3 += dot(p3, p3.yzx+33.33);"
260 "return fract((p3.xx+p3.yz)*p3.zy);"
261 "}"
262 ""
263 "void main()"
264 "{"
265 "vec2 hash_val = hash22(uOffset.xy);"
266 "float scaling_factor = smoothstep( hash_val.x, hash_val.x+1.0, uVisibility );"
267
268 // Vertex transform
269 "vec2 subtransform = uSubTransform * (a_co-0.5) * scaling_factor + 0.5;"
270 "vec3 worldpos = vec3( subtransform + uOffset.xy, 1.0 );"
271 "gl_Position = vec4( uPv * worldpos, 1.0 );"
272
273 // Create texture coords
274 "vec2 random_offset = floor(hash_val * 4.0) * 0.25;"
275 "vec2 edge_safe_coords = a_co * 0.98 + 0.01;"
276 "aTexCoords = vec4((edge_safe_coords + uOffset.zw) * 0.25, edge_safe_coords * 0.25 + random_offset );"
277 "aWorldCoords = worldpos.xy;"
278 "}",
279
280 // FRAGMENT
281 "out vec4 FragColor;"
282 ""
283 "uniform sampler2D uTexGlyphs;"
284 "uniform sampler2D uTexWood;"
285 "uniform float uGhost;"
286 "uniform float uForeground;"
287 "uniform vec2 uMousePos;"
288 "uniform vec4 uColour;"
289 "uniform vec3 uShadowing;"
290 ""
291 "in vec4 aTexCoords;"
292 "in vec2 aWorldCoords;"
293 ""
294 "void main()"
295 "{"
296 //"vec3 shadowing_colour = vec3( 0.93, 0.88536, 0.8184 ) * 0.97;"
297 //"vec3 shadowing_colour = vec3( 0.8, 0.8, 0.8 );"
298
299 "vec4 glyph = texture( uTexGlyphs, aTexCoords.xy );"
300 "vec4 wood = texture( uTexWood, aTexCoords.zw );"
301 "vec4 wood_secondary = texture( uTexWood, aTexCoords.zw + 0.25 );"
302 "vec3 wood_comp = mix( wood_secondary.rgb * uShadowing, wood.rgb, clamp( glyph.b*2.0-1.0, 0.0, 1.0 ) );"
303
304 //"vec3 shadows = mix( vec3( 0.85, 0.7344, 0.561 ), vec3(1.0,1.0,1.0), glyph.r );"
305 "vec3 shadows = mix( uShadowing, vec3(1.0,1.0,1.0), glyph.r );"
306
307 "vec4 output_regular = vec4( wood_comp * shadows, mix( glyph.a, glyph.b, uForeground ) );"
308
309 "float ghost_dist = clamp( 1.5 - distance(uMousePos, aWorldCoords), 0.0, 1.0 );"
310 "vec4 output_ghost = vec4( 1.0, 1.0, 1.0, glyph.g * ghost_dist );"
311
312 "FragColor = mix( output_regular, output_ghost, uGhost ) * uColour;"
313 "}"
314 ,
315 UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos",
316 "uColour", "uForeground", "uVisibility", "uShadowing" })
317 )
318
319 SHADER_DEFINE( shader_background,
320 // VERTEX
321 "layout (location=0) in vec2 a_co;"
322 "uniform mat3 uPv;"
323 "uniform vec3 uOffset;"
324 ""
325 "out vec2 aTexCoords;"
326 ""
327 "void main()"
328 "{"
329 "vec2 world_pos = a_co * uOffset.z + uOffset.xy;"
330 "gl_Position = vec4( uPv * vec3( world_pos, 1.0 ), 1.0 );"
331 "aTexCoords = a_co;"
332 "}",
333
334 // FRAGMENT
335 "out vec4 FragColor;"
336 ""
337 "uniform sampler2D uTexMain;"
338 "uniform sampler2D uSamplerNoise;"
339 "uniform float uVariance;"
340 "uniform float uVisibility;"
341 ""
342 "in vec2 aTexCoords;"
343 ""
344 "void main()"
345 "{"
346 "float ao_accum = 0.0;"
347 "for( int i=0; i<10; ++i )"
348 "{"
349 "vec2 random_noise = (texture( uSamplerNoise, aTexCoords * 20.0 + float(i) * 0.2 ).xy - vec2( 0.5, 0.5 )) * uVariance;"
350 "vec4 background = texture( uTexMain, aTexCoords + random_noise );"
351 "ao_accum += background.r * clamp((1.0 - length( random_noise )), 0.0, 1.0);"
352 "}"
353 "ao_accum *= 0.15;"
354
355 "vec4 data_this_tile = texture( uTexMain, aTexCoords );"
356
357 "ao_accum -= data_this_tile.r;"
358 "ao_accum *= uVisibility;"
359
360 "vec3 colour_main = mix( vec3( 0.369768, 0.3654, 0.42 ), vec3( 0.275, 0.388, 0.553 ), data_this_tile.g * uVisibility );"
361
362 "vec2 square_coords = fract( aTexCoords * 64.0 );"
363 "vec2 grid_coords = abs( square_coords - 0.5 );"
364 "float edge_contrast = (1.0-ao_accum*0.2);"
365
366 "float gridline = step( 0.49, max(grid_coords.x,grid_coords.y) );"
367 "float gridline_fadeout = min(max(edge_contrast-1.0, 0.0)*40.0 + data_this_tile.g,10.0);"
368
369 "FragColor = vec4( colour_main * edge_contrast + gridline * 0.02 * gridline_fadeout, 1.0 );"
370 "}"
371 ,
372 UNIFORMS({ "uPv", "uOffset", "uTexMain", "uVariance", "uSamplerNoise", "uVisibility" })
373 )
374
375 SHADER_DEFINE( shader_wire,
376 // VERTEX
377 "layout (location=0) in vec2 a_co;"
378 "uniform vec3 uStart;"
379 "uniform vec3 uEnd;"
380 "uniform mat3 uPv;"
381 "uniform float uCurve;"
382 ""
383 "out vec2 aTexCoords;"
384 ""
385 "vec3 sample_curve_time( float t )"
386 "{"
387 "vec3 line_coord = mix( uStart, uEnd, t );"
388
389 "float curve_amt = 1.0-(pow((t*2.0-1.0),2.0));"
390 "return vec3( line_coord.x, line_coord.y - curve_amt*uCurve, line_coord.z );"
391 "}"
392 ""
393 "void main()"
394 "{"
395 // Vertex transform
396 "vec3 p0 = sample_curve_time( a_co.x );"
397 "vec3 p1 = sample_curve_time( a_co.x + 0.025 );"
398
399 "vec2 line_tangent = normalize(p1.xy-p0.xy);"
400 "vec2 line_normal = vec2( -line_tangent.y, line_tangent.x );"
401
402 "vec2 worldfinal = p0.xy + line_normal*a_co.y*p0.z;"
403
404 "gl_Position = vec4( uPv * vec3(worldfinal, 1.0), 1.0 );"
405
406 // Create texture coords (todo: include stretch adjusted coords?)
407 "aTexCoords = vec2( a_co.x, a_co.y + 0.5 );"
408 "}",
409
410 // FRAGMENT
411 "out vec4 FragColor;"
412 ""
413 "uniform sampler2D uTexMain;"
414 "uniform vec4 uColour;"
415 "uniform float uTime;"
416 "uniform float uGlow;"
417 ""
418 "in vec2 aTexCoords;"
419 ""
420 "void main()"
421 "{"
422 // Compute shadowing
423 "float shadow = 1.0 - abs(aTexCoords.y - 0.5) * 2.0;"
424 "float masking = smoothstep( 0.5, 0.8, shadow );"
425
426 "vec3 colour_comp = mix( vec3(0.0,0.0,0.0), uColour.rgb, masking );"
427
428 "float flow_thing = fract( aTexCoords.x + uTime );"
429 "vec3 final_comp = colour_comp + flow_thing * uGlow;"
430
431 "FragColor = vec4( final_comp, max( shadow* 0.2, masking ) * uColour.a );"
432 "}"
433 ,
434 UNIFORMS({ "uPv", "uColour", "uTexMain", "uStart", "uEnd", "uCurve", "uTime", "uGlow" })
435 )
436
437 SHADER_DEFINE( shader_buttons,
438 // VERTEX
439 "layout (location=0) in vec2 a_co;"
440 "uniform vec4 uOffset;" // Tile x/y, uv x/y
441 "uniform mat3 uPv;"
442 ""
443 "out vec2 aTexCoords;"
444 ""
445 "void main()"
446 "{"
447 // Vertex transform
448 "vec3 worldpos = vec3( a_co + uOffset.xy, 1.0 );"
449 "gl_Position = vec4( uPv * worldpos, 1.0 );"
450
451 // Create texture coords
452 "vec2 edge_safe_coords = a_co * 0.98 + 0.01;"
453 "aTexCoords = (edge_safe_coords + uOffset.zw) * 0.25;"
454 "}",
455
456 // FRAGMENT
457 "out vec4 FragColor;"
458 ""
459 "uniform sampler2D uTexMain;"
460 "uniform vec4 uColour;" // rgb, light amount
461 ""
462 "in vec2 aTexCoords;"
463 ""
464 "void main()"
465 "{"
466 "vec4 glyph = texture( uTexMain, aTexCoords.xy );"
467
468 "FragColor = vec4( uColour.rgb * (mix(glyph.r, glyph.g, uColour.a)+0.02)*2.6 + glyph.b * 0.4, glyph.a );"
469 "}"
470 ,
471 UNIFORMS({ "uPv", "uOffset", "uTexMain", "uColour" })
472 )
473
474 SHADER_DEFINE( shader_sprite,
475
476 // VERTEX
477 "layout (location=0) in vec2 a_co;" // quad mesh
478 "uniform vec4 uUv;"
479 "uniform vec3 uPos;"
480 ""
481 "uniform mat3 uPv;"
482 ""
483 "out vec2 aTexCoords;"
484 ""
485 "void main()"
486 "{"
487 "vec2 vertex_world = uUv.zw * (a_co-0.5) * uPos.z + uPos.xy;"
488 "gl_Position = vec4( uPv * vec3( vertex_world, 1.0 ), 1.0 );"
489 "aTexCoords = uUv.xy + a_co*uUv.zw;"
490 "}",
491
492 // FRAGMENT
493 "uniform sampler2D uTexMain;"
494 "out vec4 FragColor;"
495 ""
496 "in vec2 aTexCoords;"
497 ""
498 "void main()"
499 "{"
500 "vec4 texture_sample = texture( uTexMain, aTexCoords );"
501 "FragColor = texture_sample;"
502 "}"
503 ,
504 UNIFORMS({ "uPv", "uTexMain", "uUv", "uPos" })
505 )
506
507 void vg_register(void)
508 {
509 SHADER_INIT( shader_tile_colour );
510 SHADER_INIT( shader_tile_main );
511 SHADER_INIT( shader_ball );
512 SHADER_INIT( shader_background );
513 SHADER_INIT( shader_wire );
514 SHADER_INIT( shader_buttons );
515 SHADER_INIT( shader_sprite );
516 }
517
518 /*
519 0000 0 | 0001 1 | 0010 2 | 0011 3
520 | | | | |
521 X | X= | X | X=
522 | | |
523 0100 4 | 0101 5 | 0110 6 | 0111 7
524 | | | | |
525 =X | =X= | =X | =X=
526 | | |
527 1000 8 | 1001 9 | 1010 10 | 1011 11
528 | | | | |
529 X | X= | X | X=
530 | | | | | | |
531 1100 12 | 1101 13 | 1110 14 | 1111 15
532 | | | | |
533 =X | =X= | =X | =X=
534 | | | | | | |
535 */
536
537 struct cmp_level
538 {
539 // Basic info
540 int serial_id;
541
542 const char *map_name;
543 const char *title;
544 const char *description;
545
546 const char *achievement;
547
548 int _unlock, _linked; // When completed, unlock this level
549 int is_tutorial;
550
551 // Aesthetic
552 struct world_string
553 {
554 enum placement
555 {
556 k_placement_top,
557 k_placement_bottom
558 }
559 placement;
560
561 const char *str;
562 }
563 strings[2];
564
565 // Persistent stats
566 int unlocked;
567 int completed_score;
568
569 // Runtime
570 struct world_button btn;
571 struct cmp_level *unlock, *linked;
572
573 #ifdef VG_STEAM
574 SteamLeaderboard_t steam_leaderboard;
575 #endif
576 };
577
578 static struct cmp_level cmp_levels_tutorials[] =
579 {
580 {
581 0, "cmp_t01", "PRINCIPLE 1", "",
582 ._unlock = 1,
583 .is_tutorial = 1
584 },
585 {
586 1, "cmp_t02", "PRINCIPLE 2", "",
587 ._unlock = 2,
588 .is_tutorial = 1,
589 },
590 {
591 2, "cmp_t03", "PRINCIPLE 3", "",
592 ._unlock = 12,
593 .is_tutorial = 1
594 },
595 {
596 12, "cmp_t04", "PRINCIPLE 4", "",
597 ._unlock = 6,
598 .is_tutorial = 1,
599 .achievement = "TUTORIALS"
600 },
601 {
602 15, "cmp_b10", "PRINCIPLE 5", "",
603 ._unlock = 16,
604 .is_tutorial = 1
605 },
606 {
607 17, "cmp_b11", "PRINCIPLE 6", "(Right click)",
608 ._unlock = 18,
609 .is_tutorial = 1
610 },
611 {
612 26, "cmp_p7", "PRINCIPLE 7", "Emitters",
613 ._unlock = 27,
614 ._linked = 13,
615 .is_tutorial = 1
616 }
617 };
618
619 static struct cmp_level cmp_levels_basic[] =
620 {
621 {
622 6, "cmp_b04", "PATCH", "",
623 ._unlock = 7,
624 ._linked = 3
625 },
626 {
627 3, "cmp_b01", "SUBDIVISION 1", "",
628 ._linked = 4,
629 ._unlock = 5
630 },
631 {
632 4, "cmp_b02", "SUBDIVISION 2", "",
633 ._unlock = 7
634 },
635 {
636 5, "cmp_b03", "RESTRUCTURE", "",
637 ._unlock = 8,
638 ._linked = 31
639 },
640 {
641 31, "cmp_121", "1-2-1", "",
642 ._unlock = 8
643 },
644 {
645 7, "cmp_b05", "PATTERNS 1", "",
646 ._unlock = 15,
647 ._linked = 8
648 },
649 {
650 8, "cmp_b06", "PATTERNS 2", "",
651 ._unlock = 15
652 },
653 {
654 16, "cmp_routing", "ROUTING PROBLEM", "",
655 ._linked = 9
656 },
657 {
658 9, "cmp_b07", "MIGHTY CONSUMER", "",
659 ._linked = 10,
660 ._unlock = 11,
661 .achievement = "MIGHTY_CONSUMER"
662 },
663 {
664 10, "cmp_b08", "SHIFT", "",
665 ._unlock = 17
666 },
667 {
668 11, "cmp_b09", "REVERSE", "",
669 ._unlock = 17
670 },
671 {
672 18, "cmp_not", "NOT GATE", "",
673 ._linked = 19,
674 ._unlock = 20
675 },
676 {
677 19, "cmp_and", "AND GATE", "",
678 ._unlock = 20
679 },
680 {
681 20, "cmp_xor", "QUALIFICATION PROJECT", "",
682 ._unlock = 26,
683 .achievement = "GRADUATE"
684 },
685 {
686 27, "cmp_expander", "EXPAND", "",
687 ._unlock = 28
688 },
689 {
690 28, "cmp_pattern3", "PATTERNS 3", "",
691 ._linked = 29
692 },
693 {
694 29, "cmp_routing2", "ROUTING PROBLEM 2", "Spaghetti!",
695 ._linked = 30,
696 ._unlock = 32
697 },
698 {
699 30, "cmp_exact5", "EXACTLY 5", "",
700 ._unlock = 32
701 },
702 {
703 32, "cmp_3and2", "THREE AND FOUR", ""
704 }
705 };
706
707 static struct cmp_level cmp_levels_grad[] =
708 {
709 {
710 13, "cmp_i01", "SORT", "",
711 ._linked = 14
712 },
713 {
714 14, "cmp_i02", "THIRDS", "",
715 ._linked = 21
716 },
717 {
718 21, "cmp_grad", "SIMPLE ADDITION", "",
719 ._linked = 22,
720 ._unlock = 23
721 },
722 {
723 22, "cmp_secret", "SECRET CODE", "",
724 ._unlock = 23
725 }
726 };
727
728 static struct cmp_level cmp_levels_computer[] =
729 {
730 {
731 23, "cmp_binary", "3 BIT BINARY", "Convert amount to binary",
732 ._unlock = 24,
733 .strings =
734 {
735 {
736 .placement = k_placement_bottom,
737 .str =
738 "\t\t\t\t\t\t\t\t\t\t\x83 \x84\n"
739 "\t\t\t\t\t\t\t\t\t\t\x83 \x84 Binary\n"
740 "\t\t\t\t\t\t\t\t\t\t\x83 4 2 1 \x84"
741 },
742 {
743 .placement = k_placement_top,
744 .str =
745 "\n"
746 "\t\t\t\t\t\t\t\t\t\t\t Count"
747 }
748 }
749 },
750 {
751 24, "cmp_add3b", "3 BIT ADDER", "Binary addition",
752 ._unlock = 25,
753 .strings =
754 {
755 {
756 .placement = k_placement_top,
757 //.str ="\t\t\t\t\t\t\t\t\t| NUMBER A | | NUMBER B |\n"
758 .str =""
759 "\t\t\t\t\t\t\t\t\t\x8A 4 2 1 \x8B \x8A 4 2 1 \x8B\n"
760 "\t\t\t\t\t\t\t\t\t\x83 \x84 add \x83 \x84\n"
761 "\t\t\t\t\t\t\t\t\t\x83 \x84 \x83 \x84"
762 },
763 {
764 .placement = k_placement_bottom,
765 .str =
766 "\t\t\t\x83 \x84\n"
767 "\t\t\t\x83 \x84 result a+b\n"
768 "\t\t\t\x83 8 4 2 1 \x84"
769 }
770 }
771 },
772 {
773 25, "cmp_plot3x3", "3x3 PLOT", "2 bit x/y",
774 .strings =
775 {
776 {
777 .placement = k_placement_top,
778 .str=
779 "\t\t\t\t\t\t\t\t\x8A 2 1 \x8B \x8A 2 1 \x8B\n"
780 "\t\t\t\t\t\t\t\t\x83 \x84 X Y \x83 \x84\n"
781 "\t\t\t\t\t\t\t\t\x83 \x84 \x83 \x84"
782 }
783 }
784 }
785 };
786
787 #define NUM_CAMPAIGN_LEVELS (vg_list_size( cmp_levels_tutorials ) + vg_list_size( cmp_levels_basic ) + vg_list_size( cmp_levels_grad ) + vg_list_size( cmp_levels_computer ) )
788
789 static struct career_level_pack
790 {
791 struct cmp_level *pack;
792 const char *title;
793 int count;
794
795 v3f primary_colour;
796 v2i origin;
797 v2i dims;
798 }
799 career_packs[] =
800 {
801 {
802 .pack = cmp_levels_tutorials,
803 .title = "",
804 .count = vg_list_size( cmp_levels_tutorials ),
805 .primary_colour = { 0.204f, 0.345f, 0.553f },
806 .origin = { -5, -2 },
807 .dims = { 1, 7 }
808 },
809 {
810 .pack = cmp_levels_basic,
811 .title = "\x8C\x8D"" Core",
812 .count = vg_list_size( cmp_levels_basic ),
813 .primary_colour = { 0.304f, 0.245f, 0.553f },
814 .origin = { -3, -2 },
815 .dims = { 3, 7 }
816 },
817 {
818 .pack = cmp_levels_grad,
819 .title = "\x8C\x8E"" Challenge",
820 .count = vg_list_size( cmp_levels_grad ),
821 .primary_colour = { 0.553f, 0.345f, 0.204f },
822 .origin = { -5, 6 },
823 .dims = { 5, 1 }
824 },
825 {
826 .pack = cmp_levels_computer,
827 .title = "\x8C\x8F"" 3 Bit computer\n\n (preview)",
828 .count = vg_list_size( cmp_levels_computer ),
829 .primary_colour = { 0.75f, 0.23f, 0.39f },
830 .origin = { -5, 8 },
831 .dims = { 5, 2 }
832 }
833 };
834
835 // Setup pointers and that
836 static void career_local_data_init(void)
837 {
838 struct cmp_level *level_ptrs[ NUM_CAMPAIGN_LEVELS ];
839 for( int i = 0; i < NUM_CAMPAIGN_LEVELS; i ++ )
840 level_ptrs[i] = NULL;
841
842 // COllect pointers
843 for( int i = 0; i < vg_list_size( career_packs ); i ++ )
844 {
845 struct career_level_pack *set = &career_packs[i];
846
847 for( int j = 0; j < set->count; j ++ )
848 {
849 int id = set->pack[j].serial_id;
850
851 if( level_ptrs[ id ] )
852 vg_error( "Serial id %u already used!\n", id );
853 else
854 level_ptrs[ set->pack[j].serial_id ] = &set->pack[j];
855 }
856 }
857
858 // Apply
859 for( int i = 0; i < vg_list_size( career_packs ); i ++ )
860 {
861 struct career_level_pack *set = &career_packs[i];
862
863 for( int j = 0; j < set->count; j ++ )
864 {
865 struct cmp_level *lvl = &set->pack[j];
866
867 if( lvl->_unlock >= NUM_CAMPAIGN_LEVELS ||
868 lvl->_linked >= NUM_CAMPAIGN_LEVELS )
869 {
870 vg_error( "_unlock / _linked out of range (%d, %d)\n",
871 lvl->_unlock, lvl->_linked );
872 }
873 else
874 {
875 lvl->unlock = lvl->_unlock? level_ptrs[ lvl->_unlock ]: NULL;
876 lvl->linked = lvl->_linked? level_ptrs[ lvl->_linked ]: NULL;
877 }
878 }
879 }
880 }