├── bf_interpreter.spwn ├── brainfugd_pro.spwn ├── brainfugd_tutorial.txt ├── text_display.spwn └── text_display_pro.spwn /bf_interpreter.spwn: -------------------------------------------------------------------------------- 1 | RIGHT = ?b // > 2 | LEFT = ?b // < 3 | INCR = ?b // + 4 | DECR = ?b // - 5 | DOT = ?b // . 6 | INPUT = ?b // , 7 | OPEN = ?b // [ 8 | CLOSE = ?b // ] 9 | 10 | END = ?b //end of the program 11 | NOOP = ?b //NO OPERATION 12 | 13 | spacing = 10 14 | extract obj_props 15 | gs = { 16 | hidden_group: 976g, 17 | button_a: () { 18 | return collision(162b, 163b) 19 | }, 20 | button_b: () { 21 | return touch(dual_side = true) 22 | }, 23 | } 24 | 25 | abs = (num) { 26 | if num < 0 { 27 | return -num 28 | } else { 29 | return num 30 | } 31 | 32 | } 33 | import "text_display.spwn" 34 | 35 | gamemode = counter(20i) // 0 = tutorial, 1 = challenge, 2 = coins, 3 = sandbox 36 | started = counter(0) 37 | challenge = counter(556i) 38 | random_seed = counter(500i) 39 | random_bg_seed = counter(601i) 40 | bg_options = 2 41 | bg_part = counter() 42 | 43 | challenges = 9 44 | input_choice = counter() 45 | input_choice2 = counter() 46 | 47 | ended = counter(0) 48 | 49 | bg_option1 = counter(800i) 50 | bg_option2 = counter(801i) 51 | 52 | message_board = 931g 53 | 54 | game_bgs = [[906g, 907g, ?g], [910g, 911g, ?g], [912g, 913g, ?g], [940g, 941g, ?g], [970g, 971g, ?g], ] 55 | random_max = 4 56 | auto_inputs = [1,3,10,13] // 2.25 57 | auto_inputs2 = [2,3,6,8] // 0.5, 0.5, 0.5, 0.25 58 | 59 | // runs in a row, level complete, 60 | messages = [804c, 808c, 809c, 900c, 850c] 61 | 62 | 63 | bc = [77, 93, 97] 64 | 65 | left_buttons = [193c, 195c, 191c, 196c, 803c] 66 | 67 | right_buttons = [192c, 194c, 802c, 212c] 68 | 69 | activate_button = (activate, deactivate) { 70 | 71 | let colors = [] 72 | 73 | 74 | 75 | if activate != null { 76 | if left_buttons.contains(activate) { 77 | colors = left_buttons 78 | } else { 79 | colors = right_buttons 80 | } 81 | for col in colors { 82 | if col == activate { 83 | -> col.set(bc[0], bc[1], bc[2], 0) 84 | } else { 85 | -> col.set(0, 0, 0, 0, blending = true) 86 | } 87 | } 88 | } else if deactivate != null { 89 | if left_buttons.contains(deactivate) { 90 | colors = left_buttons 91 | } else { 92 | colors = right_buttons 93 | } 94 | for col in colors { 95 | -> col.set(0, 0, 0, 0, blending = true) 96 | } 97 | } 98 | 99 | } 100 | 101 | successful_runs = counter(555i) 102 | 103 | reset_runs_in_a_row = !{ 104 | num = successful_runs.to_const(1..4) 105 | successful_runs -= num 106 | -> 962g.move(200 * num, 0, 0) 107 | } // fully functional programming language inside geometry dash 108 | 109 | type @bfreader 110 | layers = counter(600i) 111 | //layers.display(150, 300) 112 | cell_pointer = 20g 113 | input_layer = 21g 114 | 115 | prog_pointer = 23g 116 | prog_selector = 24g 117 | force_stop_layer = 25g 118 | input_layer.alpha(0) 119 | //finished_layer.alpha(0) 120 | force_stop_layer.alpha(0) 121 | 122 | msg_board_anim = !{ 123 | -> 963g.move(0, -20, 1, easing = EXPONENTIAL_OUT) 124 | wait(2) 125 | -> 963g.move(0, 20, 1, easing = EXPONENTIAL_IN) 126 | } 127 | 128 | top_msg_board = (message, color) { 129 | msg_board_anim! 130 | 131 | for i in ..messages.length { 132 | if i == message { 133 | //-> messages[i].set(0,0,0, 0, blending = false) 134 | -> messages[i].set(color[0], color[1], color[2], 1, blending = false) 135 | } else { 136 | -> messages[i].set(0,0,0, 0, blending = true) 137 | } 138 | } 139 | } 140 | 141 | 142 | bottom_msg_board_up = (){ 143 | -> message_board.move(0, 10, 1, easing = EXPONENTIAL_OUT) 144 | -> 216c.set(255, 255, 255, 1) 145 | -> 942g.move(0, 30, 0.5, easing = EXPONENTIAL_OUT) 146 | } 147 | 148 | bottom_msg_board_down = (){ 149 | -> message_board.move(0, -10, 1, easing = EXPONENTIAL_IN) 150 | -> 216c.set(0, 0, 0, 1) 151 | -> 942g.move(0, -30, 0.5, easing = EXPONENTIAL_IN) 152 | } 153 | 154 | input_char = 26g 155 | 156 | tut_page = 965g 157 | tut_page_num = counter(0) 158 | tut_pages = 8 159 | 160 | move_button = 10c 161 | select_button = 11c 162 | 163 | input_inc_button = 12c 164 | input_done_button = 13c 165 | 166 | input_mode = counter() 167 | //input_mode.display(120, 30) 168 | 169 | input_used = counter(0) 170 | //input_used.display(90, 30) 171 | 172 | prog_ptr_color = [94, 13, 13] 173 | 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 174 | 175 | pulse_ptr = (){ 176 | -> 972g.move(0, 1, 0.05, easing = EASE_IN) 177 | -> 973g.move(0, -1, 0.05, easing = EASE_IN) 178 | -> 974g.move(1, 0, 0.05, easing = EASE_IN) 179 | -> 975g.move(-1, 0, 0.05, easing = EASE_IN) 180 | 181 | -> 972g.move(0, -1, 0.2, easing = EASE_IN_OUT) 182 | -> 973g.move(0, 1, 0.2, easing = EASE_IN_OUT) 183 | -> 974g.move(-1, 0, 0.2, easing = EASE_IN_OUT) 184 | -> 975g.move(1, 0, 0.2, easing = EASE_IN_OUT) 185 | } 186 | 187 | // win_condition = "win" 188 | // coin_condition = "coin tu" 189 | 190 | mem_items = [62i, 54i, 63i, 64i, 58i, 55i, 65i, 60i, 59i, 66i] 191 | 192 | 193 | force_stop = !{ 194 | -> 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 195 | bottom_msg_board_up() 196 | top_msg_board(3, [255, 255, 255]) 197 | //-> finished_color.set(255, 255, 255, 0) 198 | ended += 1 199 | -> if successful_runs > 0 { 200 | reset_runs_in_a_row! 201 | top_msg_board(0, [255, 0, 0]) 202 | } 203 | } 204 | 205 | impl @bfreader { 206 | new: (script_offset: [@number], cell_count: @number) { 207 | 208 | std_out = @textdisplay::new([script_offset[0] + 1278, script_offset[1] - 66], 10) 209 | //$.print("hello") 210 | //-> BG.pulse(255, 0, 0, fade_out = 0.5) 211 | //-> std_out.write(counter(5)) 212 | 213 | 214 | 215 | block = ?b 216 | group = ?g 217 | $.add(obj { 218 | OBJ_ID: 1816, 219 | X: script_offset[0] - spacing * 3, 220 | Y: script_offset[1], 221 | GROUPS: [group, gs.hidden_group], 222 | BLOCK_A: block, 223 | SCALING: 0.5, 224 | DYNAMIC_BLOCK: true, 225 | }) 226 | // for b in [RIGHT,LEFT,INCR,DECR,DOT,OPEN,CLOSE] { 227 | // $.add(obj { 228 | // OBJ_ID: 1816, 229 | // X: script_offset[0] - spacing * 3, 230 | // Y: script_offset[1], 231 | // SCALING: 0.5, 232 | // BLOCK_A: b, 233 | // }) 234 | // } 235 | 236 | //start point 237 | start_point = ?g 238 | $.add(obj { 239 | OBJ_ID: 1765, 240 | X: script_offset[0] - spacing * 3, 241 | Y: script_offset[1], 242 | GROUPS: start_point 243 | }) 244 | 245 | 246 | // CREATE CELLS 247 | let cells = [] 248 | for i in ..cell_count { 249 | c = counter(mem_items[i]) 250 | cells.push(c) 251 | //c.display(script_offset[0] + i * 30 + 300, script_offset[1] + 690) 252 | } 253 | ptr = counter(0) 254 | //ptr.display(script_offset[0], script_offset[1] + 60) 255 | std_in = counter(85i) 256 | //std_in.display(script_offset[0], script_offset[1] - 90) 257 | 258 | 259 | 260 | num_out = counter(61i) 261 | num_out.display(script_offset[0], script_offset[1] + 210) 262 | out = @bfreader::{ 263 | group: group, 264 | right: counter(block.create_tracker_item(RIGHT)), 265 | left: counter(block.create_tracker_item(LEFT)), 266 | incr: counter(block.create_tracker_item(INCR)), 267 | dot: counter(block.create_tracker_item(DOT)), 268 | input: counter(block.create_tracker_item(INPUT)), 269 | decr: counter(block.create_tracker_item(DECR)), 270 | open: counter(block.create_tracker_item(OPEN)), 271 | close: counter(block.create_tracker_item(CLOSE)), 272 | end: counter(block.create_tracker_item(END)), 273 | noop: counter(block.create_tracker_item(NOOP)), 274 | std_out: std_out, 275 | num_out: num_out, 276 | std_in: std_in, 277 | ptr: ptr, 278 | cells: cells, 279 | start_point: start_point 280 | } 281 | 282 | 283 | return out 284 | }, 285 | // currently_on: (self) { 286 | // if self.right == 1 { 287 | // return RIGHT 288 | // } 289 | // if self.left == 1 { 290 | // return LEFT 291 | // } 292 | // if self.incr == 1 { 293 | // return INCR 294 | // } 295 | // if self.decr == 1 { 296 | // return DECR 297 | // } 298 | // if self.dot == 1 { 299 | // return DOT 300 | // } 301 | // if self.input == 1 { 302 | // return INPUT 303 | // } 304 | // if self.open == 1 { 305 | // return OPEN 306 | // } if self.close == 1 { 307 | // return CLOSE 308 | // } if self.noop == 1 { 309 | // return NOOP 310 | // } 311 | // }, 312 | current_cell: (self) => self.cells[self.ptr.to_const(..self.cells.length)], 313 | interpret: (self) { 314 | 315 | ret = !{ 316 | supress_signal(0.05) 317 | -> self.group.move(spacing, 0, 0) 318 | -> return 319 | } 320 | 321 | fast_ret = !{ 322 | -> self.group.move(spacing, 0, 0) 323 | -> return 324 | } 325 | 326 | slow_ret = !{ 327 | supress_signal(0.1) 328 | wait(0.1) 329 | -> self.group.move(spacing, 0, 0) 330 | -> return 331 | } 332 | 333 | // slow_ret = !{ 334 | // supress_signal(0.06) 335 | // ret! 336 | // } 337 | 338 | 339 | 340 | -> if @bool(self.right) { 341 | 342 | if self.ptr == self.cells.length - 1 { 343 | wait() 344 | self.ptr -= self.cells.length - 1 345 | -> cell_pointer.move(-10 * (self.cells.length - 1),0, 0.1) 346 | ret! 347 | } else { 348 | wait() 349 | self.ptr += 1 350 | -> cell_pointer.move(10,0, 0.1) 351 | ret! 352 | } 353 | 354 | 355 | } 356 | -> if @bool(self.left) { 357 | if self.ptr == 0 { 358 | wait() 359 | self.ptr += self.cells.length - 1 360 | -> cell_pointer.move(10 * (self.cells.length - 1), 0, 0.1) 361 | ret! 362 | } else { 363 | wait() 364 | self.ptr -= 1 365 | -> cell_pointer.move(-10,0, 0.1) 366 | ret! 367 | } 368 | 369 | } 370 | -> if @bool(self.incr) { 371 | -> self.current_cell() += 1 372 | pulse_ptr() 373 | fast_ret! 374 | } 375 | -> if @bool(self.decr) { 376 | -> (){ 377 | cell = self.current_cell() 378 | //$.print(current) 379 | if cell > 0 { 380 | cell -= 1 381 | } 382 | }() 383 | pulse_ptr() 384 | fast_ret! 385 | } 386 | -> if @bool(self.dot) { 387 | 388 | () { 389 | self.num_out.reset(speed = 1) 390 | cell = self.current_cell() 391 | //wait() 392 | cell.copy_to([self.num_out], speed = 1) 393 | } () 394 | supress_signal(0.1) // DO NOT REMOVE VERY IMPORTANT APPARENTLY 395 | // REQUIRED FOR TEXT TO WORK ON MOBILE FOR SOME REASON 396 | 397 | self.std_out.write(self.num_out, speed = 1) 398 | 399 | slow_ret! 400 | } 401 | -> if @bool(self.input) { 402 | //supress_signal(0.1) 403 | std_in = self.std_in 404 | -> input_layer.alpha(1, 0.5) 405 | 406 | auto_input_challenges = [3, 4, 5] 407 | 408 | manual_input = !{ 409 | activate_button(802c, null) 410 | activate_button(803c, null) 411 | input_mode += 1 412 | } 413 | 414 | done = !{ 415 | -> if input_used < 2 { 416 | input_used += 1 417 | } 418 | activate_button(null, 802c) 419 | activate_button(null, 803c) 420 | 421 | -> input_done_button.pulse(52, 247, 68, fade_out = 0.3) 422 | -> input_layer.alpha(0, 0.5) 423 | cell = self.current_cell() 424 | cell.reset(speed = 1) 425 | std_in.add_to([cell], speed = 1, for_each = (n){ input_char.move(100 * n, 0, 0) }) 426 | 427 | slow_ret! 428 | } 429 | 430 | auto_input = !{ 431 | -> 801c.pulse(255, 255, 255, hold = 2.1) 432 | -> 214c.pulse(0,0,0, hold = 2.1) 433 | wait(0.5) 434 | choice = random_seed.to_const(0..random_max) 435 | input_used.item.if_is(EQUAL_TO, 0, !{ 436 | input_choice += choice 437 | std_in += auto_inputs[choice] 438 | input_char.move(-100 * auto_inputs[choice], 0, 0) 439 | }) 440 | input_used.item.if_is(EQUAL_TO, 1, !{ 441 | input_choice2 += choice 442 | std_in += auto_inputs2[choice] 443 | input_char.move(-100 * auto_inputs2[choice], 0, 0) 444 | }) 445 | 446 | call_with_delay(0.5, done) 447 | } 448 | 449 | 450 | 451 | for ch in 0..challenges { 452 | if auto_input_challenges.contains(ch) { 453 | challenge.item.if_is(EQUAL_TO, ch, !{ 454 | input_used.item.if_is(SMALLER_THAN, 2, auto_input) 455 | input_used.item.if_is(LARGER_THAN, 1, manual_input) 456 | }) 457 | } else { 458 | challenge.item.if_is(EQUAL_TO, ch, manual_input) 459 | } 460 | } 461 | 462 | gs.button_a().on_triggered(!{ 463 | supress_signal(0.05) 464 | if input_mode == 1 { 465 | -> input_inc_button.pulse(59, 144, 247, fade_out = 0.3) 466 | std_in += 1 467 | input_char.move(-100, 0, 0) 468 | } 469 | }) 470 | gs.button_b().on_triggered(!{ 471 | -> if input_mode == 1 { 472 | input_mode -= 1 473 | done! 474 | } 475 | }) 476 | 477 | } 478 | -> if @bool(self.open) { 479 | move_to = !{ 480 | -> 45c.set(prog_ptr_color[0] * 0.3, prog_ptr_color[1] * 0.3, prog_ptr_color[2] * 0.3, blending = true) 481 | //move to corresponding ] 482 | //layers = counter(0) 483 | condition = () => !(layers == 0 && self.close == 1) 484 | //self.group.move(spacing, 0) 485 | 486 | while_loop(condition, delay = 0.03, (){ 487 | 488 | wait(0.02) 489 | -> if self.open == 1{ 490 | layers += 1 491 | } 492 | 493 | -> if self.close == 1 { 494 | layers -= 1 495 | } 496 | 497 | -> if self.end == 1 { 498 | 499 | force_stop! 500 | } else { 501 | wait(0.01) 502 | self.group.move(spacing, 0) 503 | return 504 | } 505 | 506 | 507 | }) 508 | -> 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 509 | ret! 510 | } 511 | if self.current_cell() == 0 { 512 | layers -= 1 513 | call_with_delay(0.05, move_to) 514 | } else { 515 | ret! 516 | } 517 | } 518 | -> if @bool(self.close) { 519 | move_back = !{ 520 | -> 45c.set(prog_ptr_color[0] * 0.3, prog_ptr_color[1] * 0.3, prog_ptr_color[2] * 0.3, blending = true) 521 | //move back to corresponding [ 522 | //layers = counter(0) 523 | condition = ()=> !(layers == 0 && self.open == 1) 524 | //self.group.move(-spacing, 0) 525 | 526 | //wait() 527 | while_loop(condition, delay = 0.03, (){ 528 | wait(0.02) 529 | -> if self.close == 1 { 530 | layers += 1 531 | } 532 | 533 | -> if self.open == 1 { 534 | layers -= 1 535 | } 536 | -> if self.end == 1 { 537 | 538 | force_stop! 539 | } else { 540 | wait(0.01) 541 | self.group.move(-spacing, 0) 542 | return 543 | } 544 | }) 545 | -> 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 546 | ret! 547 | } 548 | if self.current_cell() != 0 { 549 | layers -= 1 550 | call_with_delay(0.05, move_back) 551 | } else { 552 | ret! 553 | } 554 | } 555 | -> if @bool(self.noop) { 556 | fast_ret! 557 | } 558 | 559 | 560 | } 561 | } 562 | move_group_menu = 31g 563 | move_group_game = 30g 564 | move_group_tut = 32g 565 | 566 | move_group_game.toggle_off() 567 | move_group_tut.toggle_off() 568 | 569 | roll_groups = 70g..110g 570 | 571 | 572 | insert_bf_cmd = (ch: @string, offset: [@number], group: @group) { 573 | 574 | blockid = switch ch { 575 | case ">": RIGHT,//increment the data pointer (to point to the next cell to the right). 576 | case "<": LEFT, //decrement the data pointer (to point to the next cell to the left). 577 | case "+": INCR, //increment (increase by one) the byte at the data pointer. 578 | case "-": DECR, //decrement (decrease by one) the byte at the data pointer. 579 | case ".": DOT, //output the byte at the data pointer. 580 | case ",": INPUT,//accept one byte of input, storing its value in the byte at the data pointer. 581 | case "[": OPEN, 582 | case "]": CLOSE, 583 | case "end": END, 584 | case "no\nop": NOOP, 585 | 586 | } 587 | 588 | 589 | $.add(obj { 590 | OBJ_ID: 1816, 591 | X: offset[0], 592 | Y: offset[1], 593 | BLOCK_A: blockid, 594 | GROUPS: [group, gs.hidden_group], 595 | SCALING: 0.5, 596 | }) 597 | // let scale 598 | // let color 599 | // if ch.length == 1 { 600 | // scale = 0.8 601 | // } else { 602 | // scale = 0.3 603 | // } 604 | // if blockid == NOOP { 605 | // color = 2c 606 | // } else { 607 | // color = 40c 608 | // } 609 | // $.add(obj { 610 | // OBJ_ID: 914, 611 | // X: offset[0] + 41 * 30 - 1200, 612 | // Y: offset[1] - 8.6 * 30 - 600, 613 | // TEXT: $.b64encrypt(ch), 614 | // GROUPS: [group, 968g, move_group], 615 | // SCALING: scale, 616 | // COLOR: color, 617 | // EDITOR_LAYER_1: 3, 618 | // Z_LAYER: 1 619 | // }) 620 | } 621 | 622 | offset = [1500, 900] 623 | sel_off = [600, 1500] 624 | 625 | commands = 40 626 | 627 | selector = {block: ?b, group: ?g, start: ?g} 628 | 629 | 630 | 631 | $.add(obj { 632 | OBJ_ID: 1765, 633 | X: sel_off[0] - 60, 634 | Y: sel_off[1] - 60, 635 | GROUPS: [selector.start, gs.hidden_group], 636 | }) 637 | 638 | $.add(obj { 639 | OBJ_ID: 1816, 640 | X: sel_off[0] - 60, 641 | Y: sel_off[1] - 60, 642 | BLOCK_A: selector.block, 643 | GROUPS: [selector.group, gs.hidden_group], 644 | DYNAMIC_BLOCK: true, 645 | }) 646 | 647 | is_running = counter(0) 648 | block_input = counter(0) 649 | 650 | 651 | reset_selector = ?b 652 | 653 | 654 | command_end = 665g 655 | command_end_block = 666g 656 | 657 | for i in ..3 { 658 | $.add(obj { 659 | OBJ_ID: 1816, 660 | X: sel_off[0] + commands * 60, 661 | Y: sel_off[1] - 30 * i, 662 | BLOCK_A: reset_selector, 663 | GROUPS: [gs.hidden_group, command_end_block], 664 | SCALING: 0.5, 665 | }) 666 | } 667 | reset_selector_func = !{ 668 | block_input += 1 669 | -> 952g.move_to(953g, 0.5, x_only = true, easing = EASE_IN_OUT) 670 | -> selector.group.move(-10, 0, 0.09, EASE_IN_OUT) 671 | wait(0.1) 672 | prog_selector.follow(selector.group, duration = 0.15, x_mod = 0.5) 673 | wait(0.01) 674 | -> selector.group.move_to(selector.start, 0.1, easing = EASE_IN_OUT) 675 | prog_selector.move(-5, 0, 0.1, easing = EASE_IN_OUT) 676 | block_input -= 1 677 | 678 | 679 | 680 | activate_button(195c, 196c) 681 | 682 | } 683 | 684 | y_spacing = 20 685 | 686 | 687 | // end 688 | $.add(obj { 689 | OBJ_ID: 1816, 690 | X: offset[0] + commands * spacing * 3, 691 | Y: offset[1], 692 | BLOCK_A: END, 693 | SCALING: 0.2, 694 | GROUPS: [gs.hidden_group, command_end] 695 | }) 696 | 697 | $.add(obj { 698 | OBJ_ID: 1816, 699 | X: offset[0] - spacing * 3, 700 | Y: offset[1], 701 | BLOCK_A: END, 702 | SCALING: 0.2, 703 | GROUPS: [gs.hidden_group] 704 | }) 705 | 706 | //run button 707 | 708 | // block that runs the thing 709 | run_block = ?b 710 | for j in ..10 { 711 | $.add(obj { 712 | OBJ_ID: 1816, 713 | X: sel_off[0] - 60, 714 | Y: sel_off[1] + 30 * j, 715 | BLOCK_A: run_block, 716 | SCALING: 0.5, 717 | GROUPS: gs.hidden_group 718 | }) 719 | } 720 | force_quit_taps = counter(56i) 721 | //force_quit_taps.display(90, 0) 722 | 723 | reader = @bfreader::new(offset, 6) 724 | prog_pointer.follow(reader.group) 725 | 726 | 727 | 728 | -> move_group_menu.move(-235, 100, 0) 729 | -> move_group_game.move(-235 -1100, 100, 0) 730 | -> move_group_tut.move(-235, -60, 0) 731 | menu_follow = !{ 732 | move_group_menu.follow(981g) 733 | } 734 | menu_follow! 735 | 736 | 737 | 738 | 739 | 740 | all = (arr) { 741 | for item in arr { 742 | if !@bool(item) { 743 | return false 744 | } 745 | } 746 | return true 747 | } 748 | 749 | // for i in 0..3 { 750 | // reader.std_out.win[i].display(60 + i * 30, 60) 751 | // } 752 | 753 | // for i in 0..4 { 754 | // reader.std_out.coin[i].display(60 + i * 30, 90) 755 | // } 756 | 757 | // for i in 0..4 { 758 | // reader.std_out.coin_coin[i].display(60 + i * 30, 120) 759 | // } 760 | 761 | 762 | 763 | for i in ..commands { 764 | sg = roll_groups[i] 765 | c = counter(0) 766 | //c.display(sel_off[0] + i * 60, sel_off[1] + 30) 767 | order = ["no\nop","+","-","<",">","[","]",".",",","end"] 768 | for c in ..order.length { 769 | off = [offset[0] + i * spacing * 3, offset[1] + c * y_spacing * 3] 770 | insert_bf_cmd(order[c], off, sg) 771 | } 772 | // block that increments the selector 773 | inc_block = ?b 774 | for j in ..19 { 775 | $.add(obj { 776 | OBJ_ID: 1816, 777 | X: sel_off[0] + i * 60, 778 | Y: sel_off[1] + j * 30, 779 | BLOCK_A: inc_block, 780 | SCALING: 1, 781 | GROUPS: gs.hidden_group 782 | }) 783 | } 784 | 785 | // block that checks for end 786 | end_check_block = ?b 787 | $.add(obj { 788 | OBJ_ID: 1816, 789 | X: sel_off[0] + i * 60 + 30, 790 | Y: sel_off[1] - 60, 791 | BLOCK_A: end_check_block, 792 | SCALING: 0.5, 793 | GROUPS: gs.hidden_group 794 | }) 795 | 796 | // block that resets the selector 797 | reset_block = ?b 798 | $.add(obj { 799 | OBJ_ID: 1816, 800 | X: offset[0] + i * spacing * 3, 801 | Y: offset[1] - order.length * y_spacing * 3 + 10, 802 | BLOCK_A: reset_block, 803 | DYNAMIC_BLOCK: true, 804 | SCALING: 1, 805 | GROUPS: gs.hidden_group 806 | }) 807 | 808 | collision(end_check_block, selector.block).on_triggered(!{c.item.if_is(EQUAL_TO, order.length - 1, reset_selector_func)}) 809 | 810 | collision(inc_block, selector.block).on_triggered(!{ 811 | sg.move(0, -y_spacing, 0) 812 | c += 1 813 | }) 814 | 815 | collision(NOOP, reset_block).on_triggered(!{ 816 | sg.move(0, y_spacing * order.length, 0) 817 | c -= order.length 818 | }) 819 | 820 | } 821 | 822 | collision(130b, 131b).on_triggered(!{ 823 | 952g.move(-20, 0, 0.3, easing = EASE_IN_OUT) 824 | }) 825 | 826 | collision(130b, 132b).on_triggered(!{ 827 | 952g.move(-60, 0, 0.3, easing = EASE_IN_OUT) 828 | }) 829 | 830 | 831 | collision(130b, 166b).on_triggered(!{ 832 | 952g.move(30, 0, 0.3, easing = EASE_IN_OUT) 833 | }) 834 | 835 | coin1 = 201g 836 | coin2 = 202g 837 | coin3 = 765g 838 | end_wall = 200g 839 | end_anim = 987g 840 | 841 | coin1.toggle_off() 842 | coin2.toggle_off() 843 | coin3.toggle_off() 844 | end_anim.toggle_off() 845 | 846 | 847 | 955g.toggle_off() 848 | 849 | // bg1 = 867g 850 | // bg2 = 868g 851 | //bg2.toggle_off() 852 | //-> bg2.move(-1000, 0, 0) //unload 853 | 854 | game_bg_target = 908g 855 | switch_game_bg = 909g 856 | 857 | random_affect = !{ 858 | supress_signal(0.2) 859 | -> if random_seed >= random_max - 1 { 860 | wait() 861 | random_seed -= random_max - 1 862 | } else { 863 | wait() 864 | random_seed += 1 865 | } 866 | 867 | -> if random_bg_seed >= bg_options - 1 { 868 | wait() 869 | random_bg_seed -= bg_options - 1 870 | } else { 871 | wait() 872 | random_bg_seed += 1 873 | } 874 | } 875 | 876 | while_loop(() => true, delay = 0.47, () { 877 | random_affect! 878 | }) 879 | 880 | let switch_to_bg = [] 881 | for bg in game_bgs { 882 | func = !{ 883 | for g in game_bgs { 884 | if g != bg { 885 | g[2].stop() 886 | g[0].toggle_off() 887 | } 888 | } 889 | wait() 890 | -> bg[1].move_to(game_bg_target) 891 | bg[2]! 892 | bg[0].toggle_on() 893 | } 894 | switch_to_bg.push(func) 895 | } 896 | 897 | 898 | $.extend_trigger_func(switch_game_bg, (){ 899 | option = [bg_option1, bg_option2][random_bg_seed.to_const(0..bg_options)] 900 | switch_to_bg[option.to_const(0..game_bgs.length)]! 901 | }) 902 | 903 | for g in game_bgs { 904 | g[0].follow(g[1]) 905 | g[0].toggle_off() 906 | $.extend_trigger_func(g[2], (){ 907 | g[1].follow(981g) 908 | g[0].follow(981g) 909 | }) 910 | } 911 | 912 | 913 | 914 | 915 | tut_text_colors = 300c..800c 916 | 917 | // challenge 0: run any program 918 | // challenge 1: output 10 919 | // challenge 2: output 40 no input 920 | // challenge 3: double input 921 | // challenge 4: add 2 inputs 922 | // challenge 5: compare 2 inputs 923 | 924 | 925 | // challenge ideas: 926 | // write b if input > 10, else write s 927 | // square input 928 | // get nth fibonachi number 929 | 930 | // coin 7: write "coin" using no input 931 | // coin 8: write "coin coin" using no input 932 | 933 | challenge_board = 203g 934 | challenge_board_color = 203c 935 | 936 | challenge_name_colors = 55c..65c 937 | challenge_desc_colors = (65c..101c) + (181c..186c) + (218c..300c) 938 | challenge_extra_info_colors = [186c, 188c] 939 | 940 | next_challenge = !{ 941 | challenge += 1 942 | 943 | -> challenge_board_color.pulse(81, 252, 95, fade_out = 0.5) 944 | -> 187c.pulse(0,0,0, fade_in = 0.4, hold = 0.2, fade_out = 0.6) 945 | -> 866g.move(-40, 0, 0.4, easing = EASE_IN_OUT) 946 | -> 865g.move(40, 0, 0.4, easing = EASE_IN_OUT) 947 | for i in ..challenge_name_colors.length { 948 | -> challenge_name_colors[i].pulse(0,0,0, fade_in = 0.4, hold = 0.1 + 0.06 * i) 949 | } 950 | for i in ..challenge_desc_colors.length { 951 | extra_delay = $.sin(i / 10) * 0.3 952 | -> challenge_desc_colors[i].pulse(0,0,0, fade_in = extra_delay + 0.1, hold = 2.0 + 0.03 * i - extra_delay, fade_out = 0.1) 953 | } 954 | 955 | for i in ..challenge_extra_info_colors.length { 956 | -> challenge_extra_info_colors[i].pulse(0,0,0, fade_in = 0.4, hold = 2.3 + i * 0.1, fade_out = 0.3) 957 | } 958 | 959 | wait(0.45) 960 | -> 866g.move(40, 0, 1.5, easing = EASE_IN) 961 | -> 865g.move(-40, 0, 1.5, easing = EASE_IN) 962 | -> challenge_board.move(-200, 0) 963 | 964 | -> if challenge == 6 { 965 | // limit commands 966 | -> command_end.move(-10 * 13, 0, 1, easing = EXPONENTIAL_OUT) 967 | -> command_end_block.move(-20 * 13, 0, 1, easing = EXPONENTIAL_OUT) 968 | } 969 | wait(3) 970 | reset_runs_in_a_row! 971 | -> if challenge == 4 { 972 | end_wall.toggle_off() 973 | end_anim.toggle_on() 974 | top_msg_board(1, [255, 255, 0]) 975 | } 976 | } 977 | 978 | reset_env = !{ 979 | for c in reader.cells { 980 | -> c.reset(speed = 1) 981 | } 982 | 983 | -> input_used -= input_used.to_const(1..3) 984 | 985 | -> reader.ptr.reset(speed = 1, for_each = (n) { cell_pointer.move(-10 * n, 0, 0.1, easing = EASE_IN_OUT) }) 986 | -> reader.num_out.reset(speed = 1) 987 | -> reader.group.move_to(reader.start_point, 0) 988 | -> 952g.move_to(953g, 0.5, x_only = true, easing = EASE_IN_OUT) 989 | -> cell_pointer.move_to(reader.start_point, 0.3) 990 | -> force_quit_taps -= force_quit_taps.to_const(1..4) 991 | -> reader.std_out.reset() 992 | 993 | 994 | 995 | } 996 | 997 | 998 | start = (){ 999 | 1000 | 1001 | 1002 | 1003 | 1004 | switch_game_bg! 1005 | 1006 | collision(reset_selector, selector.block).on_triggered(reset_selector_func) 1007 | 1008 | 1009 | touch().on_triggered(!{ 1010 | 1011 | if ended == 1 { 1012 | reset_env! 1013 | 1014 | bottom_msg_board_down() 1015 | wait(0.2) 1016 | activate_button(195c, null) 1017 | activate_button(192c, null) 1018 | 954g.toggle_on() //prog selector collision enable 1019 | 955g.toggle_off() 1020 | is_running -= 1 1021 | block_input -= 1 1022 | ended -= 1 1023 | 1024 | } else if is_running == 1 && reader.input != 1 { 1025 | force_quit_taps.item.if_is(SMALLER_THAN, 3, !{ 1026 | force_quit_taps += 1 1027 | }) 1028 | force_stop_layer.alpha(1, 0.5) 1029 | force_stop_layer.alpha(0, 2) 1030 | 1031 | } 1032 | }) 1033 | 1034 | force_quit_taps.item.count(3).on_triggered(force_stop) 1035 | 1036 | output_correct = () { 1037 | -> 217c.pulse(0, 255, 0, fade_out = 1) 1038 | -> 800c.pulse(0, 255, 0, fade_out = 1) 1039 | ended += 1 1040 | bottom_msg_board_up() 1041 | } 1042 | 1043 | output_correct_no_end = () { 1044 | -> 217c.pulse(69, 255, 187, fade_out = 0.5) 1045 | -> 800c.pulse(69, 255, 187, fade_out = 0.5) 1046 | } 1047 | 1048 | output_wrong = !{ 1049 | -> 217c.pulse(255, 0, 0, fade_out = 1) 1050 | -> 800c.pulse(255, 0, 0, fade_out = 1) 1051 | ended += 1 1052 | bottom_msg_board_up() 1053 | } 1054 | 1055 | collision(run_block, selector.block).on_triggered(!{ 1056 | is_running += 1 1057 | block_input += 1 1058 | 954g.toggle_off() //prog selector collision disable 1059 | 955g.toggle_on() 1060 | // reader.num_out.add(10) 1061 | // wait(0.1) 1062 | // reader.std_out.write(reader.num_out) 1063 | // wait(0.1) 1064 | 1065 | activate_button(null, 195c) 1066 | activate_button(null, 192c) 1067 | run = !{ 1068 | wait(0.1) 1069 | reader.group.move(10, 0, 0.05) 1070 | //-> BG.pulse(255, 0, 0, fade_out = 1) 1071 | 1072 | while_loop(()=> reader.end == 0 && force_quit_taps < 3, delay = 0.1, (){ 1073 | reader.interpret() 1074 | }) 1075 | 1076 | if force_quit_taps < 3 && ended == 0 { 1077 | wrong_out = !{ 1078 | output_wrong! 1079 | top_msg_board(0, [255, 0, 0]) 1080 | reset_runs_in_a_row! 1081 | } 1082 | //-> finished_color.set(255, 255, 255, 0) 1083 | -> if gamemode == 1 { 1084 | //challenges 1085 | -> if challenge == 0 { 1086 | call_with_delay(0.05, next_challenge) 1087 | bottom_msg_board_up() 1088 | ended += 1 1089 | } 1090 | 1091 | -> if challenge == 1 { 1092 | if reader.num_out == 10 { 1093 | call_with_delay(0.05, next_challenge) 1094 | output_correct() 1095 | } else { 1096 | 1097 | output_wrong! 1098 | } 1099 | } 1100 | 1101 | -> if input_used == 0 { 1102 | 1103 | 1104 | -> if challenge == 2 { 1105 | if reader.num_out == 40 { 1106 | call_with_delay(0.05, next_challenge) 1107 | output_correct() 1108 | } else { 1109 | output_wrong! 1110 | } 1111 | } 1112 | 1113 | challenge.item.if_is(EQUAL_TO, 3, wrong_out) 1114 | 1115 | challenge.item.if_is(EQUAL_TO, 4, wrong_out) 1116 | 1117 | challenge.item.if_is(EQUAL_TO, 5, wrong_out) 1118 | 1119 | // -> if challenge == 6 { 1120 | // if all(reader.std_out.win) { 1121 | // call_with_delay(0.05, next_challenge) 1122 | // output_correct() 1123 | // top_msg_board(2, [255, 255, 0]) 1124 | // } else { 1125 | // output_wrong! 1126 | // } 1127 | // } 1128 | 1129 | 1130 | -> if all(reader.std_out.coin) { 1131 | 1132 | -> if challenge == 6 { 1133 | coin1.toggle_on() 1134 | call_with_delay(0.05, next_challenge) 1135 | -> command_end.move(10 * 13, 2, 0, easing = EXPONENTIAL_IN) 1136 | -> command_end_block.move(20 * 13, 2, 0, easing = EXPONENTIAL_IN) 1137 | end_wall.toggle_off() 1138 | end_anim.toggle_on() 1139 | top_msg_board(2, [255, 255, 0]) 1140 | output_correct() 1141 | } 1142 | 1143 | -> if challenge == 7 { 1144 | if all(reader.std_out.coin_coin) { 1145 | coin2.toggle_on() 1146 | top_msg_board(2, [255, 255, 0]) 1147 | call_with_delay(0.05, next_challenge) 1148 | output_correct() 1149 | 1150 | } else { 1151 | output_wrong! 1152 | } 1153 | } 1154 | 1155 | } else { 1156 | -> if challenge == 6 { 1157 | output_wrong! 1158 | } 1159 | 1160 | -> if challenge == 7 { 1161 | output_wrong! 1162 | } 1163 | } 1164 | } else { 1165 | //input challenges 1166 | inc_runs_in_a_row = !{ 1167 | 1168 | successful_runs += 1 1169 | -> 962g.move(-200, 0, 0) 1170 | messages[0].set(0,0,0,0) 1171 | wait() 1172 | 1173 | -> if successful_runs == 3 { 1174 | -> if challenge == 5 { 1175 | wait(4) 1176 | top_msg_board(2, [255, 255, 0]) 1177 | coin3.toggle_on() 1178 | } 1179 | top_msg_board(0, [0, 255, 0]) 1180 | call_with_delay(0.05, next_challenge) 1181 | output_correct() 1182 | 1183 | } else { 1184 | top_msg_board(0, [255, 255, 255]) 1185 | output_correct_no_end() 1186 | reset_env! 1187 | call_with_delay(2, run) 1188 | } 1189 | } 1190 | 1191 | 1192 | 1193 | -> if input_used == 2 { 1194 | -> if challenge == 3 { 1195 | wrong_out! 1196 | } 1197 | 1198 | } 1199 | 1200 | -> if input_used == 1 { 1201 | -> if challenge == 4 { 1202 | wrong_out! 1203 | } 1204 | 1205 | -> if challenge == 5 { 1206 | wrong_out! 1207 | } 1208 | 1209 | } 1210 | 1211 | 1212 | 1213 | input_choice.to_const_enclosed(..random_max, (choice) { 1214 | -> if challenge == 3 { 1215 | -> if input_used == 1 { 1216 | -> if reader.num_out == auto_inputs[choice] * 2 { 1217 | inc_runs_in_a_row! 1218 | } else { 1219 | wrong_out! 1220 | } 1221 | } 1222 | 1223 | } 1224 | -> if choice != 0 { 1225 | wait() 1226 | input_choice -= choice 1227 | } 1228 | 1229 | -> if input_used == 2 { 1230 | 1231 | 1232 | input_choice2.to_const_enclosed(..random_max, (choice2) { 1233 | -> if challenge == 4 { 1234 | -> if reader.num_out == auto_inputs[choice] + auto_inputs2[choice2] { 1235 | inc_runs_in_a_row! 1236 | } else { 1237 | wrong_out! 1238 | } 1239 | } 1240 | 1241 | -> if challenge == 5 { 1242 | 1243 | -> if reader.num_out == abs(auto_inputs[choice] - auto_inputs2[choice2]) { 1244 | inc_runs_in_a_row! 1245 | } else { 1246 | wrong_out! 1247 | } 1248 | } 1249 | 1250 | -> if choice2 != 0 { 1251 | wait() 1252 | input_choice2 -= choice2 1253 | } 1254 | }) 1255 | } 1256 | }) 1257 | } 1258 | -> if challenge > 7 { 1259 | bottom_msg_board_up() 1260 | ended += 1 1261 | } 1262 | 1263 | 1264 | //wait(0.2) 1265 | } else { 1266 | bottom_msg_board_up() 1267 | ended += 1 1268 | } 1269 | } 1270 | } 1271 | 1272 | run! 1273 | //call_with_delay(999, run) 1274 | 1275 | 1276 | }) 1277 | 1278 | 1279 | } 1280 | 8c.set(0, 0, 0) 1281 | // start menu 1282 | gm_selector = 50g 1283 | menu_timer = 51g 1284 | gm_name_colors = 20c..29c 1285 | allow_menu_move = counter(0) 1286 | //212c 1287 | // follow group shit 1288 | game_switch = ?g //group that toggles the triggers that switch to ingame 1289 | tut_switch = ?g //group that toggles the triggers that switch to ingame 1290 | switch_spacing = 150 1291 | game_switch.toggle_off() 1292 | tut_switch.toggle_off() 1293 | 1294 | start_func = !{ 1295 | activate_button(195c, 191c) 1296 | 1297 | move_group_game.toggle_on() 1298 | game_switch.toggle_off() 1299 | 1300 | 1301 | 1302 | move_group_game.follow(981g) 1303 | -> 54c.set(0,0,0, 0.5, opacity = 0.0) 1304 | -> 900g.move(0, 33, 0) 1305 | -> 903g.move(0, -150, 0) 1306 | //-> BG.pulse(255, 0, 0, fade_out = 0.6) 1307 | 1308 | 1309 | 1310 | -> $.add( trigger{ 1311 | OBJ_ID: 1268, 1312 | SPAWN_DURATION: 3, 1313 | TARGET: !{ 1314 | top_msg_board(4, [112, 215, 255]) 1315 | }, 1316 | HIGH_DETAIL: true, 1317 | }) 1318 | 1319 | start() 1320 | } 1321 | 1322 | tut_text_anim_finished = counter(200i) 1323 | 1324 | for col in tut_text_colors { 1325 | -> col.set(255,0,0) 1326 | } 1327 | 1328 | tut_letters = !{ 1329 | activate_button(194c, 192c) 1330 | delta = 0.05 1331 | for i in 0..tut_text_colors.length { 1332 | -> tut_text_colors[i].pulse(0,0,0, fade_in = 0.4, hold = 0.2 + i * delta, exclusive = true) 1333 | } 1334 | 1335 | -> 197c.pulse(0,0,0, fade_in = 0.4, hold = 0.2 + 131 * delta, fade_out = 0.5, exclusive = true) 1336 | -> 198c.pulse(0,0,0, fade_in = 0.4, hold = 0.2 + 193 * delta, fade_out = 0.5, exclusive = true) 1337 | -> 199c.pulse(0,0,0, fade_in = 0.4, hold = 0.2 + 266 * delta, fade_out = 0.5, exclusive = true) 1338 | -> 200c.pulse(0,0,0, fade_in = 0.4, hold = 0.2 + 0 * delta, fade_out = 0.5, exclusive = true) 1339 | -> 211c.pulse(0,0,0, fade_in = 0.4, hold = 0.2 + 68 * delta, fade_out = 0.5, exclusive = true) 1340 | -> 213c.pulse(0,0,0, fade_in = 0.4, hold = 0.2 + 450 * delta, fade_out = 0.5, exclusive = true) 1341 | 1342 | //wait() 1343 | tut_text_anim_finished.item.if_is(EQUAL_TO, 1, !{ 1344 | tut_text_anim_finished -= 1 1345 | }) 1346 | wait(delta * 300) 1347 | tut_text_anim_finished.item.if_is(EQUAL_TO, 0, !{ 1348 | tut_text_anim_finished += 1 1349 | if tut_page_num < tut_pages - 1 { 1350 | activate_button(192c, 194c) 1351 | } else { 1352 | activate_button(212c, 194c) 1353 | } 1354 | }) 1355 | } 1356 | 1357 | tut_func = !{ 1358 | move_group_tut.toggle_on() 1359 | tut_switch.toggle_off() 1360 | -> 54c.set(0,0,0, 0.5, opacity = 0.0) 1361 | 1362 | move_group_tut.follow(981g) 1363 | //-> BG.pulse(255, 0, 0, fade_out = 0.6) 1364 | delta = 0.05 1365 | for i in 0..tut_text_colors.length { 1366 | -> tut_text_colors[i].pulse(0,0,0, fade_in = 0, hold = 0.2 + i * delta) 1367 | } 1368 | tut_text_anim_finished += 1 1369 | activate_button(null, 191c) 1370 | activate_button(192c, null) 1371 | 1372 | 1373 | 1374 | } 1375 | 1376 | 1377 | 1378 | for i in 1..669 { 1379 | //game 1380 | $.add( obj{ 1381 | X: switch_spacing * i - 2, 1382 | Y: -15, 1383 | OBJ_ID: 901, 1384 | TARGET: move_group_game, 1385 | MOVE_X: i * switch_spacing, 1386 | DURATION: 0, 1387 | GROUPS: game_switch, 1388 | }) 1389 | $.add( obj{ 1390 | X: switch_spacing * i, 1391 | Y: -45, 1392 | OBJ_ID: 1268, 1393 | SPAWN_DURATION: 0, 1394 | TARGET: start_func, 1395 | GROUPS: game_switch, 1396 | }) 1397 | 1398 | //tut 1399 | $.add( obj{ 1400 | X: switch_spacing * i - 2, 1401 | Y: -15 - 90, 1402 | OBJ_ID: 901, 1403 | TARGET: move_group_tut, 1404 | MOVE_X: i * switch_spacing, 1405 | DURATION: 0, 1406 | GROUPS: tut_switch, 1407 | }) 1408 | $.add( obj{ 1409 | X: switch_spacing * i, 1410 | Y: -45 - 90, 1411 | OBJ_ID: 1268, 1412 | SPAWN_DURATION: 0, 1413 | TARGET: tut_func, 1414 | GROUPS: tut_switch, 1415 | }) 1416 | } 1417 | // added this because compiler stupid and im too lazy to fix 1418 | -> call_with_delay(999, start_func) 1419 | -> call_with_delay(999, tut_func) 1420 | wait(2.5) 1421 | 1422 | 1423 | 1424 | 1425 | tut_transition = (dir){ 1426 | // seglen = tut_text_colors.length / 3 1427 | // part1 = 0..seglen 1428 | // part2 = part1.end..(part1.end + seglen) 1429 | // part3 = part2.end..(part2.end + seglen) 1430 | 1431 | tut_letters! 1432 | 1433 | 1434 | if dir != 0 { 1435 | wait(0.4) 1436 | tut_page.move(300 * -dir, 0, 0) 1437 | tut_page_num.add(dir) 1438 | } 1439 | } 1440 | 1441 | 1442 | right_button = 901g 1443 | left_button = 902g 1444 | 1445 | // tutorial animations 1446 | 1447 | inc_item = 501i 1448 | decr_item = 502i 1449 | decr_item.add(100) 1450 | 1451 | tut_arrow_items = 503i..508i 1452 | for i in ..tut_arrow_items.length { 1453 | tut_arrow_items[i].add(i) 1454 | } 1455 | 1456 | 1457 | gs.button_a().on_triggered(!{ 1458 | 1459 | -> right_button.move(0, -2, 0.1, easing = EASE_OUT, easing_rate = 4) 1460 | -> right_button.move(0, 2, 0.4, easing = EASE_IN_OUT, easing_rate = 3) 1461 | -> right_button.pulse(0, 0, 2, fade_out = 0.5, hsv = true) 1462 | random_affect! 1463 | 1464 | -> if started == 0 && allow_menu_move == 0 { 1465 | 1466 | wait() 1467 | allow_menu_move += 1 1468 | -> 53c.set(255, 255, 255) 1469 | -> 53c.set(0, 0, 0, 0.4) 1470 | -> 937g.move(10, 10, 0.5, easing = EXPONENTIAL_OUT) 1471 | -> 938g.move(-10, -10, 0.5, easing = EXPONENTIAL_OUT) 1472 | wait(0.3) 1473 | 54c.set(0,0,0, 0.5) 1474 | 1475 | started += 1 1476 | -> if gamemode == 0 { 1477 | //tutorial setup 1478 | move_group_menu.toggle_off() 1479 | menu_follow.start_group.stop() 1480 | //move_group.move(0, -160, 0) 1481 | tut_switch.toggle_on() 1482 | 1483 | -> while_loop(() => gamemode == 0, delay = 1, () { 1484 | inc_item.add(1) 1485 | -> if counter(decr_item) > 0 { 1486 | decr_item.add(-1) 1487 | } 1488 | 1489 | -> 939g.pulse(100, 2.0, 2.0, fade_out = 0.5, hsv = true) 1490 | pulse_ptr() 1491 | -> () { 1492 | 1493 | -> 932g.move(10, 0, 0.3) 1494 | -> 935g.move(-10, 0, 0.3) 1495 | -> 933g.move(-10, 0, 1) 1496 | -> 934g.move(10, 0, 1) 1497 | wait(1) 1498 | 1499 | 933g.move(10, 0, 0) 1500 | 932g.move(-10, 0, 0) 1501 | 934g.move(-10, 0, 0) 1502 | 935g.move(10, 0, 0) 1503 | for item in tut_arrow_items { 1504 | -> if counter(item) < 99 { 1505 | item.add(1) 1506 | } 1507 | } 1508 | }() 1509 | }) 1510 | 1511 | } 1512 | 1513 | 1514 | 1515 | 1516 | 1517 | 1518 | 1519 | -> if gamemode == 1 { 1520 | // challenge setup 1521 | 1522 | 1523 | move_group_menu.toggle_off() 1524 | menu_follow.start_group.stop() 1525 | 1526 | challenge -= 1 1527 | call_with_delay(0.05, next_challenge) 1528 | //move_group.move(-1100, 0, 0) 1529 | game_switch.toggle_on() 1530 | 1531 | 1532 | } 1533 | -> if gamemode == 2 { 1534 | // coins setup 1535 | 1536 | 1537 | move_group_menu.toggle_off() 1538 | menu_follow.start_group.stop() 1539 | first_coin_challenge = 6 1540 | -> 810c.set(0,0,0) 1541 | challenge += first_coin_challenge - 1 1542 | call_with_delay(0.05, next_challenge) 1543 | //move_group.move(-1100, 0, 0) 1544 | challenge_board.move(-200 * first_coin_challenge, 0) 1545 | wait() 1546 | gamemode -= 1 1547 | game_switch.toggle_on() 1548 | 1549 | 1550 | 1551 | } 1552 | 1553 | 1554 | -> if gamemode == 3 { 1555 | // sandbox setup 1556 | 1557 | 1558 | move_group_menu.toggle_off() 1559 | menu_follow.start_group.stop() 1560 | 1561 | //-> bg2.move(1000, 0, 0) //reload 1562 | //move_group.move(-1100, 0, 0) 1563 | game_switch.toggle_on() 1564 | 1565 | 1566 | 1567 | } 1568 | 1569 | 1570 | 1571 | } else { 1572 | 1573 | -> if gamemode == 0 { 1574 | 1575 | tut_page_num.item.if_is(EQUAL_TO, 1, !{ 1576 | activate_button(null, 193c) 1577 | }) 1578 | 1579 | tut_page_num.item.if_is(LARGER_THAN, 0, !{ 1580 | -> tut_transition(-1) 1581 | activate_button(null, 212c) 1582 | }) 1583 | 1584 | } else { 1585 | -> if block_input == 0 { 1586 | 1587 | selector.group.move(0, 20, 0) 1588 | wait(0.03) 1589 | selector.group.move(0, -20, 0) 1590 | } 1591 | } 1592 | } 1593 | }) 1594 | 1595 | gs.button_b().on_triggered(!{ 1596 | -> left_button.move(0, -2, 0.1, easing = EASE_OUT, easing_rate = 4) 1597 | -> left_button.move(0, 2, 0.4, easing = EASE_IN_OUT, easing_rate = 3) 1598 | -> left_button.pulse(0, 0, 2, fade_out = 0.5, hsv = true) 1599 | random_affect! 1600 | 1601 | -> if started == 0 && allow_menu_move == 0 { 1602 | -> 985g.move(0, -1500, 0) 1603 | -> 985g.move(0, 1500, 0.8) 1604 | -> 15c.set(0,0,0, 0.1) 1605 | wait() 1606 | allow_menu_move += 1 1607 | -> 978g.move(-80, 10, 0.5, easing = EASE_IN_OUT, easing_rate = 3.0) 1608 | -> 977g.move(-60, -10, 0.5, easing = EASE_IN_OUT, easing_rate = 3.0) 1609 | -> 7c.set(0, 0, 0, 0.4) 1610 | -> 8c.set(255, 255, 255, 0.4) 1611 | for i in ..gm_name_colors.length { 1612 | -> gm_name_colors[i].pulse(0,0,0, fade_in = 0.4, hold = 0.1 + 0.06 * i) 1613 | } 1614 | 1615 | wait(0.5) 1616 | -> 15c.set(255,255,255, 0) 1617 | allow_menu_move -= 1 1618 | -> if gamemode == 3 { 1619 | wait() 1620 | gamemode -= 3 1621 | gm_selector.move(600, 0, 0) 1622 | } else { 1623 | wait() 1624 | gamemode += 1 1625 | gm_selector.move(-200, 0, 0) 1626 | } 1627 | 1628 | 1629 | -> 978g.move(80, -10, 0) 1630 | -> 977g.move(60, 10, 0) 1631 | -> 8c.set(0, 0, 0) 1632 | -> 7c.set(255, 255, 255) 1633 | 1634 | } else { 1635 | -> if gamemode == 0 { 1636 | tut_text_anim_finished.item.if_is(EQUAL_TO, 0, !{ 1637 | tut_letters.start_group.stop() 1638 | if tut_page_num < tut_pages - 1 { 1639 | activate_button(192c, 194c) 1640 | } else { 1641 | activate_button(212c, 194c) 1642 | } 1643 | wait() 1644 | tut_text_anim_finished += 1 1645 | }) 1646 | tut_text_anim_finished.item.if_is(EQUAL_TO, 1, !{ 1647 | if tut_page_num < tut_pages - 1 { 1648 | activate_button(193c, null) 1649 | -> tut_transition(1) 1650 | } else { 1651 | //stop double tap 1652 | 1653 | 1654 | supress_signal_forever() 1655 | tut_page_num.add(1) 1656 | 54c.set(0,0,0, 0.5) 1657 | activate_button(null, 193c) 1658 | activate_button(192c, 212c) 1659 | gamemode += 1 1660 | 1661 | tut_func.start_group.stop() 1662 | move_group_tut.toggle_off() 1663 | 1664 | challenge -= 1 1665 | call_with_delay(0.05, next_challenge) 1666 | //move_group.move(-1100, 0, 0) 1667 | game_switch.toggle_on() 1668 | } 1669 | }) 1670 | 1671 | 1672 | } else { 1673 | 1674 | if block_input == 0 { 1675 | -> move_button.pulse(59, 144, 247, fade_out = 0.3) 1676 | selector.group.move(20, 0, 0.1) 1677 | prog_selector.move(10, 0, 0.1) 1678 | 1679 | //-> 905g.move(0, -150, 0) 1680 | activate_button(196c, 195c) 1681 | } 1682 | } 1683 | } 1684 | 1685 | }) 1686 | 1687 | // +++.[->+++++>+++<<]>.>.[->++<]<-.>>++.+. 1688 | 1689 | // +++.[->+++++>+++<<]>.>.<-. 1690 | // +++.++++++++++++.------.+++++. 1691 | 1692 | 1693 | -------------------------------------------------------------------------------- /brainfugd_pro.spwn: -------------------------------------------------------------------------------- 1 | RIGHT = ?b 2 | LEFT = ?b 3 | INCR = ?b 4 | DECR = ?b 5 | DOT = ?b 6 | INPUT = ?b 7 | OPEN = ?b //opening bracket 8 | CLOSE = ?b //closing bracket 9 | 10 | END = ?b //end of the program 11 | NOOP = ?b //NO OPERATION 12 | 13 | spacing = 10 14 | extract obj_props 15 | 16 | right_button = 901g 17 | left_button = 902g 18 | 19 | gs = { 20 | hidden_group: 976g, 21 | button_a: () { 22 | return collision(162b, 163b) 23 | }, 24 | button_b: () { 25 | return touch(dual_side = true) 26 | }, 27 | } 28 | 29 | abs = (num) { 30 | if num < 0 { 31 | return -num 32 | } else { 33 | return num 34 | } 35 | 36 | } 37 | import "text_display_pro.spwn" 38 | 39 | 40 | 41 | ended = counter(0) 42 | 43 | 44 | 45 | 46 | bc = [77, 93, 97] 47 | 48 | left_buttons = [193c, 195c, 191c, 196c, 803c] 49 | 50 | right_buttons = [192c, 194c, 802c, 212c] 51 | 52 | activate_button = (activate, deactivate) { 53 | 54 | let colors = [] 55 | 56 | 57 | 58 | if activate != null { 59 | if left_buttons.contains(activate) { 60 | colors = left_buttons 61 | } else { 62 | colors = right_buttons 63 | } 64 | for col in colors { 65 | if col == activate { 66 | -> col.set(bc[0], bc[1], bc[2], 0) 67 | } else { 68 | -> col.set(0, 0, 0, 0, blending = true) 69 | } 70 | } 71 | } else if deactivate != null { 72 | if left_buttons.contains(deactivate) { 73 | colors = left_buttons 74 | } else { 75 | colors = right_buttons 76 | } 77 | for col in colors { 78 | -> col.set(0, 0, 0, 0, blending = true) 79 | } 80 | } 81 | 82 | } 83 | 84 | 85 | type @bfreader 86 | layers = counter(600i) 87 | //layers.display(150, 300) 88 | cell_pointer = 20g 89 | input_layer = 21g 90 | 91 | prog_pointer = 23g 92 | prog_selector = 24g 93 | force_stop_layer = 25g 94 | input_layer.alpha(0) 95 | //finished_layer.alpha(0) 96 | force_stop_layer.alpha(0) 97 | 98 | message_board = 931g 99 | 100 | 101 | bottom_msg_board_up = (){ 102 | -> message_board.move(0, 10, 1, easing = EXPONENTIAL_OUT) 103 | -> 216c.set(255, 255, 255, 1) 104 | -> 942g.move(0, 30, 0.5, easing = EXPONENTIAL_OUT) 105 | } 106 | 107 | bottom_msg_board_down = (){ 108 | -> message_board.move(0, -10, 1, easing = EXPONENTIAL_IN) 109 | -> 216c.set(0, 0, 0, 1) 110 | -> 942g.move(0, -30, 0.5, easing = EXPONENTIAL_IN) 111 | } 112 | 113 | input_char = 26g 114 | 115 | move_button = 10c 116 | select_button = 11c 117 | 118 | input_inc_button = 12c 119 | input_done_button = 13c 120 | 121 | input_mode = counter() 122 | //input_mode.display(120, 30) 123 | //input_used.display(90, 30) 124 | 125 | prog_ptr_color = [94, 13, 13] 126 | 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 127 | 128 | pulse_ptr = (){ 129 | -> 972g.move(0, 1, 0.05, easing = EASE_IN) 130 | -> 973g.move(0, -1, 0.05, easing = EASE_IN) 131 | -> 974g.move(1, 0, 0.05, easing = EASE_IN) 132 | -> 975g.move(-1, 0, 0.05, easing = EASE_IN) 133 | 134 | -> 972g.move(0, -1, 0.2, easing = EASE_IN_OUT) 135 | -> 973g.move(0, 1, 0.2, easing = EASE_IN_OUT) 136 | -> 974g.move(-1, 0, 0.2, easing = EASE_IN_OUT) 137 | -> 975g.move(1, 0, 0.2, easing = EASE_IN_OUT) 138 | } 139 | 140 | // win_condition = "win" 141 | // coin_condition = "coin tu" 142 | 143 | mem_items = [62i, 54i, 63i, 64i, 58i, 55i, 65i, 60i, 59i, 66i] 144 | 145 | 146 | force_stop = !{ 147 | -> 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 148 | bottom_msg_board_up() 149 | 150 | //-> finished_color.set(255, 255, 255, 0) 151 | ended += 1 152 | } 153 | 154 | impl @bfreader { 155 | new: (script_offset: [@number], cell_count: @number) { 156 | 157 | std_out = @textdisplay::new([script_offset[0] + 1278, script_offset[1] - 66], 15) 158 | //$.print("hello") 159 | //-> BG.pulse(255, 0, 0, fade_out = 0.5) 160 | //-> std_out.write(counter(5)) 161 | 162 | 163 | 164 | block = ?b 165 | group = ?g 166 | $.add(obj { 167 | OBJ_ID: 1816, 168 | X: script_offset[0] - spacing * 3, 169 | Y: script_offset[1], 170 | GROUPS: [group, gs.hidden_group], 171 | BLOCK_A: block, 172 | SCALING: 0.5, 173 | DYNAMIC_BLOCK: true, 174 | }) 175 | // for b in [RIGHT,LEFT,INCR,DECR,DOT,OPEN,CLOSE] { 176 | // $.add(obj { 177 | // OBJ_ID: 1816, 178 | // X: script_offset[0] - spacing * 3, 179 | // Y: script_offset[1], 180 | // SCALING: 0.5, 181 | // BLOCK_A: b, 182 | // }) 183 | // } 184 | 185 | //start point 186 | start_point = ?g 187 | $.add(obj { 188 | OBJ_ID: 1765, 189 | X: script_offset[0] - spacing * 3, 190 | Y: script_offset[1], 191 | GROUPS: start_point 192 | }) 193 | 194 | 195 | // CREATE CELLS 196 | let cells = [] 197 | for i in ..cell_count { 198 | c = counter(mem_items[i]) 199 | cells.push(c) 200 | //c.display(script_offset[0] + i * 30 + 300, script_offset[1] + 690) 201 | } 202 | ptr = counter(0) 203 | //ptr.display(script_offset[0], script_offset[1] + 60) 204 | std_in = counter(85i) 205 | //std_in.display(script_offset[0], script_offset[1] - 90) 206 | 207 | 208 | 209 | num_out = counter(61i) 210 | num_out.display(script_offset[0], script_offset[1] + 210) 211 | out = @bfreader::{ 212 | group: group, 213 | right: counter(block.create_tracker_item(RIGHT)), 214 | left: counter(block.create_tracker_item(LEFT)), 215 | incr: counter(block.create_tracker_item(INCR)), 216 | dot: counter(block.create_tracker_item(DOT)), 217 | input: counter(block.create_tracker_item(INPUT)), 218 | decr: counter(block.create_tracker_item(DECR)), 219 | open: counter(block.create_tracker_item(OPEN)), 220 | close: counter(block.create_tracker_item(CLOSE)), 221 | end: counter(block.create_tracker_item(END)), 222 | noop: counter(block.create_tracker_item(NOOP)), 223 | std_out: std_out, 224 | num_out: num_out, 225 | std_in: std_in, 226 | ptr: ptr, 227 | cells: cells, 228 | start_point: start_point 229 | } 230 | 231 | 232 | return out 233 | }, 234 | currently_on: (self) { 235 | if self.right == 1 { 236 | return RIGHT 237 | } else if self.left == 1 { 238 | return LEFT 239 | } else if self.incr == 1 { 240 | return INCR 241 | } else if self.decr == 1 { 242 | return DECR 243 | } else if self.dot == 1 { 244 | return DOT 245 | } else if self.input == 1 { 246 | return INPUT 247 | } else if self.open == 1 { 248 | return OPEN 249 | } else if self.close == 1 { 250 | return CLOSE 251 | } else if self.noop == 1 { 252 | return NOOP 253 | } 254 | }, 255 | current_cell: (self) => self.cells[self.ptr.to_const(..self.cells.length)], 256 | interpret: (self) { 257 | 258 | ret = !{ 259 | supress_signal(0.05) 260 | -> self.group.move(spacing, 0, 0) 261 | -> return 262 | } 263 | 264 | fast_ret = !{ 265 | -> self.group.move(spacing, 0, 0) 266 | -> return 267 | } 268 | 269 | slow_ret = !{ 270 | supress_signal(0.1) 271 | wait(0.1) 272 | -> self.group.move(spacing, 0, 0) 273 | -> return 274 | } 275 | 276 | // slow_ret = !{ 277 | // supress_signal(0.06) 278 | // ret! 279 | // } 280 | 281 | current = self.currently_on() 282 | 283 | -> if current == RIGHT { 284 | 285 | if self.ptr == self.cells.length - 1 { 286 | wait() 287 | self.ptr -= self.cells.length - 1 288 | -> cell_pointer.move(-10 * (self.cells.length - 1),0, 0.1) 289 | ret! 290 | } else { 291 | wait() 292 | self.ptr += 1 293 | -> cell_pointer.move(10,0, 0.1) 294 | ret! 295 | } 296 | 297 | 298 | } 299 | -> if current == LEFT { 300 | if self.ptr == 0 { 301 | wait() 302 | self.ptr += self.cells.length - 1 303 | -> cell_pointer.move(10 * (self.cells.length - 1), 0, 0.1) 304 | ret! 305 | } else { 306 | wait() 307 | self.ptr -= 1 308 | -> cell_pointer.move(-10,0, 0.1) 309 | ret! 310 | } 311 | 312 | } 313 | -> if current == INCR { 314 | -> self.current_cell() += 1 315 | pulse_ptr() 316 | fast_ret! 317 | } 318 | -> if current == DECR { 319 | -> (){ 320 | cell = self.current_cell() 321 | //$.print(current) 322 | if cell > 0 { 323 | cell -= 1 324 | } 325 | }() 326 | pulse_ptr() 327 | fast_ret! 328 | } 329 | -> if current == DOT { 330 | 331 | () { 332 | self.num_out.reset(speed = 3) 333 | cell = self.current_cell() 334 | //wait() 335 | cell.copy_to([self.num_out], speed = 1) 336 | } () 337 | supress_signal(0.1) // DO NOT REMOVE VERY IMPORTANT APARENTLY 338 | // REQUIRED FOR TEXT TO WORK ON MOBILE FOR SOME REASON 339 | 340 | self.std_out.write(self.num_out, speed = 1) 341 | 342 | slow_ret! 343 | } 344 | -> if current == INPUT { 345 | //supress_signal(0.1) 346 | std_in = self.std_in 347 | -> input_layer.alpha(1, 0.5) 348 | 349 | 350 | 351 | done = !{ 352 | 353 | activate_button(null, 802c) 354 | activate_button(null, 803c) 355 | 356 | -> input_done_button.pulse(52, 247, 68, fade_out = 0.3) 357 | -> input_layer.alpha(0, 0.5) 358 | cell = self.current_cell() 359 | cell.reset(speed = 1) 360 | std_in.add_to([cell], speed = 1, for_each = (n){ input_char.move(100 * n, 0, 0) }) 361 | 362 | slow_ret! 363 | } 364 | 365 | 366 | 367 | activate_button(802c, null) 368 | activate_button(803c, null) 369 | input_mode += 1 370 | 371 | gs.button_a().on_triggered(!{ 372 | supress_signal(0.05) 373 | if input_mode == 1 { 374 | -> input_inc_button.pulse(59, 144, 247, fade_out = 0.3) 375 | std_in += 1 376 | input_char.move(-100, 0, 0) 377 | } 378 | }) 379 | gs.button_b().on_triggered(!{ 380 | -> if input_mode == 1 { 381 | input_mode -= 1 382 | done! 383 | } 384 | }) 385 | 386 | } 387 | -> if current == OPEN { 388 | move_to = !{ 389 | -> 45c.set(prog_ptr_color[0] * 0.3, prog_ptr_color[1] * 0.3, prog_ptr_color[2] * 0.3, blending = true) 390 | //move to corresponding ] 391 | //layers = counter(0) 392 | condition = () => !(layers == 0 && self.close == 1) 393 | //self.group.move(spacing, 0) 394 | 395 | while_loop(condition, delay = 0.03, (){ 396 | 397 | wait(0.02) 398 | -> if self.open == 1{ 399 | layers += 1 400 | } 401 | 402 | -> if self.close == 1 { 403 | layers -= 1 404 | } 405 | 406 | -> if self.end == 1 { 407 | 408 | force_stop! 409 | } else { 410 | wait(0.01) 411 | self.group.move(spacing, 0) 412 | return 413 | } 414 | 415 | 416 | }) 417 | -> 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 418 | ret! 419 | } 420 | if self.current_cell() == 0 { 421 | layers -= 1 422 | call_with_delay(0.05, move_to) 423 | } else { 424 | ret! 425 | } 426 | } 427 | -> if current == CLOSE { 428 | move_back = !{ 429 | -> 45c.set(prog_ptr_color[0] * 0.3, prog_ptr_color[1] * 0.3, prog_ptr_color[2] * 0.3, blending = true) 430 | //move back to corresponding [ 431 | //layers = counter(0) 432 | condition = ()=> !(layers == 0 && self.open == 1) 433 | //self.group.move(-spacing, 0) 434 | 435 | //wait() 436 | while_loop(condition, delay = 0.03, (){ 437 | wait(0.02) 438 | -> if self.close == 1 { 439 | layers += 1 440 | } 441 | 442 | -> if self.open == 1 { 443 | layers -= 1 444 | } 445 | -> if self.end == 1 { 446 | 447 | force_stop! 448 | } else { 449 | wait(0.01) 450 | self.group.move(-spacing, 0) 451 | return 452 | } 453 | }) 454 | -> 45c.set(prog_ptr_color[0], prog_ptr_color[1], prog_ptr_color[2], blending = true) 455 | ret! 456 | } 457 | if self.current_cell() != 0 { 458 | layers -= 1 459 | call_with_delay(0.05, move_back) 460 | } else { 461 | ret! 462 | } 463 | } 464 | -> if current == NOOP { 465 | fast_ret! 466 | } 467 | 468 | 469 | } 470 | } 471 | 472 | 473 | roll_groups = 70g..170g 474 | 475 | 476 | insert_bf_cmd = (ch: @string, offset: [@number], group: @group) { 477 | 478 | blockid = switch ch { 479 | case ">": RIGHT,//increment the data pointer (to point to the next cell to the right). 480 | case "<": LEFT, //decrement the data pointer (to point to the next cell to the left). 481 | case "+": INCR, //increment (increase by one) the byte at the data pointer. 482 | case "-": DECR, //decrement (decrease by one) the byte at the data pointer. 483 | case ".": DOT, //output the byte at the data pointer. 484 | case ",": INPUT,//accept one byte of input, storing its value in the byte at the data pointer. 485 | case "[": OPEN, 486 | case "]": CLOSE, 487 | case "end": END, 488 | case "no\nop": NOOP, 489 | 490 | } 491 | 492 | 493 | $.add(obj { 494 | OBJ_ID: 1816, 495 | X: offset[0], 496 | Y: offset[1], 497 | BLOCK_A: blockid, 498 | GROUPS: [group, gs.hidden_group], 499 | SCALING: 0.5, 500 | }) 501 | // let scale 502 | // let color 503 | // if ch.length == 1 { 504 | // scale = 0.8 505 | // } else { 506 | // scale = 0.3 507 | // } 508 | // if blockid == NOOP { 509 | // color = 2c 510 | // } else { 511 | // color = 40c 512 | // } 513 | // $.add(obj { 514 | // OBJ_ID: 914, 515 | // X: offset[0] + 41 * 30 - 1200, 516 | // Y: offset[1] - 8.6 * 30 - 600, 517 | // TEXT: $.b64encrypt(ch), 518 | // GROUPS: [group, 968g, move_group], 519 | // SCALING: scale, 520 | // COLOR: color, 521 | // EDITOR_LAYER_1: 3, 522 | // Z_LAYER: 1 523 | // }) 524 | } 525 | 526 | offset = [1500, 900] 527 | sel_off = [600, 1500] 528 | 529 | commands = 100 530 | 531 | selector = {block: ?b, group: ?g, start: ?g} 532 | 533 | 534 | 535 | $.add(obj { 536 | OBJ_ID: 1765, 537 | X: sel_off[0] - 60, 538 | Y: sel_off[1] - 60, 539 | GROUPS: [selector.start, gs.hidden_group], 540 | }) 541 | 542 | $.add(obj { 543 | OBJ_ID: 1816, 544 | X: sel_off[0] - 60, 545 | Y: sel_off[1] - 60, 546 | BLOCK_A: selector.block, 547 | GROUPS: [selector.group, gs.hidden_group], 548 | DYNAMIC_BLOCK: true, 549 | }) 550 | 551 | is_running = counter(0) 552 | block_input = counter(0) 553 | 554 | 555 | reset_selector = ?b 556 | 557 | 558 | 559 | 560 | 561 | for i in ..3 { 562 | $.add(obj { 563 | OBJ_ID: 1816, 564 | X: sel_off[0] + commands * 60, 565 | Y: sel_off[1] - 30 * i, 566 | BLOCK_A: reset_selector, 567 | GROUPS: [gs.hidden_group], 568 | SCALING: 0.5, 569 | }) 570 | } 571 | reset_selector_func = !{ 572 | block_input += 1 573 | -> 952g.move_to(953g, 0.5, x_only = true, easing = EASE_IN_OUT) 574 | -> selector.group.move(-10, 0, 0.09, EASE_IN_OUT) 575 | wait(0.1) 576 | prog_selector.follow(selector.group, duration = 0.15, x_mod = 0.5) 577 | wait(0.01) 578 | -> selector.group.move_to(selector.start, 0.1, easing = EASE_IN_OUT) 579 | prog_selector.move(-5, 0, 0.1, easing = EASE_IN_OUT) 580 | block_input -= 1 581 | 582 | 583 | 584 | activate_button(195c, 196c) 585 | 586 | } 587 | 588 | y_spacing = 20 589 | 590 | 591 | // end 592 | $.add(obj { 593 | OBJ_ID: 1816, 594 | X: offset[0] + commands * spacing * 3, 595 | Y: offset[1], 596 | BLOCK_A: END, 597 | SCALING: 0.2, 598 | GROUPS: [gs.hidden_group] 599 | }) 600 | 601 | $.add(obj { 602 | OBJ_ID: 1816, 603 | X: offset[0] - spacing * 3, 604 | Y: offset[1], 605 | BLOCK_A: END, 606 | SCALING: 0.2, 607 | GROUPS: [gs.hidden_group] 608 | }) 609 | 610 | //run button 611 | 612 | // block that runs the thing 613 | run_block = ?b 614 | $.add(obj { 615 | OBJ_ID: 1816, 616 | X: sel_off[0] - 60, 617 | Y: sel_off[1], 618 | BLOCK_A: run_block, 619 | SCALING: 0.5, 620 | GROUPS: gs.hidden_group 621 | }) 622 | force_quit_taps = counter(56i) 623 | //force_quit_taps.display(90, 0) 624 | 625 | reader = @bfreader::new(offset, 8) 626 | prog_pointer.follow(reader.group) 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | // for i in 0..3 { 637 | // reader.std_out.win[i].display(60 + i * 30, 60) 638 | // } 639 | 640 | // for i in 0..4 { 641 | // reader.std_out.coin[i].display(60 + i * 30, 90) 642 | // } 643 | 644 | // for i in 0..4 { 645 | // reader.std_out.coin_coin[i].display(60 + i * 30, 120) 646 | // } 647 | 648 | 649 | 650 | for i in ..commands { 651 | sg = roll_groups[i] 652 | c = counter(0) 653 | //c.display(sel_off[0] + i * 60, sel_off[1] + 30) 654 | order = ["no\nop","+","-","<",">","[","]",".",",","end"] 655 | for c in ..order.length { 656 | off = [offset[0] + i * spacing * 3, offset[1] + c * y_spacing * 3] 657 | insert_bf_cmd(order[c], off, sg) 658 | } 659 | // block that increments the selector 660 | inc_block = ?b 661 | $.add(obj { 662 | OBJ_ID: 1816, 663 | X: sel_off[0] + i * 60, 664 | Y: sel_off[1], 665 | BLOCK_A: inc_block, 666 | SCALING: 0.5, 667 | GROUPS: gs.hidden_group 668 | }) 669 | 670 | // block that checks for end 671 | end_check_block = ?b 672 | $.add(obj { 673 | OBJ_ID: 1816, 674 | X: sel_off[0] + i * 60 + 30, 675 | Y: sel_off[1] - 60, 676 | BLOCK_A: end_check_block, 677 | SCALING: 0.5, 678 | GROUPS: gs.hidden_group 679 | }) 680 | 681 | // block that resets the selector 682 | reset_block = ?b 683 | $.add(obj { 684 | OBJ_ID: 1816, 685 | X: offset[0] + i * spacing * 3, 686 | Y: offset[1] - order.length * y_spacing * 3 + 10, 687 | BLOCK_A: reset_block, 688 | DYNAMIC_BLOCK: true, 689 | SCALING: 1, 690 | GROUPS: gs.hidden_group 691 | }) 692 | 693 | collision(end_check_block, selector.block).on_triggered(!{c.item.if_is(EQUAL_TO, order.length - 1, reset_selector_func)}) 694 | 695 | collision(inc_block, selector.block).on_triggered(!{ 696 | sg.move(0, -y_spacing, 0) 697 | c += 1 698 | }) 699 | 700 | collision(NOOP, reset_block).on_triggered(!{ 701 | sg.move(0, y_spacing * order.length, 0) 702 | c -= order.length 703 | }) 704 | 705 | } 706 | 707 | collision(130b, 131b).on_triggered(!{ 708 | 952g.move(-20, 0, 0.3, easing = EASE_IN_OUT) 709 | }) 710 | 711 | collision(130b, 132b).on_triggered(!{ 712 | 952g.move(-60, 0, 0.3, easing = EASE_IN_OUT) 713 | }) 714 | 715 | 716 | collision(130b, 166b).on_triggered(!{ 717 | 952g.move(30, 0, 0.3, easing = EASE_IN_OUT) 718 | }) 719 | 720 | 721 | 722 | 955g.toggle_off() 723 | 724 | // bg1 = 867g 725 | // bg2 = 868g 726 | //bg2.toggle_off() 727 | //-> bg2.move(-1000, 0, 0) //unload 728 | 729 | 730 | // challenge 0: run any program 731 | // challenge 1: output 10 732 | // challenge 2: output 40 no input 733 | // challenge 3: double input 734 | // challenge 4: add 2 inputs 735 | // challenge 5: compare 2 inputs 736 | 737 | 738 | // challenge ideas: 739 | // write b if input > 10, else write s 740 | // square input 741 | // get nth fibonachi number 742 | 743 | // coin 7: write "coin" using no input 744 | // coin 8: write "coin coin" using no input 745 | 746 | 747 | 748 | 749 | 750 | reset_env = !{ 751 | for c in reader.cells { 752 | -> c.reset(speed = 3) 753 | } 754 | 755 | -> reader.ptr.reset(speed = 3, for_each = (n) { cell_pointer.move(-10 * n, 0, 0.1, easing = EASE_IN_OUT) }) 756 | -> reader.num_out.reset(speed = 3) 757 | -> reader.group.move_to(reader.start_point, 0) 758 | -> 952g.move_to(953g, 0.5, x_only = true, easing = EASE_IN_OUT) 759 | -> cell_pointer.move_to(reader.start_point, 0.3) 760 | -> force_quit_taps -= force_quit_taps.to_const(1..4) 761 | -> reader.std_out.reset() 762 | } 763 | 764 | 765 | start = (){ 766 | 767 | collision(reset_selector, selector.block).on_triggered(reset_selector_func) 768 | 769 | 770 | touch().on_triggered(!{ 771 | 772 | if ended == 1 { 773 | reset_env! 774 | 775 | bottom_msg_board_down() 776 | wait(0.2) 777 | activate_button(195c, null) 778 | activate_button(192c, null) 779 | 954g.toggle_on() //prog selector collision enable 780 | 955g.toggle_off() 781 | is_running -= 1 782 | block_input -= 1 783 | ended -= 1 784 | 785 | } else if is_running == 1 && reader.input != 1 { 786 | force_quit_taps.item.if_is(SMALLER_THAN, 3, !{ 787 | force_quit_taps += 1 788 | }) 789 | force_stop_layer.alpha(1, 0.5) 790 | force_stop_layer.alpha(0, 2) 791 | 792 | } 793 | }) 794 | 795 | force_quit_taps.item.count(3).on_triggered(force_stop) 796 | 797 | 798 | 799 | collision(run_block, selector.block).on_triggered(!{ 800 | is_running += 1 801 | block_input += 1 802 | 954g.toggle_off() //prog selector collision disable 803 | 955g.toggle_on() 804 | // reader.num_out.add(10) 805 | // wait(0.1) 806 | // reader.std_out.write(reader.num_out) 807 | // wait(0.1) 808 | 809 | activate_button(null, 195c) 810 | activate_button(null, 192c) 811 | run = !{ 812 | wait(0.1) 813 | reader.group.move(10, 0, 0.05) 814 | //-> BG.pulse(255, 0, 0, fade_out = 1) 815 | 816 | while_loop(()=> reader.end == 0 && force_quit_taps < 3, delay = 0.1, (){ 817 | reader.interpret() 818 | }) 819 | 820 | if force_quit_taps < 3 && ended == 0 { 821 | //-> finished_color.set(255, 255, 255, 0) 822 | bottom_msg_board_up() 823 | ended += 1 824 | } 825 | } 826 | 827 | run! 828 | //call_with_delay(999, run) 829 | 830 | 831 | }) 832 | } 833 | 8c.set(0, 0, 0) 834 | 835 | 836 | 837 | wait(2.5) 838 | 839 | start() 840 | 841 | 842 | gs.button_a().on_triggered(!{ 843 | supress_signal(0.1) 844 | -> right_button.move(0, -2, 0.1, easing = EASE_OUT, easing_rate = 4) 845 | -> right_button.move(0, 2, 0.4, easing = EASE_IN_OUT, easing_rate = 3) 846 | -> right_button.pulse(0, 0, 2, fade_out = 0.5, hsv = true) 847 | 848 | 849 | 850 | if block_input == 0 { 851 | -> select_button.pulse(59, 144, 247, fade_out = 0.3) 852 | -> selector.group.move(0, 30, 0.05, easing = EASE_OUT, easing_rate = 10) 853 | -> selector.group.move(0, -30, 0.05, easing = EASE_IN, easing_rate = 10) 854 | } 855 | 856 | 857 | }) 858 | 859 | gs.button_b().on_triggered(!{ 860 | -> left_button.move(0, -2, 0.1, easing = EASE_OUT, easing_rate = 4) 861 | -> left_button.move(0, 2, 0.4, easing = EASE_IN_OUT, easing_rate = 3) 862 | -> left_button.pulse(0, 0, 2, fade_out = 0.5, hsv = true) 863 | 864 | supress_signal(0.1) 865 | 866 | 867 | 868 | if block_input == 0 { 869 | -> move_button.pulse(59, 144, 247, fade_out = 0.3) 870 | selector.group.move(20, 0, 0.1) 871 | prog_selector.move(10, 0, 0.1) 872 | 873 | //-> 905g.move(0, -150, 0) 874 | activate_button(196c, 195c) 875 | } 876 | 877 | 878 | }) 879 | 880 | // +++.[->+++++>+++<<]>.>.[->++<]<-.>>++.+. 881 | 882 | // +++.[->+++++>+++<<]>.>.<-. 883 | // +++.++++++++++++.------.+++++. 884 | 885 | 886 | -------------------------------------------------------------------------------- /brainfugd_tutorial.txt: -------------------------------------------------------------------------------- 1 | INTRODUCTION: 2 | 3 | Your goal in this game is to create programs that fulfill certain tasks. 4 | 5 | Your programs have access to a memory containing six numbers, each in a box called a cell. 6 | The cell with a line under it is the currently selected cell. This underline is called the "cell selector". 7 | 8 | A program is a list of commands, which will be done one by one in order when the program is running. 9 | There are 8 different commands you can use: 10 | 11 | + Adds 1 to the number in the currently selected cell 12 | - Subtracts 1 from the number in the currently selected cell 13 | > Moves the cell selector one cell to the right 14 | < Moves the cell selector one cell to the left 15 | . Outputs the number in the current cell, and also the corresponding letter in the alphabet 16 | , Takes one number as input from the player and puts that number in the currently selected cell 17 | 18 | 19 | BRACKETS: 20 | 21 | The last two commands you can use are [ and ]. All the commands between a [ and a ] will be repeated over and over until the selected cell's number is 0. This can be done by having a number larger than 0 in the selected cell, and then decreasing it with - until it reaches 0. If it is 0 to begin with, the commands inside get skipped, and if it never reaches 0, the commands will repeat forever. 22 | 23 | EXAMPLES: 24 | 25 | +++. 26 | This program adds 3 to the first cell and then outputs the 3 (and also the letter C). 27 | 28 | +>+>+ 29 | This program sets the 3 first cells in the memory to 1. 30 | 31 | +++[-] 32 | This program sets the current cell to 3 and then subtracts 1 again and again until the cell is 0. 33 | 34 | +++[->++<] 35 | This program adds 3 to the first cell, and then subtracts 1 from the first cell and adds 2 to the second cell until the first cell is 0, and the second cell is 6. Notice how this essentially multiplies 3 by 2. 36 | 37 | 38 | 39 | Welcome to Brainfugd## 40 | 41 | A programming language for your GMD system. 42 | ### 43 | Spu7Nix systems INC## [c] 2021 44 | ~Memory 45 | ## 46 | Your goal in this game is to create 47 | programs that fulfill certain tasks. 48 | ## 49 | Your programs have access to a memory containing 50 | six numbers,# each in a box called a cell.## 51 | The cell with a line under it is the currently 52 | selected cell.## This underline is called the 53 | "cell selector". 54 | ~Commands 55 | ## 56 | A program is a list of commands,# which will be 57 | done one by one in order when the program 58 | is running. 59 | ## 60 | There are 8 different commands you can use: 61 | ## 62 | +## Adds 1 to the number in the current cell 63 | ## 64 | -## Subtracts 1 from the number in the current cell 65 | ## 66 | [more on the next page] 67 | ~>## Moves the cell selector one cell to the right 68 | # 69 | <## Moves the cell selector one cell to the left 70 | # 71 | .## Outputs the number in the current cell,# 72 | and also the corresponding letter in the alphabet 73 | # 74 | ,## Takes one number as input from the player and 75 | puts that number in the currently selected cell 76 | ## 77 | [more on the next page] 78 | ~Brackets 79 | ## 80 | The last two commands you can use are [ and ].## 81 | All the commands between a [ and a ] will be 82 | repeated over and over until the selected cell's 83 | number is 0. ##This can be done by having a number 84 | larger than 0 in the selected cell, #and then 85 | decreasing it with - until it reaches 0. #If it is 86 | 0 to begin with,# the commands inside get skipped,# 87 | and if it never reaches 0,# the commands will 88 | repeat forever. 89 | ~Examples 90 | ## 91 | +++.## 92 | This program adds 3 to the first cell and then 93 | outputs the 3 (and also the letter C). 94 | ## 95 | +>+>+## 96 | This program sets the 3 first cells in the 97 | memory to 1. 98 | ## 99 | [more on the next page] 100 | ~+++[-]## 101 | This program sets the current cell to 3# and 102 | then subtracts 1 again and again until 103 | the cell is 0. 104 | ## 105 | +++[->++<]## 106 | This program adds 3 to the first cell,# 107 | and then subtracts 1 from the first cell# and 108 | adds 2 to the second cell# until the first cell 109 | is 0,# and the second cell is 6.## Notice how this 110 | essentially multiplies 3 by 2. 111 | ~Practical 112 | ## 113 | Complete challenge 5 to unlock level completion## 114 | Complete the coin challenges for coin 1 and 2## 115 | Complete challenge 7 for coin 3## 116 | ## 117 | In challenges that depend on inputs the input 118 | will be provided automatically when the program 119 | is running# to avoid cheating.## You need 3 successful 120 | runs in a row to complete such a challenge. -------------------------------------------------------------------------------- /text_display.spwn: -------------------------------------------------------------------------------- 1 | type @textdisplay 2 | spacing = 0.6 * 30 3 | y_spacing = 20 4 | impl @textdisplay { 5 | new: (offset: [@number], letters: @number) { 6 | extract obj_props 7 | order = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 8 | writer = ?b 9 | writer_group = ?g 10 | let list = [] 11 | // I N C O 12 | wincon = [?b, ?b, ?b, ?b] 13 | let checkers = [] 14 | //WINCO 15 | for i in ..letters { 16 | 17 | group = ?g 18 | block = ?b 19 | 20 | default_pos = ?g 21 | group.alpha(0) 22 | default_pos.alpha(0) 23 | follow_group = (500g..510g)[i] 24 | 25 | // space 26 | // $.add(obj { 27 | // OBJ_ID: 1816, 28 | // X: offset[0] + i * spacing, 29 | // Y: offset[1], 30 | // GROUPS: follow_group, 31 | // BLOCK_A: wincon[6], 32 | // SCALING: 0.7, 33 | // }) 34 | 35 | 36 | check_block = ?b 37 | checkers.push(check_block) 38 | 39 | $.add(obj { 40 | OBJ_ID: 1816, 41 | X: offset[0] + i * spacing - 12, 42 | Y: offset[1], 43 | //GROUPS: follow_group, 44 | BLOCK_A: check_block, 45 | DYNAMIC_BLOCK: true, 46 | SCALING: 0.2, 47 | }) 48 | 49 | for ch in ..order.length { 50 | $.add(obj { 51 | OBJ_ID: 914, 52 | X: offset[0] + i * spacing + (ch + 1) * spacing * letters, 53 | Y: offset[1], 54 | TEXT: $.b64encode(order[ch]), 55 | GROUPS: follow_group, 56 | SCALING: 0.7, 57 | }) 58 | 59 | cblock = switch order[ch] { 60 | case "I": wincon[0], 61 | case "N": wincon[1], 62 | case "C": wincon[2], 63 | case "O": wincon[3], 64 | else: null 65 | } 66 | //$.print(order[ch], cblock) 67 | if cblock != null { 68 | 69 | 70 | $.add(obj { 71 | OBJ_ID: 1816, 72 | X: offset[0] + i * spacing + (ch + 1) * spacing * letters, 73 | Y: offset[1], 74 | GROUPS: follow_group, 75 | BLOCK_A: cblock, 76 | SCALING: 0.3, 77 | }) 78 | } 79 | } 80 | $.add(obj { 81 | OBJ_ID: 1816, 82 | X: offset[0], 83 | Y: offset[1] + i * y_spacing * 3 + 30 + y_spacing * 3, 84 | BLOCK_A: block, 85 | SCALING: 0.6, 86 | GROUPS: follow_group, 87 | }) 88 | 89 | lock = !{ 90 | group.follow(writer_group) 91 | follow_group.follow(writer_group) 92 | -> follow_group.pulse(0,0,0, hold = 0.05, fade_out = 0.15) 93 | } 94 | 95 | collision(block, writer).on_triggered(lock) 96 | 97 | $.add(obj { 98 | OBJ_ID: 1765, 99 | X: offset[0] + i * spacing, 100 | Y: offset[1], 101 | GROUPS: group, 102 | }) 103 | $.add(obj { 104 | OBJ_ID: 1765, 105 | X: offset[0] + i * spacing, 106 | Y: offset[1], 107 | GROUPS: default_pos, 108 | }) 109 | 110 | -> follow_group.follow(group) 111 | 112 | list.push({ 113 | group, 114 | default_pos, 115 | lock, 116 | follow_group, 117 | }) 118 | 119 | } 120 | 121 | //writer 122 | $.add(obj { 123 | OBJ_ID: 1816, 124 | X: offset[0] + 30, 125 | Y: offset[1] + 30, 126 | BLOCK_A: writer, 127 | GROUPS: writer_group, 128 | DYNAMIC_BLOCK: true, 129 | }) 130 | 131 | writer_default = ?g 132 | $.add(obj { 133 | OBJ_ID: 1765, 134 | X: offset[0] + 30, 135 | Y: offset[1] + 30, 136 | GROUPS: writer_default, 137 | }) 138 | let coin = [] 139 | let coin_coin = [] 140 | for i in 0..9 { 141 | if i < 4 { 142 | c1 = counter(wincon[[2, 3, 0, 1][i]].create_tracker_item(checkers[i])) 143 | coin.push(c1) 144 | } else { 145 | if i > 4 { 146 | coin_coin.push(counter(wincon[[2, 3, 0, 1][i - 5]].create_tracker_item(checkers[i]))) 147 | } 148 | } 149 | } 150 | 151 | return @textdisplay::{list, writer: writer_group, writer_default, letters, coin, coin_coin} 152 | }, 153 | write: (self, letter: @counter, speed = 3) { 154 | // temp = counter() 155 | // read_counter = () { 156 | // read = !{ 157 | // mini_read = (num){ 158 | // letter.item.if_is(LARGER_THAN, num - 1, !{ 159 | // letter.add(-num) 160 | // temp.add(num) 161 | // self.writer.move(-(spacing / 3) * self.letters * num, 0) 162 | // call_with_delay(@epsilon::{}, read) 163 | // }) 164 | // } 165 | 166 | // for i in 0..speed { 167 | // mini_read(3^i) 168 | // } 169 | // letter.item.if_is(EQUAL_TO, 0, !{ 170 | // wait() 171 | // if speed > 1 { supress_signal(0.1) } 172 | // -> return 173 | // }) 174 | // } 175 | // read! 176 | // } 177 | 178 | self.writer.move(0, y_spacing, 0) 179 | -> if letter < 27 { 180 | -> self.writer.move(-5, 0, 0.2, easing = EXPONENTIAL_OUT) 181 | wait(0.05) 182 | // read_counter() 183 | // temp.add_to([letter], speed=speed) 184 | self.writer.move(-(spacing / 3) * self.letters * letter.to_const(..27), 0) 185 | wait(0.2) 186 | for l in self.list { 187 | l.lock.start_group.stop() 188 | } 189 | wait(0.05) 190 | self.writer.move_to(self.writer_default, x_only = true) 191 | } 192 | 193 | }, 194 | 195 | reset: (self) { 196 | 197 | for letter in self.list { 198 | -> letter.follow_group.pulse(0,0,0, fade_in = 0.3, hold = 0.5) 199 | } 200 | wait(0.3) 201 | 202 | self.writer.move_to(self.writer_default) 203 | for letter in self.list { 204 | letter.group.move_to(letter.default_pos) 205 | } 206 | } 207 | } -------------------------------------------------------------------------------- /text_display_pro.spwn: -------------------------------------------------------------------------------- 1 | type @textdisplay 2 | spacing = 0.6 * 30 3 | y_spacing = 20 4 | impl @textdisplay { 5 | new: (offset: [@number], letters: @number) { 6 | extract obj_props 7 | order = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 8 | writer = ?b 9 | writer_group = ?g 10 | list = [] 11 | // I N C O 12 | 13 | 14 | //WINCO 15 | for i in ..letters { 16 | 17 | group = ?g 18 | block = ?b 19 | 20 | default_pos = ?g 21 | group.alpha(0) 22 | default_pos.alpha(0) 23 | follow_group = (500g..515g)[i] 24 | 25 | // space 26 | // $.add(obj { 27 | // OBJ_ID: 1816, 28 | // X: offset[0] + i * spacing, 29 | // Y: offset[1], 30 | // GROUPS: follow_group, 31 | // BLOCK_A: wincon[6], 32 | // SCALING: 0.7, 33 | // }) 34 | 35 | for ch in ..order.length { 36 | $.add(obj { 37 | OBJ_ID: 914, 38 | X: offset[0] + i * spacing + (ch + 1) * spacing * letters, 39 | Y: offset[1], 40 | TEXT: $.b64encrypt(order[ch]), 41 | GROUPS: follow_group, 42 | SCALING: 0.7, 43 | }) 44 | } 45 | $.add(obj { 46 | OBJ_ID: 1816, 47 | X: offset[0], 48 | Y: offset[1] + i * y_spacing * 3 + 30 + y_spacing * 3, 49 | BLOCK_A: block, 50 | SCALING: 0.6, 51 | GROUPS: follow_group, 52 | }) 53 | 54 | lock = !{ 55 | group.follow(writer_group) 56 | follow_group.follow(writer_group) 57 | -> follow_group.pulse(0,0,0, hold = 0.05, fade_out = 0.15) 58 | } 59 | 60 | collision(block, writer).on_triggered(lock) 61 | 62 | $.add(obj { 63 | OBJ_ID: 1765, 64 | X: offset[0] + i * spacing, 65 | Y: offset[1], 66 | GROUPS: group, 67 | }) 68 | $.add(obj { 69 | OBJ_ID: 1765, 70 | X: offset[0] + i * spacing, 71 | Y: offset[1], 72 | GROUPS: default_pos, 73 | }) 74 | 75 | -> follow_group.follow(group) 76 | 77 | list.push({ 78 | group, 79 | default_pos, 80 | lock, 81 | follow_group, 82 | }) 83 | 84 | } 85 | 86 | //writer 87 | $.add(obj { 88 | OBJ_ID: 1816, 89 | X: offset[0] + 30, 90 | Y: offset[1] + 30, 91 | BLOCK_A: writer, 92 | GROUPS: writer_group, 93 | DYNAMIC_BLOCK: true, 94 | }) 95 | 96 | writer_default = ?g 97 | $.add(obj { 98 | OBJ_ID: 1765, 99 | X: offset[0] + 30, 100 | Y: offset[1] + 30, 101 | GROUPS: writer_default, 102 | }) 103 | 104 | 105 | return @textdisplay::{list, writer: writer_group, writer_default, letters} 106 | }, 107 | write: (self, letter: @counter, speed = 3) { 108 | // temp = counter() 109 | // read_counter = () { 110 | // read = !{ 111 | // mini_read = (num){ 112 | // letter.item.if_is(LARGER_THAN, num - 1, !{ 113 | // letter.add(-num) 114 | // temp.add(num) 115 | // self.writer.move(-(spacing / 3) * self.letters * num, 0) 116 | // call_with_delay(@epsilon::{}, read) 117 | // }) 118 | // } 119 | 120 | // for i in 0..speed { 121 | // mini_read(3^i) 122 | // } 123 | // letter.item.if_is(EQUAL_TO, 0, !{ 124 | // wait() 125 | // if speed > 1 { supress_signal(0.1) } 126 | // -> return 127 | // }) 128 | // } 129 | // read! 130 | // } 131 | 132 | self.writer.move(0, y_spacing, 0) 133 | -> if letter < 27 { 134 | -> self.writer.move(-5, 0, 0.2, easing = EXPONENTIAL_OUT) 135 | wait(0.05) 136 | // read_counter() 137 | // temp.add_to([letter], speed=speed) 138 | self.writer.move(-(spacing / 3) * self.letters * letter.to_const(..27), 0) 139 | wait(0.2) 140 | for l in self.list { 141 | l.lock.start_group.stop() 142 | } 143 | wait(0.05) 144 | self.writer.move_to(self.writer_default, x_only = true) 145 | } 146 | 147 | }, 148 | 149 | reset: (self) { 150 | 151 | for letter in self.list { 152 | -> letter.follow_group.pulse(0,0,0, fade_in = 0.3, hold = 0.5) 153 | } 154 | wait(0.3) 155 | 156 | self.writer.move_to(self.writer_default) 157 | for letter in self.list { 158 | letter.group.move_to(letter.default_pos) 159 | } 160 | } 161 | } --------------------------------------------------------------------------------