̬̬̬̈̬̬̬̬̈̬̬̬̬̬̪쬪̬̬̬̪쬪 ><""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",,"""",,",,""","",,"""","""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",",",""",""""",",""""""","",",""",""","","""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",","",""""",",,"""""",","",""""""","""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",",""""""""",,,,","""""",,"""",""","","""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",",",""",,",",,,""""",",","""","""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""̼ ̼̼̻www xwww pxwwg pwwwwwgͼ `wwwwwg̻ `vwwwwf̼ `fwwwgf̼`fvwwff̼ ffffff̻ݼffffff ffffff̼efffff̻@UffffVE̻@UefffUE̻DUUffVUE̼DUUUUUUEpx"DTUUUUUDpwx!2DDUUUUEDwwxw"3DDTUUUD`wwwxxw!"3DDDUUEDfwwwwwwxww!23DDDDDDDfwwwwwwwww"23DDDDDDDfwwwwwxwwwf"23CDDDDDD`fvwwwwwwwwf"23CDDDDDD`ffwwwgw~wwwwff"233DDDDD4fffvwwfwwwwgff""33CDDDDPfffffff~wwwfff!"333CDD3TffffffffwwgfffV!"2333333@Ufffffff`ffffffV""33333DUfffff`ffffffVE!"23333TUefffffffffffVE""233@TUUffffV`fffffUU"""!DTUUefffPffffVUUD!CDTUUUffVefffUUUD!2CDTUUUUUUp~UffVUUUD"3DDDUUUUUE~PUUUUUUD!23DDDTUUUUDpxww@UUUUUEDD"23DDDDUUUEpwwww@TUUUUDDD"33DDDDTUUDww}wwgDUUUEDDD!"33DDDDDDDDp}wwgDTUUDDDD!"33CDDDDDDDp}wwg@DDDDDD3!"33CDDDDDD}wwgf@DDDDDD?!"333DDDDDD }wwff1DDDDD3!"233CDDDDwwgff1CDDD?3"2333CDD3 wwffff43DDD33""333333 ffffffE43D33#!"233333ff>33#""3333 mf333"!""33`>333#!"" 4333"M433" UUUDD3# UUUUDD3#ZUUUEDD3#̘ZUUUDDD3#w̼YUUEDDD3# wwxYUUDDD43#~wwDDDDDD43" ~wwwwwwDDDDDD33 vwwwwwwDDDD43# nvwwwww0DD433ݽfvwwwww3333#ݽnffwwwwg33#ݻ `ffvwwwfݽffffwwgfvwݻ Pfffffff`wݺUfffffff`vUݭ@UffffffffUݭTUffffff`WEݪ TUefffffvxWE̪ATUUffffpwWED̬ !DTUUefffpwxwWED̜ 2DTUUUffV@wwwwwwED4̜!CDTUUUUUU@wwwwwwDDD 2CDDUUUUUEwwwwwwDDD3̜2CDDTUUUUDwwwwwwFDD3#̈!3CDDDUUUEvwwwwwfDD3#̌!3CDDDTUUDfwwwwgfDD33"!3CDDDDDDDfvwwwffF433"!33DDDDDDDffwwgffF433"!33DDDDDD`ffffffV333"p!23CDDDDD`ffffffV433"p{x233DDDD4ffffffVE3#"vzwwww"333DD4ffffffVE4#"vzwwww!233333`fffffUUD3#"vwwwwww"3333PffffVUUD43"vwfwwwww!"33#efffUUUD43#"fwwhfwwwww!""UffVUUUDD33"fvwwwf`fvwwwwPUUUUUUDD33"ffwwgfF`ffwwwg@UUUUUEDD33#"AefffffE`ffvwwfTUUUUDDD33#"AUffffVEdffffffDUUUEDDD33#"AUefffUEdffffff@TUUDDD433#"AUUffVUEeffffff@DDDDDD433#"ATUUUUUDeffffffDDDDDD333"DUUUUEDUfffffV@DDDD4333"DTUUUDDUeffffU"@DD4333#"DDUUEDDUUfffVE"333333"DDDDDDDUUeffUE$"03333#"@DDDDDDUUUUUUE4"033#"@DDDDDDTUUUUUD4"DDDDDDDUUUUED4#"CDDDDDDTUUUDD4#"3DDDD4DDUUEDD4#"03DD43DDDDDDD3#"033333CDDDDDD3#"333333DDDDD43"033333CDDDD33"3333#3CDD33#" 33#"233333""""""3333#""""33#"-- title: Nusan's Tentacle Effect with Explanations -- author: Nusan, TheAnarchyDice -- desc: Breakdown of Nusan's tentacle effect from the Byte Battle with Gopher (https://youtu.be/-Esj_g2PNAU) -- license: MIT License -- version: 0.1 -- script: lua sin=math.sin format=string.format --16320=0x3fc0 i.e. palette address PALETTE_ADDR=16320 --Prints current color palette, --with each line in the color with --the same ID from the palette. function print_palette() for i=0,15 do print(format('color %d',i),10,8+i*8,i) end end function TIC() cls() t=time()/512 --Sets palette to a gradient based --on the time. --Each byte represents the value for --R, G and B in an RGB color triplet, --spanning 16 colors => 3*16=48 bytes. for k=0,47 do byte_addr=PALETTE_ADDR+k --k//3 increases intensity as --palette color indices advance. --sin(k%3+t-sin(t)) both adds time --variation and ensures that all --R,G and B values differ, to avoid --grayscale. r_g_b_val=k//3*15*sin(k%3+t-sin(t)) --Uncomment to see R/G/B value. --Note: Text color is not indicative --of the actual RGB color. --print(format('%.3f',r_g_b_val),10+k%3*50,8+k//3*8,15) poke(byte_addr,r_g_b_val) end --Uncomment to see palette. --Note: Text color matches the color --with the same ID in the palette. --print_palette() for i=0,899 do --'f' is a value with several uses --and with certain prerequisites: --1. It determines the radius of the --circles that make up the tentacles. --2. It determines the color of the --circles that make up the tentacles. --3. It contributes to the x/y --positions of the circles that make --up the tentacles. --Use 1 requires that 'f'<1, as the --radius of the circle will be 0 if --'f'>=1. --For all tentacles to be have --equally sized segments of the same --colors, 'f' must have the same --value when drawing equivalent --segments of different tentacles. --As such, i//9 ensures that 'f' has --the same value for equivalent --sections of the 9 tentacles, and -- /99 scales 'f' down to the range --[0,899//9/99] (with 899//9/99<=1). f=i//9/99 --Controls how many tentacles are --drawn, and which one this loop --iteration is contributing to. tntcl_id=i%9 --'a=f*3' has been removed to improve --clarity --a=f*3 --'b' is used to compute both the x --and y position of the circle. --'tntcl_id' ensures that each --tentacle has a different value. --sin(t/4)*3*sin(t/3) creates a --non-linear dependence of 'b' to --the time, contributing to the --unusual rotating motion of the --tentacles. b=tntcl_id+sin(t/4)*3*sin(t/3) --120 centers the ring of tentacles --horizontally to 120. --sin(b)*40 provides the scaled --horizontal movement contributing --to the circular motion of the ring --of tentacles. --sin(f*3+t+tntcl_id)*50*f provides --the scaled horizontal movement of --individual segments with respect --to the tentacle base, contributing --to the illusion of tentacles --undulating all around. --*f exaggerates this motion by --by scaling the value more the --'further along' the tentacle that --a segment is. x=120+sin(f*3+t+tntcl_id)*50*f+sin(b)*40 --80 centers the ring of tentacles --vertically to 80 --40*sin(b+1.6) provides the scaled --vertical movement contributing to --the circular motion of the ring of --tentacles. Note: sin(x+1.6) is an --approximation for cos(x). --(f*80+sin(f*9+t+tntcl_id/4)*50/3)*f --provides the scaled vertical --movement of individual segments --with respect to the tentacle base, --contributing to the illusion of --tentacles undulating all around. --The '-' sign makes segments --'further along' the tentacle move --up (towards y=-INF) instead of --down (towaards y=+INF). --f*80 offsets tentacle segements --vertically in the direction of the --sign. It offsets segments 'further --along' the tentacle more than those --'closer to the base' by the --properties of 'f'. --sin(f*9+t+tntcl_id/4)*50/3 provides --scaled offset both in the same --direction as well as opposite that --of the sign. This provides the --illusion of a bobbing motion --vertically. --*f exaggerates this motion by --by scaling the value more the --'further along' the tentacle that --a segment is. y=80-(f*80+sin(f*9+t+tntcl_id/4)*50/3)*f+40*sin(b+1.6) --10*(1-f) determines the radius of --each segment, making the segments --'further along' the tentacle be --smaller by the properties of 'f'. --f*17 determines the color of each --segment, making the segments --'further along' the tentacle be --lighter by the properties of 'f' --and of the modified, gradient --color palette. --Comment to disable the drawing of --tentacles. circ(x,y,10*(1-f),f*17) end end