Day 3 in TIC-80
This commit is contained in:
parent
cb23a6af1b
commit
e59f6f62a9
|
@ -3,3 +3,6 @@ Day 1
|
||||||
|
|
||||||
Day 2
|
Day 2
|
||||||
![Day 2](gifs/day2.gif "Day 2")
|
![Day 2](gifs/day2.gif "Day 2")
|
||||||
|
|
||||||
|
Day 3
|
||||||
|
![Day 3](gifs/day3.gif "Day 3")
|
216
day3.p8
Normal file
216
day3.p8
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
pico-8 cartridge // http://www.pico-8.com
|
||||||
|
version 41
|
||||||
|
__lua__
|
||||||
|
|
||||||
|
local input = split(
|
||||||
|
[[.......................661.........................485..565.......344.......325.....................................841.....725.............
|
||||||
|
....*609..131................512.......................*................536*..............462/..-...60..424.........@....$.*................
|
||||||
|
.316.........*.......39..................@.630......377........919...........98................789..*..*..............788..2.......=..564...
|
||||||
|
...........431...535...*...............622.-..../.................*..........*.......682...........108.116....@...-...............299.......
|
||||||
|
.....................428.....378...844.........416...............586.537=..27..........*......$..............871...331..................492.
|
||||||
|
...878....390....%..............*.*...................739.496=.................867......867..867.........................344......487.../...
|
||||||
|
...../.....*...558........@..535...644..................+.........404..605.......*................................%.....*...................
|
||||||
|
........................381............729..726....578........10...*..........818..............................929....934..........119......
|
||||||
|
.53....31..........734-..........847*.................#.........*...........#............217............/..321....................*.........
|
||||||
|
.......=.............................509.315.654.................60.........925.747*559..*.....430....226..*...................290...848=...
|
||||||
|
..........=.......546......664..507......../....#.......337.............................94........=.........359....528*996..................
|
||||||
|
.....351...638.......*.............*433............337.....................226...859........../............................378..............
|
||||||
|
.......*..........648.........183.........126........*...........208.954......=....*.......626........499*..........803.../....642.235......
|
||||||
|
.518*...813..990..............*..............*......699...133....+...............68...............79......838.447...*..........*...*........
|
||||||
|
................+.696*.........586.6......243.............*..........$224.............392...275.....-.........*...699...#177..230.593.&.....
|
||||||
|
...........$326.......683.-761.......491......./.........26...........................*.....=.........56.305.262.......................150..
|
||||||
|
....=.......................................41.908.........................819.785.....276.....&.................%..........................
|
||||||
|
.618......401$...............-......................599..124......34+.........*..............676..................342...........473.........
|
||||||
|
....................889......888..454....723/.........*.................141*.....958.......................................416.....*94......
|
||||||
|
....212.............-................%.........826=....552..................569....*............................728........=............143.
|
||||||
|
...*......287...................=60.............................872.....886.......171....437......815..680.........*.............633....+...
|
||||||
|
..234....*.....687..........432........203/.....*...275.65.........*341.@...........................*....%.246......272.....922*..../.......
|
||||||
|
........967.........495.......*....161.......474.97...*..*..84.400.........*295....805......................@...................915.........
|
||||||
|
...419.................*.979...932....*.............729.215.#....*.......81........*......554.263*567..........812..........................
|
||||||
|
.....*..............458....$.........682......................179................348..906.................428.../............798............
|
||||||
|
...668..................-.........................552............./..................=.......+...........@..........99........*..85.4.......
|
||||||
|
........29......938..594......107........*171.98.....*..896....$..491...........+..........412..12.............326.*.....705..4....*........
|
||||||
|
..........*....................+......332......@....949..*...750.......$..974....342.............*....558......#............*..........794..
|
||||||
|
.......459....342*.........637...........................273.....658..601....*................735....*...............%....627....889...*....
|
||||||
|
.697..............131....................718.................689.............450....390............994.............793.............*..241...
|
||||||
|
..............991........89..........14.......*.................*912.............39.+...698.............................953*240...87........
|
||||||
|
..324.............618.....*...328......*....538.%.....307.920.........515...............*...................................................
|
||||||
|
.....*386...........*...780..*.......475.........719...*...*...................910...410................384.....999........*756.............
|
||||||
|
....................268.......701.............72........63.43...193.....+..................674...670$....*........*......95.......893.......
|
||||||
|
...16.........................................*....663........../....407.....................*........258....264=.298........202*..../......
|
||||||
|
...&......574................187.......88...53.........931........@......&759....$..672....385..............................................
|
||||||
|
.....938........192......297....*.723...*.................%......930...........692................283.....................=349.........&981.
|
||||||
|
......*....................&.207....*...843.736.........................260..........677..389........*..............954..........&..........
|
||||||
|
......603........713.............745..................411.359.922.......*.............*......*.......718..888..561..=.........182..206......
|
||||||
|
............896....*.....173*383.......%...145...943...*.....*.........622..382*.......180.141............*...........................*.....
|
||||||
|
.....89........*...238.............+.714....*........575../.........................@...............$.....539.......114*721.645........471..
|
||||||
|
.......*307....968..............250......836.....498......59....909..601*..........117...........435../........944..........................
|
||||||
|
............*...............56*.................+....498..........-......730.882..........975..........680........*...95......152....$517...
|
||||||
|
...........150.......142.......473.713.+262...........=...577.266...736..........668..$.........70*111......811.165..@......................
|
||||||
|
.......741.............*.97.......................=.........*.......*....-654..........428..157................................748*823......
|
||||||
|
.........*............48...*.....772....892.....350....$.....760.148.............................440...........731*563......................
|
||||||
|
........260..............227...............*..........795..................649.....27.107...219.@.....23@...............226......369........
|
||||||
|
...41............&...................+...136.....546.......$.920...................+...*...&....../.........981...........@.......*.....454.
|
||||||
|
...*......635%....782...............560............*....896...........854..+...........694......340...@.498*....................41..959*....
|
||||||
|
...486..........................63..................810......641....+....*..532....642.......$.......90.....................76=.............
|
||||||
|
..........325.....................@..............@...........-....539.407.............$......9...........550................................
|
||||||
|
...787..$....*.$105.126.+810.........497.576...538.............................718.......................*...+....317..519..................
|
||||||
|
.......303.493...........................................-...........462..647..*...........%..+875....641..644.....*......*.....154.588.....
|
||||||
|
................./.....-......44.........%...@140.......228...43......*....*..132.794...628.......................669....110....*.....*.....
|
||||||
|
....579...........348..32.491*.......#...646.......506..........*708......74........#........117..............24*............698....532.....
|
||||||
|
......*.........................902.722............=....=........................................700....610......878....*...................
|
||||||
|
.../..885.../..351.............*.........................799.....814*238......*339....428*825......./................965.862......125.......
|
||||||
|
.723......243.@........852..........757...784.472..814.......603...........151........................279.617....849........................
|
||||||
|
........................*......./............*.......*.........*....#.............91.......246...384.....*........%.........................
|
||||||
|
.218.659....113+........128....691...................972......571....934............*......*...................................442..236.....
|
||||||
|
....*...............455.............868......&379.........................594.......80....654.....................421.456...................
|
||||||
|
............2*535......*410...553........409......235.173..779......116.....*.................&........*646.418*.....*.................596..
|
||||||
|
.70#.361......................./....493....$..........*...-.....440.........317...865...323....696..202..........952.......187.....%....#...
|
||||||
|
..........%...767......318............*................1.............../...........*......*................241......@.147...*.....389.......
|
||||||
|
..921.....301..*........*............67.540.../....149.........=........827.....=.347....956..........980...............$...204.............
|
||||||
|
...*............341......154.............*..695.....$.....20.183..............177..................$...$...66......699..........495......296
|
||||||
|
.460........&.......+............%.......4......+........*.......................................347.........*36...*....912.......*..765....
|
||||||
|
............142..163......885..480...............805.%...587...........289.310*389........$843..........-..........417....*.....628....*....
|
||||||
|
.............................*............434........803........482......-.........556.........&.........294...33$.........79........358....
|
||||||
|
.......................407@...873...............+..................*542....../.41....$./758....176.................*........................
|
||||||
|
.........842......................442*766.......284.........842...........856...*......................647......422.94..............@.......
|
||||||
|
....$........799............................&.......433.318*.....576..........111....................................................788....
|
||||||
|
.720...168.....%........840..............989....................*.......=............468..419...........198.................................
|
||||||
|
......*..................+..392..............282.......&...............591..........&....*....101.340....-.....187.....-....................
|
||||||
|
.....746...........................499...779...*....456...........@....................346....*......%...........*..693.......94..72........
|
||||||
|
.........970..671..696./....................&..999......124..246.434...........................173........@.....165.......925*.../..........
|
||||||
|
..628.............*....608.....827-.......*..............#....*........634...../418......185.......311...808.........372*............824....
|
||||||
|
..........694...360.....................43.645.................935........*516...........*....555.....*..................33.........-.......
|
||||||
|
............*............+........576#.........810*592..740.....................#665..968........*499.775..882+..............998............
|
||||||
|
....=303.....433.280......147..82.........................*..............................................................751*...............
|
||||||
|
.................$......................608...560..827...227....................448*..@......................@529.376...........@...........
|
||||||
|
...........465.....#.............554.....#.......#..#.......................401.......714...../.192.999..................466...28.161....351
|
||||||
|
..............&....706..157.679.@..........741..............818.811=..............412.......376...&..*.......=..............................
|
||||||
|
.441.....955....63.........*........=........+.............*..............#..........*..............399.......613.......444........*972.....
|
||||||
|
........@......*..................697..........600.&965...354.#.....392...827..665....326.................323...........&.......483.........
|
||||||
|
................381........972..........373*..*................9...&...........................289.........*................................
|
||||||
|
...........................*....+.............239......................863....................*..........341.....*329...................$...
|
||||||
|
801..+...638.659........358...29..695.....@........241...680.....863..........................310.#...........941........@216........311....
|
||||||
|
...*.358.*...*....................@....786....*330................&.........842........11..........279...................................686
|
||||||
|
.932..........666....533..712..............801.............64.544.....*972.....*353....-..809...........524...........397...............*...
|
||||||
|
.........795+.......*.......*......394=................586......*.........................................&...........................562...
|
||||||
|
...................629.......184........796..............=................-946.348.../670............63.........%...........................
|
||||||
|
.....428-................918.........@..............#.............850.889.........*..............673..#..110.221..........337.560...-.......
|
||||||
|
.....................926*.........809.........=......627.............*..........344..........343.*........*.......832.......*....*...216....
|
||||||
|
.....624.....+................................78............915..701.....876.........734.402.....181.193.460.639.....*...558...138..........
|
||||||
|
.../...*...91....804..324..985......#429......................*..*.............892....................*......*...321.727...........134......
|
||||||
|
...991............*.........*.............39...........%.633.213.623..........&...........601.919.....378.318...*............@34............
|
||||||
|
........183.....#.399...+..297..973...622..*........855../......................+684../......*................335.................733.......
|
||||||
|
..........@..576......597........*.....*....686....................371..98..23$......119................................=.777......*........
|
||||||
|
.................901%......*...412......102...........754...332.47*......*......861+......539................495@....801...*..404...777.....
|
||||||
|
.........577..........577..978.................990......*...#............236.............@..............339............../......*........534
|
||||||
|
..169.....*..687........*..........598..........*..349@.723.....864..........972............196.....491*........$........335.372............
|
||||||
|
.........339..=......633........29...*.........4............251*.....$..........*.250.........$.908..............356.230...........324.386..
|
||||||
|
.................943.............-.....=............................325...726.690.*................/.......646........*...214.......=.......
|
||||||
|
.........&468.......*..................999.......944.........751..........*.......219.837.107..............*...=....271..*..............283.
|
||||||
|
......*..........210.....*390.....917*.....996*.....+..790...-.........128...............*................905.277.......320....936..835.....
|
||||||
|
...640.581....*.......167.............392......29......*..........885............................369..................&...........*.$...#...
|
||||||
|
..............708..........106.223...................817.........*............277.........&.........@..795.-296....172..........633......229
|
||||||
|
.......82..........@679.......*....*806.................../....10.............*.........456...........*.................95...........3......
|
||||||
|
..........536....................12........=914..458.......214..........995..97.-735........370.......334..876=.........*.......950#........
|
||||||
|
.........*.............=.....10.......837...........+..518.................*...................*........................761.................
|
||||||
|
......414..=.........794.............=................*...................813.394...815.718....759........403...............738.............
|
||||||
|
............463...........-..238.419............810.41...........452..2=..................&..............&........435.................468...
|
||||||
|
........................103....*..........................+...11.&....................927...........%.......282...*...234.....229......*....
|
||||||
|
......301+....................678............100.......954.....*...@....182....@.........*....737...916....-....890....@..118*.......625....
|
||||||
|
............67...312..865+.............910.....*...382.......516....973....*..874.500..153.....*............................................
|
||||||
|
.....373+...*.....*...............979..........469....*375..............765...................99....................733................897..
|
||||||
|
..........828.....669......=.....*...........................................284.189...$..371......*168..............%.......762............
|
||||||
|
..........................4..565.226........562@....190......281....257.......*.......889./......57........./...#.......210..*..............
|
||||||
|
......47.......120.............#...................*...........&....*.....169.549............%............414..744......%....503.#208.......
|
||||||
|
........*.................643.........397...........350..........289....&...*........&.....323.....+..................................856...
|
||||||
|
.....*...............458....#........................................104.....931..855..............89..469.....882...........=.........*....
|
||||||
|
..594.777......390...*...........422........355..............654............................81........*...........*......282..630....195....
|
||||||
|
..................*.568.912........*........*.....377..........*......*877.............419..*.....148.768.......471....+....*...............
|
||||||
|
.......393......163..........298.820............@..................582.......823......=...........*....................952..................
|
||||||
|
..........*268.......*733.59...@.............403..........................................14&...502...............481.........$.....231.....
|
||||||
|
........#.........970.....*......#....981...........711.261=.................=.......................701..244................323.....*......
|
||||||
|
.396....993.............557.......46.....*...........+..........714*659.....134........623..........*............677.730..............846...
|
||||||
|
......#......91...405........296..........295..............@..*.......................#..............740............*........%..............
|
||||||
|
.......345..=........-.792....*..834................100.891....764...697........570......*....620*.@.....................508..295...........
|
||||||
|
...*13................../...340...#..134..............#................*..........*.......247......660....607....705.....=...........165....
|
||||||
|
.........521..824...222.............*......372..290.....844.825-.......867..820...627...........................*............128...../...777
|
||||||
|
...629...*....#..................788...535....*..-.......*.........361......................*......805.......732....914....../...-......@...
|
||||||
|
...*.....743...........853..................637.......880...-..849*........425............946..590....*302...........*.........748..........
|
||||||
|
...120.%.......271..............862.....70................207................=......233.......*..................443..263...................
|
||||||
|
........680....../.825.....&793...........*....................-720.............555........184..509.......22......*.............811.........
|
||||||
|
..........................................772.272......................134.........*..374.........*............573........*.......*.........
|
||||||
|
934..231.....*....821...230.....981..............%........707..370....*.....634%..787..*..........93..909..70..........199.59...490.........
|
||||||
|
.......*....525.........-........*...747...676=..../.......*..........829...............324..952.........%...*..........................%...
|
||||||
|
.....189.........................791.............236........687.868........................................505..............713......777....]], "\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
printh("")
|
||||||
|
printh("")
|
||||||
|
printh("advent 2023 - day 3")
|
||||||
|
printh("")
|
||||||
|
printh("")
|
||||||
|
|
||||||
|
local sum = "0"
|
||||||
|
|
||||||
|
--strdsum
|
||||||
|
--v0.1
|
||||||
|
--@shiftalow / bitchunk
|
||||||
|
function strdsum(a, b)
|
||||||
|
local s, l, d = '', max(#a, #b), ''
|
||||||
|
for i = 1, l do
|
||||||
|
local v = (a[-i] or 0) + (b[-i] or 0) + #d
|
||||||
|
d = v > 9 and '1' or ''
|
||||||
|
s = v % 10 .. s
|
||||||
|
end
|
||||||
|
return d .. s
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, line in ipairs(input) do
|
||||||
|
printh("///")
|
||||||
|
local num = ""
|
||||||
|
local startx = nil
|
||||||
|
for j = 1, #line + 1 do
|
||||||
|
-- +1 to catch end of line
|
||||||
|
local c = line[j]
|
||||||
|
-- number char, append to num
|
||||||
|
if tonum(c) and tonum(c) >= 0 and tonum(c) <= 9 then
|
||||||
|
if not startx then startx = j end
|
||||||
|
num ..= c
|
||||||
|
else
|
||||||
|
-- end of a number, check for any surrounding symbols
|
||||||
|
if startx then
|
||||||
|
-- printh("startx: " .. startx)
|
||||||
|
local x1 = max(1, startx - 1)
|
||||||
|
local x2 = min(#line, startx + #num + 1)
|
||||||
|
local y1 = max(1, i - 1)
|
||||||
|
local y2 = min(#input, i + 1)
|
||||||
|
for x = x1, x2 do
|
||||||
|
for y = y1, y2 do
|
||||||
|
local symbol = input[y][x]
|
||||||
|
if symbol and symbol != "." and tonum(symbol) == nil then
|
||||||
|
local newsum = strdsum(sum, num)
|
||||||
|
-- printh(x .. "," .. y .. ": " .. symbol)
|
||||||
|
printh(sum .. " + " .. num .. " = " .. newsum)
|
||||||
|
sum = newsum
|
||||||
|
goto endloop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
::endloop::
|
||||||
|
end
|
||||||
|
num = ""
|
||||||
|
startx = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
printh(sum)
|
||||||
|
|
||||||
|
__gfx__
|
||||||
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
2
day3/.gitignore
vendored
Normal file
2
day3/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.local
|
||||||
|
build
|
261
day3/game.js
Normal file
261
day3/game.js
Normal file
|
@ -0,0 +1,261 @@
|
||||||
|
// title: Advent 2023 - Day 3
|
||||||
|
// author: Simon Cambier
|
||||||
|
// desc: short description
|
||||||
|
// script: js
|
||||||
|
const input = `.......................661.........................485..565.......344.......325.....................................841.....725.............
|
||||||
|
....*609..131................512.......................*................536*..............462/..-...60..424.........@....$.*................
|
||||||
|
.316.........*.......39..................@.630......377........919...........98................789..*..*..............788..2.......=..564...
|
||||||
|
...........431...535...*...............622.-..../.................*..........*.......682...........108.116....@...-...............299.......
|
||||||
|
.....................428.....378...844.........416...............586.537=..27..........*......$..............871...331..................492.
|
||||||
|
...878....390....%..............*.*...................739.496=.................867......867..867.........................344......487.../...
|
||||||
|
...../.....*...558........@..535...644..................+.........404..605.......*................................%.....*...................
|
||||||
|
........................381............729..726....578........10...*..........818..............................929....934..........119......
|
||||||
|
.53....31..........734-..........847*.................#.........*...........#............217............/..321....................*.........
|
||||||
|
.......=.............................509.315.654.................60.........925.747*559..*.....430....226..*...................290...848=...
|
||||||
|
..........=.......546......664..507......../....#.......337.............................94........=.........359....528*996..................
|
||||||
|
.....351...638.......*.............*433............337.....................226...859........../............................378..............
|
||||||
|
.......*..........648.........183.........126........*...........208.954......=....*.......626........499*..........803.../....642.235......
|
||||||
|
.518*...813..990..............*..............*......699...133....+...............68...............79......838.447...*..........*...*........
|
||||||
|
................+.696*.........586.6......243.............*..........$224.............392...275.....-.........*...699...#177..230.593.&.....
|
||||||
|
...........$326.......683.-761.......491......./.........26...........................*.....=.........56.305.262.......................150..
|
||||||
|
....=.......................................41.908.........................819.785.....276.....&.................%..........................
|
||||||
|
.618......401$...............-......................599..124......34+.........*..............676..................342...........473.........
|
||||||
|
....................889......888..454....723/.........*.................141*.....958.......................................416.....*94......
|
||||||
|
....212.............-................%.........826=....552..................569....*............................728........=............143.
|
||||||
|
...*......287...................=60.............................872.....886.......171....437......815..680.........*.............633....+...
|
||||||
|
..234....*.....687..........432........203/.....*...275.65.........*341.@...........................*....%.246......272.....922*..../.......
|
||||||
|
........967.........495.......*....161.......474.97...*..*..84.400.........*295....805......................@...................915.........
|
||||||
|
...419.................*.979...932....*.............729.215.#....*.......81........*......554.263*567..........812..........................
|
||||||
|
.....*..............458....$.........682......................179................348..906.................428.../............798............
|
||||||
|
...668..................-.........................552............./..................=.......+...........@..........99........*..85.4.......
|
||||||
|
........29......938..594......107........*171.98.....*..896....$..491...........+..........412..12.............326.*.....705..4....*........
|
||||||
|
..........*....................+......332......@....949..*...750.......$..974....342.............*....558......#............*..........794..
|
||||||
|
.......459....342*.........637...........................273.....658..601....*................735....*...............%....627....889...*....
|
||||||
|
.697..............131....................718.................689.............450....390............994.............793.............*..241...
|
||||||
|
..............991........89..........14.......*.................*912.............39.+...698.............................953*240...87........
|
||||||
|
..324.............618.....*...328......*....538.%.....307.920.........515...............*...................................................
|
||||||
|
.....*386...........*...780..*.......475.........719...*...*...................910...410................384.....999........*756.............
|
||||||
|
....................268.......701.............72........63.43...193.....+..................674...670$....*........*......95.......893.......
|
||||||
|
...16.........................................*....663........../....407.....................*........258....264=.298........202*..../......
|
||||||
|
...&......574................187.......88...53.........931........@......&759....$..672....385..............................................
|
||||||
|
.....938........192......297....*.723...*.................%......930...........692................283.....................=349.........&981.
|
||||||
|
......*....................&.207....*...843.736.........................260..........677..389........*..............954..........&..........
|
||||||
|
......603........713.............745..................411.359.922.......*.............*......*.......718..888..561..=.........182..206......
|
||||||
|
............896....*.....173*383.......%...145...943...*.....*.........622..382*.......180.141............*...........................*.....
|
||||||
|
.....89........*...238.............+.714....*........575../.........................@...............$.....539.......114*721.645........471..
|
||||||
|
.......*307....968..............250......836.....498......59....909..601*..........117...........435../........944..........................
|
||||||
|
............*...............56*.................+....498..........-......730.882..........975..........680........*...95......152....$517...
|
||||||
|
...........150.......142.......473.713.+262...........=...577.266...736..........668..$.........70*111......811.165..@......................
|
||||||
|
.......741.............*.97.......................=.........*.......*....-654..........428..157................................748*823......
|
||||||
|
.........*............48...*.....772....892.....350....$.....760.148.............................440...........731*563......................
|
||||||
|
........260..............227...............*..........795..................649.....27.107...219.@.....23@...............226......369........
|
||||||
|
...41............&...................+...136.....546.......$.920...................+...*...&....../.........981...........@.......*.....454.
|
||||||
|
...*......635%....782...............560............*....896...........854..+...........694......340...@.498*....................41..959*....
|
||||||
|
...486..........................63..................810......641....+....*..532....642.......$.......90.....................76=.............
|
||||||
|
..........325.....................@..............@...........-....539.407.............$......9...........550................................
|
||||||
|
...787..$....*.$105.126.+810.........497.576...538.............................718.......................*...+....317..519..................
|
||||||
|
.......303.493...........................................-...........462..647..*...........%..+875....641..644.....*......*.....154.588.....
|
||||||
|
................./.....-......44.........%...@140.......228...43......*....*..132.794...628.......................669....110....*.....*.....
|
||||||
|
....579...........348..32.491*.......#...646.......506..........*708......74........#........117..............24*............698....532.....
|
||||||
|
......*.........................902.722............=....=........................................700....610......878....*...................
|
||||||
|
.../..885.../..351.............*.........................799.....814*238......*339....428*825......./................965.862......125.......
|
||||||
|
.723......243.@........852..........757...784.472..814.......603...........151........................279.617....849........................
|
||||||
|
........................*......./............*.......*.........*....#.............91.......246...384.....*........%.........................
|
||||||
|
.218.659....113+........128....691...................972......571....934............*......*...................................442..236.....
|
||||||
|
....*...............455.............868......&379.........................594.......80....654.....................421.456...................
|
||||||
|
............2*535......*410...553........409......235.173..779......116.....*.................&........*646.418*.....*.................596..
|
||||||
|
.70#.361......................./....493....$..........*...-.....440.........317...865...323....696..202..........952.......187.....%....#...
|
||||||
|
..........%...767......318............*................1.............../...........*......*................241......@.147...*.....389.......
|
||||||
|
..921.....301..*........*............67.540.../....149.........=........827.....=.347....956..........980...............$...204.............
|
||||||
|
...*............341......154.............*..695.....$.....20.183..............177..................$...$...66......699..........495......296
|
||||||
|
.460........&.......+............%.......4......+........*.......................................347.........*36...*....912.......*..765....
|
||||||
|
............142..163......885..480...............805.%...587...........289.310*389........$843..........-..........417....*.....628....*....
|
||||||
|
.............................*............434........803........482......-.........556.........&.........294...33$.........79........358....
|
||||||
|
.......................407@...873...............+..................*542....../.41....$./758....176.................*........................
|
||||||
|
.........842......................442*766.......284.........842...........856...*......................647......422.94..............@.......
|
||||||
|
....$........799............................&.......433.318*.....576..........111....................................................788....
|
||||||
|
.720...168.....%........840..............989....................*.......=............468..419...........198.................................
|
||||||
|
......*..................+..392..............282.......&...............591..........&....*....101.340....-.....187.....-....................
|
||||||
|
.....746...........................499...779...*....456...........@....................346....*......%...........*..693.......94..72........
|
||||||
|
.........970..671..696./....................&..999......124..246.434...........................173........@.....165.......925*.../..........
|
||||||
|
..628.............*....608.....827-.......*..............#....*........634...../418......185.......311...808.........372*............824....
|
||||||
|
..........694...360.....................43.645.................935........*516...........*....555.....*..................33.........-.......
|
||||||
|
............*............+........576#.........810*592..740.....................#665..968........*499.775..882+..............998............
|
||||||
|
....=303.....433.280......147..82.........................*..............................................................751*...............
|
||||||
|
.................$......................608...560..827...227....................448*..@......................@529.376...........@...........
|
||||||
|
...........465.....#.............554.....#.......#..#.......................401.......714...../.192.999..................466...28.161....351
|
||||||
|
..............&....706..157.679.@..........741..............818.811=..............412.......376...&..*.......=..............................
|
||||||
|
.441.....955....63.........*........=........+.............*..............#..........*..............399.......613.......444........*972.....
|
||||||
|
........@......*..................697..........600.&965...354.#.....392...827..665....326.................323...........&.......483.........
|
||||||
|
................381........972..........373*..*................9...&...........................289.........*................................
|
||||||
|
...........................*....+.............239......................863....................*..........341.....*329...................$...
|
||||||
|
801..+...638.659........358...29..695.....@........241...680.....863..........................310.#...........941........@216........311....
|
||||||
|
...*.358.*...*....................@....786....*330................&.........842........11..........279...................................686
|
||||||
|
.932..........666....533..712..............801.............64.544.....*972.....*353....-..809...........524...........397...............*...
|
||||||
|
.........795+.......*.......*......394=................586......*.........................................&...........................562...
|
||||||
|
...................629.......184........796..............=................-946.348.../670............63.........%...........................
|
||||||
|
.....428-................918.........@..............#.............850.889.........*..............673..#..110.221..........337.560...-.......
|
||||||
|
.....................926*.........809.........=......627.............*..........344..........343.*........*.......832.......*....*...216....
|
||||||
|
.....624.....+................................78............915..701.....876.........734.402.....181.193.460.639.....*...558...138..........
|
||||||
|
.../...*...91....804..324..985......#429......................*..*.............892....................*......*...321.727...........134......
|
||||||
|
...991............*.........*.............39...........%.633.213.623..........&...........601.919.....378.318...*............@34............
|
||||||
|
........183.....#.399...+..297..973...622..*........855../......................+684../......*................335.................733.......
|
||||||
|
..........@..576......597........*.....*....686....................371..98..23$......119................................=.777......*........
|
||||||
|
.................901%......*...412......102...........754...332.47*......*......861+......539................495@....801...*..404...777.....
|
||||||
|
.........577..........577..978.................990......*...#............236.............@..............339............../......*........534
|
||||||
|
..169.....*..687........*..........598..........*..349@.723.....864..........972............196.....491*........$........335.372............
|
||||||
|
.........339..=......633........29...*.........4............251*.....$..........*.250.........$.908..............356.230...........324.386..
|
||||||
|
.................943.............-.....=............................325...726.690.*................/.......646........*...214.......=.......
|
||||||
|
.........&468.......*..................999.......944.........751..........*.......219.837.107..............*...=....271..*..............283.
|
||||||
|
......*..........210.....*390.....917*.....996*.....+..790...-.........128...............*................905.277.......320....936..835.....
|
||||||
|
...640.581....*.......167.............392......29......*..........885............................369..................&...........*.$...#...
|
||||||
|
..............708..........106.223...................817.........*............277.........&.........@..795.-296....172..........633......229
|
||||||
|
.......82..........@679.......*....*806.................../....10.............*.........456...........*.................95...........3......
|
||||||
|
..........536....................12........=914..458.......214..........995..97.-735........370.......334..876=.........*.......950#........
|
||||||
|
.........*.............=.....10.......837...........+..518.................*...................*........................761.................
|
||||||
|
......414..=.........794.............=................*...................813.394...815.718....759........403...............738.............
|
||||||
|
............463...........-..238.419............810.41...........452..2=..................&..............&........435.................468...
|
||||||
|
........................103....*..........................+...11.&....................927...........%.......282...*...234.....229......*....
|
||||||
|
......301+....................678............100.......954.....*...@....182....@.........*....737...916....-....890....@..118*.......625....
|
||||||
|
............67...312..865+.............910.....*...382.......516....973....*..874.500..153.....*............................................
|
||||||
|
.....373+...*.....*...............979..........469....*375..............765...................99....................733................897..
|
||||||
|
..........828.....669......=.....*...........................................284.189...$..371......*168..............%.......762............
|
||||||
|
..........................4..565.226........562@....190......281....257.......*.......889./......57........./...#.......210..*..............
|
||||||
|
......47.......120.............#...................*...........&....*.....169.549............%............414..744......%....503.#208.......
|
||||||
|
........*.................643.........397...........350..........289....&...*........&.....323.....+..................................856...
|
||||||
|
.....*...............458....#........................................104.....931..855..............89..469.....882...........=.........*....
|
||||||
|
..594.777......390...*...........422........355..............654............................81........*...........*......282..630....195....
|
||||||
|
..................*.568.912........*........*.....377..........*......*877.............419..*.....148.768.......471....+....*...............
|
||||||
|
.......393......163..........298.820............@..................582.......823......=...........*....................952..................
|
||||||
|
..........*268.......*733.59...@.............403..........................................14&...502...............481.........$.....231.....
|
||||||
|
........#.........970.....*......#....981...........711.261=.................=.......................701..244................323.....*......
|
||||||
|
.396....993.............557.......46.....*...........+..........714*659.....134........623..........*............677.730..............846...
|
||||||
|
......#......91...405........296..........295..............@..*.......................#..............740............*........%..............
|
||||||
|
.......345..=........-.792....*..834................100.891....764...697........570......*....620*.@.....................508..295...........
|
||||||
|
...*13................../...340...#..134..............#................*..........*.......247......660....607....705.....=...........165....
|
||||||
|
.........521..824...222.............*......372..290.....844.825-.......867..820...627...........................*............128...../...777
|
||||||
|
...629...*....#..................788...535....*..-.......*.........361......................*......805.......732....914....../...-......@...
|
||||||
|
...*.....743...........853..................637.......880...-..849*........425............946..590....*302...........*.........748..........
|
||||||
|
...120.%.......271..............862.....70................207................=......233.......*..................443..263...................
|
||||||
|
........680....../.825.....&793...........*....................-720.............555........184..509.......22......*.............811.........
|
||||||
|
..........................................772.272......................134.........*..374.........*............573........*.......*.........
|
||||||
|
934..231.....*....821...230.....981..............%........707..370....*.....634%..787..*..........93..909..70..........199.59...490.........
|
||||||
|
.......*....525.........-........*...747...676=..../.......*..........829...............324..952.........%...*..........................%...
|
||||||
|
.....189.........................791.............236........687.868........................................505..............713......777....
|
||||||
|
`.split("\n");
|
||||||
|
|
||||||
|
function isNum(c) {
|
||||||
|
return !isNaN(parseInt(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
trace("Advent of Code 2023 - Day 3");
|
||||||
|
|
||||||
|
trace("");
|
||||||
|
|
||||||
|
let sum1 = 0;
|
||||||
|
|
||||||
|
let sum2 = 0;
|
||||||
|
|
||||||
|
let gears = [];
|
||||||
|
|
||||||
|
let nums = [];
|
||||||
|
|
||||||
|
for (const [ i, line ] of input.entries()) {
|
||||||
|
// Regex to extract asterisks and their position from string
|
||||||
|
const regexGears = /(\*)/g;
|
||||||
|
let matchGears;
|
||||||
|
while (matchGears = regexGears.exec(line)) {
|
||||||
|
const gear = {
|
||||||
|
x: matchGears.index,
|
||||||
|
y: i
|
||||||
|
};
|
||||||
|
gears.push(gear);
|
||||||
|
}
|
||||||
|
// regex to extract numbers + their position from string
|
||||||
|
const regexNum = /(\d+)/g;
|
||||||
|
let matchNum;
|
||||||
|
while (matchNum = regexNum.exec(line)) {
|
||||||
|
const num = {
|
||||||
|
value: parseInt(matchNum[0]),
|
||||||
|
x1: matchNum.index - 1,
|
||||||
|
x2: matchNum.index + matchNum[0].length,
|
||||||
|
y1: i - 1,
|
||||||
|
y2: i + 1
|
||||||
|
};
|
||||||
|
// Check if the number is adjacent to a symbol
|
||||||
|
loop: for (let y = num.y1; y <= num.y2; y++) {
|
||||||
|
for (let x = num.x1; x <= num.x2; x++) {
|
||||||
|
const symbol = input[y]?.[x];
|
||||||
|
if (symbol && symbol !== "." && !isNum(symbol)) {
|
||||||
|
nums.push(num);
|
||||||
|
sum1 += num.value;
|
||||||
|
break loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const vizItems = [];
|
||||||
|
// Iterate gears to find ones that are adjacent to 2 numbers
|
||||||
|
|
||||||
|
for (const gear of gears) {
|
||||||
|
let count = 0;
|
||||||
|
let matches = [];
|
||||||
|
for (const num of nums) {
|
||||||
|
if (gear.x >= num.x1 && gear.y >= num.y1 && gear.x >= num.x1 && gear.y <= num.y2 && gear.x <= num.x2 && gear.y >= num.y1 && gear.x <= num.x2 && gear.y <= num.y2) {
|
||||||
|
matches.push(num);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count === 2) {
|
||||||
|
vizItems.push({
|
||||||
|
gear: gear,
|
||||||
|
num1: matches[0],
|
||||||
|
num2: matches[1]
|
||||||
|
});
|
||||||
|
sum2 += matches[0].value * matches[1].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trace("Part 1: " + sum1);
|
||||||
|
|
||||||
|
trace("Part 2: " + sum2);
|
||||||
|
|
||||||
|
trace(JSON.stringify(vizItems.length));
|
||||||
|
|
||||||
|
function TIC() {
|
||||||
|
cls();
|
||||||
|
const item = vizItems[0];
|
||||||
|
print("*", 120, 68);
|
||||||
|
const len = print(item.num1.value, -100, -100);
|
||||||
|
print(item.num1.value, 120 - len + Math.sin(time() / 200) * 20, 68 + Math.cos(time() / 200) * 20);
|
||||||
|
// print(viz)
|
||||||
|
}
|
||||||
|
// <TILES>
|
||||||
|
// 001:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc
|
||||||
|
// 002:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c
|
||||||
|
// 003:eccccccccc888888caaaaaaaca888888cacccccccacccccccacc0ccccacc0ccc
|
||||||
|
// 004:ccccceee8888cceeaaaa0cee888a0ceeccca0cccccca0c0c0cca0c0c0cca0c0c
|
||||||
|
// 017:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec
|
||||||
|
// 018:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee
|
||||||
|
// 019:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec
|
||||||
|
// 020:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee
|
||||||
|
// </TILES>
|
||||||
|
|
||||||
|
// <WAVES>
|
||||||
|
// 000:00000000ffffffff00000000ffffffff
|
||||||
|
// 001:0123456789abcdeffedcba9876543210
|
||||||
|
// 002:0123456789abcdef0123456789abcdef
|
||||||
|
// </WAVES>
|
||||||
|
|
||||||
|
// <SFX>
|
||||||
|
// 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
|
||||||
|
// </SFX>
|
||||||
|
|
||||||
|
// <PALETTE>
|
||||||
|
// 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
|
||||||
|
// </PALETTE>
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// title: Advent 2023 - Day 3
|
||||||
|
// author: Simon Cambier
|
||||||
|
// desc: short description
|
||||||
|
// script: js
|
||||||
|
|
||||||
const input =
|
const input =
|
||||||
`.......................661.........................485..565.......344.......325.....................................841.....725.............
|
`.......................661.........................485..565.......344.......325.....................................841.....725.............
|
||||||
....*609..131................512.......................*................536*..............462/..-...60..424.........@....$.*................
|
....*609..131................512.......................*................536*..............462/..-...60..424.........@....$.*................
|
||||||
|
@ -141,19 +146,35 @@ const input =
|
||||||
.....189.........................791.............236........687.868........................................505..............713......777....
|
.....189.........................791.............236........687.868........................................505..............713......777....
|
||||||
`.split("\n");
|
`.split("\n");
|
||||||
|
|
||||||
|
type Gear = {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
// Visualization
|
||||||
|
color: number;
|
||||||
|
rotOffset: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Num = {
|
||||||
|
value: number;
|
||||||
|
x1: number;
|
||||||
|
x2: number;
|
||||||
|
y1: number;
|
||||||
|
y2: number;
|
||||||
|
};
|
||||||
|
|
||||||
function isNum(c: string) {
|
function isNum(c: string) {
|
||||||
return !isNaN(parseInt(c));
|
return !isNaN(parseInt(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("");
|
trace("");
|
||||||
console.log("Advent of Code 2023 - Day 3");
|
trace("Advent of Code 2023 - Day 3");
|
||||||
console.log("");
|
trace("");
|
||||||
|
|
||||||
let sum1 = 0;
|
let sum1 = 0;
|
||||||
let sum2 = 0;
|
let sum2 = 0;
|
||||||
|
|
||||||
let gears = [];
|
let gears: Gear[] = [];
|
||||||
let nums = [];
|
let nums: Num[] = [];
|
||||||
|
|
||||||
for (const [i, line] of input.entries()) {
|
for (const [i, line] of input.entries()) {
|
||||||
// Regex to extract asterisks and their position from string
|
// Regex to extract asterisks and their position from string
|
||||||
|
@ -163,6 +184,8 @@ for (const [i, line] of input.entries()) {
|
||||||
const gear = {
|
const gear = {
|
||||||
x: matchGears.index,
|
x: matchGears.index,
|
||||||
y: i,
|
y: i,
|
||||||
|
color: Math.round(Math.random() * 15 + 1),
|
||||||
|
rotOffset: Math.random() * Math.PI * 2,
|
||||||
};
|
};
|
||||||
gears.push(gear);
|
gears.push(gear);
|
||||||
}
|
}
|
||||||
|
@ -193,6 +216,8 @@ for (const [i, line] of input.entries()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vizItems: { gear: Gear; num1: Num; num2: Num }[] = [];
|
||||||
|
|
||||||
// Iterate gears to find ones that are adjacent to 2 numbers
|
// Iterate gears to find ones that are adjacent to 2 numbers
|
||||||
for (const gear of gears) {
|
for (const gear of gears) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
@ -213,12 +238,41 @@ for (const gear of gears) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count === 2) {
|
if (count === 2) {
|
||||||
|
vizItems.push({ gear, num1: matches[0], num2: matches[1] });
|
||||||
sum2 += matches[0].value * matches[1].value;
|
sum2 += matches[0].value * matches[1].value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Part 1: " + sum1);
|
trace("Part 1: " + sum1);
|
||||||
console.log("Part 2: " + sum2);
|
trace("Part 2: " + sum2);
|
||||||
|
|
||||||
|
trace(JSON.stringify(vizItems.length));
|
||||||
|
|
||||||
|
function TIC() {
|
||||||
|
cls();
|
||||||
|
for (const [i, cog] of vizItems.entries()) {
|
||||||
|
if (i % 10 !== 0) continue;
|
||||||
|
|
||||||
|
const offset = cog.gear.rotOffset;
|
||||||
|
const x = (cog.gear.x / 140) * 240; //Math.random() * 240;
|
||||||
|
const y = cog.gear.y; // Math.random() * 136;
|
||||||
|
|
||||||
|
print("*", x, y, cog.gear.color);
|
||||||
|
const len = print(cog.num1.value, -100, -100);
|
||||||
|
|
||||||
|
// num1 rotates around gear
|
||||||
|
print(
|
||||||
|
cog.num1.value,
|
||||||
|
x + 3 - len / 2 + (Math.sin(time() / 200 + offset) * len) / 2,
|
||||||
|
y + (Math.cos(time() / 200 + offset) * len) / 2,
|
||||||
|
cog.gear.color
|
||||||
|
);
|
||||||
|
// num2 rotates around gear, but with a 180° offset
|
||||||
|
print(
|
||||||
|
cog.num2.value,
|
||||||
|
x + 3 - len / 2 + (Math.sin(time() / 200 + Math.PI + offset) * len) / 2,
|
||||||
|
y + (Math.cos(time() / 200 + Math.PI + offset) * len) / 2,
|
||||||
|
cog.gear.color
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
635
day3/tic.d.ts
vendored
Normal file
635
day3/tic.d.ts
vendored
Normal file
|
@ -0,0 +1,635 @@
|
||||||
|
/** @noSelfInFile */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows you to read the status of one of the buttons attached to TIC. The function returns true if the key with the supplied id is currently in the pressed state. It remains true for as long as the key is held down. If you want to test if a key was just pressed, use btnp instead.
|
||||||
|
* @param id the id of the key we want to interrogate, see the key map for reference
|
||||||
|
* @returns pressed
|
||||||
|
*/
|
||||||
|
declare function btn(id: number): boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bitfield of currently pressed buttons
|
||||||
|
*/
|
||||||
|
declare function btn(): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows you to read the status of one of TIC's buttons. It returns true only if the key has been pressed since the last frame.
|
||||||
|
* You can also use the optional hold and period parameters which allow you to check if a button is being held down. After the time specified by hold has elapsed, btnp will return true each time period is passed if the key is still down. For example, to re-examine the state of button '0' after 2 seconds and continue to check its state every 1/10th of a second, you would use btnp(0, 120, 6). Since time is expressed in ticks and TIC runs at 60 frames per second, we use the value of 120 to wait 2 seconds and 6 ticks (ie 60/10) as the interval for re-checking.
|
||||||
|
* @param id The id of the key we wish to interrogate - see the key map for reference
|
||||||
|
* @param [hold] The time (in ticks) the key must be pressed before re-checking
|
||||||
|
* @param [period] The the amount of time (in ticks) after hold before this function will return true again.
|
||||||
|
* @returns pressed (but wasn't pressed in previous frame)
|
||||||
|
*/
|
||||||
|
declare function btnp(id: number, hold?: number, period?: number): boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bitfield of buttons that were pressed the last frame
|
||||||
|
*/
|
||||||
|
declare function btnp(): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limits drawing to a clipping region or 'viewport' defined by x,y,w,h. Things drawn outside of this area will not be visible.
|
||||||
|
* Calling clip() with no parameters will reset the drawing area to the entire screen.
|
||||||
|
* @param x x coordinate of the top left of the clipping region
|
||||||
|
* @param y y coordinate of the top left of the clipping region
|
||||||
|
* @param width width of the drawing area in pixels
|
||||||
|
* @param height height of the drawing area in pixels
|
||||||
|
*/
|
||||||
|
declare function clip(x: number, y: number, width: number, height: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limits drawing to a clipping region or 'viewport' defined by x,y,w,h. Things drawn outside of this area will not be visible.
|
||||||
|
* Calling clip() with no parameters will reset the drawing area to the entire screen.
|
||||||
|
*/
|
||||||
|
declare function clip(): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the entire screen using the color argument. If no parameter is passed, index 0 of the palette is used.
|
||||||
|
* The function is usually called inside TIC(), but isn't mandatory. If you're drawing to the entire screen, for example with sprites, the map or primitive shapes, there's no need to clear the screen with cls() beforehand.
|
||||||
|
* Tip: You can create some interesting effects by not calling cls() or calling it repeatedly it to "flash" the screen when some special event occurs. You can also supply a color index above 15 to see some interesting fill patterns!
|
||||||
|
* @param color the index (0 to 15) of the color in the current palette.
|
||||||
|
*/
|
||||||
|
declare function cls(color?: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a filled circle of the desired radius and color with its center at x, y. It uses the Bresenham algorithm.
|
||||||
|
* @param x the x coordinate of the circle center
|
||||||
|
* @param y the y coordinate of the circle center
|
||||||
|
* @param radius the radius of the circle in pixels
|
||||||
|
* @param color the index of the desired color in the current palette
|
||||||
|
*/
|
||||||
|
declare function circ(x: number, y: number, radius: number, color: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws the circumference of a circle with its center at x, y using the radius and color requested. It uses the Bresenham algorithm.
|
||||||
|
* @param x the x coordinate of the circle center
|
||||||
|
* @param y the y coordinate of the circle center
|
||||||
|
* @param radius the radius of the circle in pixels
|
||||||
|
* @param color the index of the desired color in the current palette
|
||||||
|
*/
|
||||||
|
declare function circb(
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
radius: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a filled ellipse of the desired radiuses a b and color with its center at x, y. It uses the Bresenham algorithm.
|
||||||
|
* @param x the x coordinate of the ellipse center
|
||||||
|
* @param y the y coordinate of the ellipse center
|
||||||
|
* @param a the horizontal radius of the ellipse in pixels
|
||||||
|
* @param b the vertical radius of the ellipse in pixels
|
||||||
|
* @param color the index of the desired color in the current palette
|
||||||
|
*/
|
||||||
|
declare function elli(
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
a: number,
|
||||||
|
b: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws an ellipse border with the desired radiuses a b and color with its center at x, y. It uses the Bresenham algorithm.
|
||||||
|
* @param x the x coordinate of the ellipse center
|
||||||
|
* @param y the y coordinate of the ellipse center
|
||||||
|
* @param a the horizontal radius of the ellipse in pixels
|
||||||
|
* @param b the vertical radius of the ellipse in pixels
|
||||||
|
* @param color the index of the desired color in the current palette
|
||||||
|
*/
|
||||||
|
declare function ellib(
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
a: number,
|
||||||
|
b: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interrupts program execution and returns to the console when the TIC function ends.
|
||||||
|
*/
|
||||||
|
declare function exit(): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the specified flag of the sprite is set. See fset for more details.
|
||||||
|
* @param spriteId sprite index (0..511)
|
||||||
|
* @param flag flag index (0..7) to check
|
||||||
|
* @returns true if the specified flag of the sprite is set
|
||||||
|
*/
|
||||||
|
declare function fget(spriteId: number, flag: number): boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each sprite has eight flags which can be used to store information or signal different conditions. For example, flag 0 might be used to indicate that the sprite is invisible, flag 6 might indicate that the flag should be draw scaled etc.
|
||||||
|
* @param spriteId sprite index (0..511)
|
||||||
|
* @param flag index of flag (0..7)
|
||||||
|
* @param bool state to set (true/false)
|
||||||
|
*/
|
||||||
|
declare function fset(spriteId: number, flag: number, bool: boolean): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will draw text to the screen using the foreground spritesheet as the font. Sprite #256 is used for ASCII code 0, #257 for code 1 and so on. The character 'A' has the ASCII code 65 so will be drawn using the sprite with sprite #321 (256+65).
|
||||||
|
* - To simply print text to the screen using the system font, please see print
|
||||||
|
* - To print to the console, please see trace
|
||||||
|
* @param text any string to be printed to the screen
|
||||||
|
* @param x x coordinate where to print the text
|
||||||
|
* @param y y coordinate where to print the text
|
||||||
|
* @param transcolor the palette index to use for transparency
|
||||||
|
* @param charWidth distance between start of each character, in pixels
|
||||||
|
* @param charHeight distance vertically between start of each character, in pixels, when printing multi-line text.
|
||||||
|
* @param fixed indicates whether the font is fixed width (defaults to false ie variable width)
|
||||||
|
* @param scale font scaling (defaults to 1)
|
||||||
|
* @returns returns the width of the text in pixels
|
||||||
|
*/
|
||||||
|
declare function font(
|
||||||
|
text: string,
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
transcolor?: number,
|
||||||
|
charWidth?: number,
|
||||||
|
charHeight?: number,
|
||||||
|
fixed?: boolean,
|
||||||
|
scale?: number
|
||||||
|
): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function returns true if the key denoted by keycode is pressed.
|
||||||
|
* If the keycode is omitted, will return true if any key is pressed.
|
||||||
|
* @param code the key code we want to check (1..65). Check the wiki for the keycodes.
|
||||||
|
* @returns pressed
|
||||||
|
*/
|
||||||
|
declare function key(code?: number): boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given key is pressed but wasn't pressed in the previous frame. Refer to btnp for an explanation of the optional hold and period parameters.
|
||||||
|
* If the keycode is omitted, will return true if any key is pressed.
|
||||||
|
* @param code the key code we want to check (1..65). See codes in the wiki)
|
||||||
|
* @param hold time in ticks before autorepeat
|
||||||
|
* @param period time in ticks for autorepeat interval
|
||||||
|
* @returns key is pressed (but wasn't pressed in previous frame)
|
||||||
|
*/
|
||||||
|
declare function keyp(code?: number, hold?: number, period?: number): boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a straight line from point (x0,y0) to point (x1,y1) in the specified color.
|
||||||
|
* @param x0 the x coordinate of the start of the line
|
||||||
|
* @param y0 the y coordinate of the start of the line
|
||||||
|
* @param x1 the x coordinate of the end of the line
|
||||||
|
* @param y1 the y coordinate of the end of the line
|
||||||
|
* @param color the index of the color in the current palette
|
||||||
|
*/
|
||||||
|
declare function line(
|
||||||
|
x0: number,
|
||||||
|
y0: number,
|
||||||
|
x1: number,
|
||||||
|
y1: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param x The x coordinate of the top left map cell to be drawn (default 0).
|
||||||
|
* @param y The y coordinate of the top left map cell to be drawn (default 0).
|
||||||
|
* @param w The number of cells to draw horizontally (default 30).
|
||||||
|
* @param h The number of cells to draw vertically (default 17).
|
||||||
|
* @param sx The screen x coordinate where drawing of the map section will start (default 0).
|
||||||
|
* @param sy The screen y coordinate where drawing of the map section will start (default 0).
|
||||||
|
* @param colorkey index (or array of indexes 0.80.0) of the color that will be used as transparent color. Not setting this parameter will make the map opaque (default -1).
|
||||||
|
* @param scale Map scaling (default 1).
|
||||||
|
* @param remap An optional function called before every tile is drawn. Using this callback function you can show or hide tiles, create tile animations or flip/rotate tiles during the map rendering stage: callback [tile [x y] ] -> [tile [flip [rotate] ] ]
|
||||||
|
*/
|
||||||
|
declare function map(
|
||||||
|
x?: number,
|
||||||
|
y?: number,
|
||||||
|
w?: number,
|
||||||
|
h?: number,
|
||||||
|
sx?: number,
|
||||||
|
sy?: number,
|
||||||
|
colorkey?: number | number[],
|
||||||
|
scale?: number,
|
||||||
|
remap?: (
|
||||||
|
tile: number,
|
||||||
|
x: number,
|
||||||
|
y: number
|
||||||
|
) => [number, number?, number?] | number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies a continuous block of RAM from one address to another.
|
||||||
|
* @param to the address you want to write to
|
||||||
|
* @param from the address you want to copy from
|
||||||
|
* @param length the length of the memory block you want to copy (in bytes)
|
||||||
|
*/
|
||||||
|
declare function memcpy(to: number, from: number, length: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a continuous block of RAM to the same value.
|
||||||
|
* @param addr the address of the first byte of RAM you want to write to
|
||||||
|
* @param value the value you want to write (0..255)
|
||||||
|
* @param length the length of the memory block you want to set
|
||||||
|
*/
|
||||||
|
declare function memset(addr: number, value: number, length: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tile at the specified MAP coordinates, the top left cell of the map being (0, 0).
|
||||||
|
* @param x x coordinate on the map
|
||||||
|
* @param y y coordinate on the map
|
||||||
|
* @returns the tile id at the given coordinates
|
||||||
|
*/
|
||||||
|
declare function mget(x: number, y: number): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will change the sprite at the specified map coordinates. By default, changes made are only kept while the current game is running. To make permanent changes to the map, see sync.
|
||||||
|
* @param x x coordinate on the map
|
||||||
|
* @param y y coordinate on the map
|
||||||
|
* @param tileId The background sprite (0..255) to place in map at specified coordinates.
|
||||||
|
*/
|
||||||
|
declare function mset(x: number, y: number, tileId: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the mouse coordinates and a boolean value for the state of each mouse button, with true indicating that a button is pressed.
|
||||||
|
* @returns [x, y, left, middle, right, scrollx, scrolly]
|
||||||
|
*/
|
||||||
|
declare function mouse(): [
|
||||||
|
number,
|
||||||
|
number,
|
||||||
|
boolean,
|
||||||
|
boolean,
|
||||||
|
boolean,
|
||||||
|
number,
|
||||||
|
number
|
||||||
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts playing a track created in the Music Editor. Call without arguments to stop the music.
|
||||||
|
* @param track the id of the track to play (0..7).
|
||||||
|
* @param frame the index of the frame to play from (0..15).
|
||||||
|
* @param row the index of the row to play from (0..63).
|
||||||
|
* @param loop loop music (true, default) or play it once (false).
|
||||||
|
* @param sustain sustain notes after the end of each frame (true) or stop them (false, default).
|
||||||
|
* @param tempo play track with the specified tempo.
|
||||||
|
* @param speed play track with the specified speed.
|
||||||
|
*/
|
||||||
|
declare function music(
|
||||||
|
track?: number,
|
||||||
|
frame?: number,
|
||||||
|
row?: number,
|
||||||
|
loop?: boolean,
|
||||||
|
sustain?: boolean,
|
||||||
|
tempo?: number,
|
||||||
|
speed?: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read directly from RAM. It can be used to access resources created with the integrated tools, such as the sprite, map and sound editors, as well as cartridge data.
|
||||||
|
* @param addr the address of RAM you desire to read (segmented based on bits)
|
||||||
|
* @param bits the number of bits to read (1, 2, 4, or 8) from address (default: 8)
|
||||||
|
* @returns The range of value returned depends on the bits parameter:
|
||||||
|
* - byte : a full byte (0..255) - bits=8
|
||||||
|
* - val4 : a nibble (4 bits) (0..15) - bits=4
|
||||||
|
* - val2 : two bits (0..3) - bits=2
|
||||||
|
* - bitval : a single bit (0..1) - bits=1
|
||||||
|
*/
|
||||||
|
declare function peek(addr: number, bits?: 1 | 2 | 4 | 8): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The equivalent of peek(addr, 4)
|
||||||
|
* @param addr the address of RAM you desire to read
|
||||||
|
* @returns a nibble (4 bits) (0..15)
|
||||||
|
*/
|
||||||
|
declare function peek4(addr: number): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The equivalent of peek(addr, 2)
|
||||||
|
* @param addr the address of RAM you desire to read
|
||||||
|
* @returns two bits (0..3)
|
||||||
|
*/
|
||||||
|
declare function peek2(addr: number): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The equivalent of peek(addr, 1)
|
||||||
|
* @param addr the address of RAM you desire to read
|
||||||
|
* @returns a single bit (0..1)
|
||||||
|
*/
|
||||||
|
declare function peek1(addr: number): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a pixel in the specified color
|
||||||
|
* @param x x coordinate of the pixel to write
|
||||||
|
* @param y y coordinate of the pixel to write
|
||||||
|
* @param color the index of the palette color to draw
|
||||||
|
*/
|
||||||
|
declare function pix(x: number, y: number, color: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a pixel's color
|
||||||
|
* @param x x coordinate of the pixel to write
|
||||||
|
* @param y y coordinate of the pixel to write
|
||||||
|
* @returns the index (0..15) of the palette color at the specified coordinates.
|
||||||
|
*/
|
||||||
|
declare function pix(x: number, y: number): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save data to persistent memory. See https://github.com/nesbox/TIC-80/wiki/pmem for more information
|
||||||
|
* @param index an index (0..255) into the persistent memory of a cartridge.
|
||||||
|
* @param val the value you want to store in the memory.
|
||||||
|
*/
|
||||||
|
declare function pmem(index: number, val: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve data from persistent memory. See https://github.com/nesbox/TIC-80/wiki/pmem for more information
|
||||||
|
* @param index an index (0..255) into the persistent memory of a cartridge.
|
||||||
|
* @returns the current value saved in that memory slot.
|
||||||
|
*/
|
||||||
|
declare function pmem(index: number): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write directly to RAM. The requested number of bits is written at the address requested. The address is typically specified in hexadecimal format.
|
||||||
|
* @param addr the address of RAM you desire to write (segmented based on bits)
|
||||||
|
* @param val the integer value write to RAM (range varies based on bits)
|
||||||
|
* @param bits : the number of bits to write (1, 2, 4, or 8; default: 8)
|
||||||
|
*/
|
||||||
|
declare function poke(addr: number, val: number, bits?: 1 | 2 | 3 | 4): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The equivalent of poke(addr, val, 4)
|
||||||
|
* @param addr the 4-bit address in RAM to which to write,
|
||||||
|
* @param val the 4-bit value (0-15) to write to the specified address
|
||||||
|
*/
|
||||||
|
declare function poke4(addr: number, val: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The equivalent of poke(addr, val, 2)
|
||||||
|
* @param addr the 2-bit address in RAM to which to write,
|
||||||
|
* @param val the 2-bit value (0..3) to write to the specified address
|
||||||
|
*/
|
||||||
|
declare function poke2(addr: number, val: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The equivalent of poke(addr, val, 1)
|
||||||
|
* @param addr the bit address address in RAM to which to write,
|
||||||
|
* @param val the bit value (0..1) to write to the specified address
|
||||||
|
*/
|
||||||
|
declare function poke1(addr: number, val: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints text to the screen using the font defined in config.
|
||||||
|
* - To use a custom rastered font, check out font.
|
||||||
|
* - To print to the console, check out trace.
|
||||||
|
* @param text any string to be printed to the screen
|
||||||
|
* @param x x coordinate where to print the text
|
||||||
|
* @param y y coordinate where to print the text
|
||||||
|
* @param color the color to use to draw the text to the screen
|
||||||
|
* @param fixed a flag indicating whether fixed width printing is required
|
||||||
|
* @param scale font scaling
|
||||||
|
* @param smallfont use small font if true
|
||||||
|
* @returns the width of the text in pixels.
|
||||||
|
*/
|
||||||
|
declare function print(
|
||||||
|
text: any,
|
||||||
|
x?: number,
|
||||||
|
y?: number,
|
||||||
|
color?: number,
|
||||||
|
fixed?: boolean,
|
||||||
|
scale?: number,
|
||||||
|
smallfont?: boolean
|
||||||
|
): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a filled rectangle of the desired size and color at the specified position. If you only need to draw the the border or outline of a rectangle (ie not filled) see rectb
|
||||||
|
* @param x x coordinate of the top left corner of the rectangle
|
||||||
|
* @param y y coordinate of the top left corner of the rectangle
|
||||||
|
* @param w the width the rectangle in pixels
|
||||||
|
* @param h the height of the rectangle in pixels
|
||||||
|
* @param color the index of the color in the palette that will be used to fill the rectangle
|
||||||
|
*/
|
||||||
|
declare function rect(
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
w: number,
|
||||||
|
h: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a one pixel thick rectangle border at the position requested. If you need to fill the rectangle with a color see rect instead.
|
||||||
|
* @param x x coordinate of the top left corner of the rectangle
|
||||||
|
* @param y y coordinate of the top left corner of the rectangle
|
||||||
|
* @param w the width the rectangle in pixels
|
||||||
|
* @param h the height of the rectangle in pixels
|
||||||
|
* @param color the index of the color in the palette that will be used to color the rectangle's border.
|
||||||
|
*/
|
||||||
|
declare function rectb(
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
w: number,
|
||||||
|
h: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the cartridge. To return to the console, see the exit function.
|
||||||
|
*/
|
||||||
|
declare function reset(): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will play the sound with id created in the sfx editor.
|
||||||
|
* To stop playing: `sfx(-1)` or `sfx(-1, null, null, channel)`
|
||||||
|
* @param id the SFX id (0..63), or -1 to stop playing
|
||||||
|
* @param note the note number (0..95) or name (ex: C#3)
|
||||||
|
* @param duration the duration (number of frames) (-1 by default, which plays continuously)
|
||||||
|
* @param channel the audio channel to use (0..3)
|
||||||
|
* @param volume the volume (0..15) (defaults to 15)
|
||||||
|
* @param speed the speed (-4..3) (defaults to 0)
|
||||||
|
*/
|
||||||
|
declare function sfx(
|
||||||
|
id: number,
|
||||||
|
note?: number | string,
|
||||||
|
duration?: number,
|
||||||
|
channel?: number,
|
||||||
|
volume?: number,
|
||||||
|
speed?: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws the sprite number index at the x and y coordinate.
|
||||||
|
* You can specify a colorkey in the palette which will be used as the transparent color or use a value of -1 for an opaque sprite.
|
||||||
|
* The sprite can be scaled up by a desired factor. For example, a scale factor of 2 means an 8x8 pixel sprite is drawn to a 16x16 area of the screen.
|
||||||
|
* You can flip the sprite where:
|
||||||
|
* - 0 = No Flip
|
||||||
|
* - 1 = Flip horizontally
|
||||||
|
* - 2 = Flip vertically
|
||||||
|
* - 3 = Flip both vertically and horizontally
|
||||||
|
*
|
||||||
|
* When you rotate the sprite, it's rotated clockwise in 90° steps:
|
||||||
|
* - 0 = No rotation
|
||||||
|
* - 1 = 90° rotation
|
||||||
|
* - 2 = 180° rotation
|
||||||
|
* - 3 = 270° rotation
|
||||||
|
*
|
||||||
|
* You can draw a composite sprite (consisting of a rectangular region of sprites from the sprite sheet) by specifying the w and h parameters (which default to 1).
|
||||||
|
* @param id index of the sprite
|
||||||
|
* @param x x coordinate where the sprite will be drawn, starting from top left corner.
|
||||||
|
* @param y y coordinate where the sprite will be drawn, starting from top left corner.
|
||||||
|
* @param colorkey index (or array of indexes) of the color in the sprite that will be used as transparent color. Use -1 if you want an opaque sprite.
|
||||||
|
* @param scale scale factor applied to sprite.
|
||||||
|
* @param flip flip the sprite horizontally (1), vertically (2) or both (3).
|
||||||
|
* @param rotate rotate the sprite by 0, 90 (1), 180 (2) or 270 (3) degrees.
|
||||||
|
* @param w width of composite sprite
|
||||||
|
* @param h height of composite sprite
|
||||||
|
*/
|
||||||
|
declare function spr(
|
||||||
|
id: number,
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
colorkey?: number | number[],
|
||||||
|
scale?: number,
|
||||||
|
flip?: 0 | 1 | 2 | 3,
|
||||||
|
rotate?: 0 | 1 | 2 | 3,
|
||||||
|
w?: number,
|
||||||
|
h?: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pro version of TIC-80 contains 8 memory banks. To switch between these banks, sync can be used to either load contents from a memory bank to runtime, or save contents from the active runtime to a bank. The function can only be called once per frame.
|
||||||
|
* If you have manipulated the runtime memory (e.g. by using mset), you can reset the active state by calling sync(0,0,false). This resets the whole runtime memory to the contents of bank 0.
|
||||||
|
* Note that sync is not used to load code from banks; this is done automatically.
|
||||||
|
* @param mask mask of sections you want to switch:
|
||||||
|
* - tiles = 1<<0 -- 1
|
||||||
|
* - sprites = 1<<1 -- 2
|
||||||
|
* - map = 1<<2 -- 4
|
||||||
|
* - sfx = 1<<3 -- 8
|
||||||
|
* - music = 1<<4 -- 16
|
||||||
|
* - palette = 1<<5 -- 32
|
||||||
|
* - flags = 1<<6 -- 64
|
||||||
|
* - screen = 1<<7 -- 128
|
||||||
|
* @param bank memory bank, can be 0..7.
|
||||||
|
* @param tocart true - save sprites/map/sound from runtime to bank, false - load data from bank to runtime.
|
||||||
|
*/
|
||||||
|
declare function sync(mask?: number, bank?: number, tocart?: boolean): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function draws a triangle filled with texture from either SPRITES or MAP RAM or VBANK.
|
||||||
|
* @param x1 the screen coordinates of the first corner
|
||||||
|
* @param y1 the screen coordinates of the first corner
|
||||||
|
* @param x2 the screen coordinates of the second corner
|
||||||
|
* @param y2 the screen coordinates of the second corner
|
||||||
|
* @param x3 the screen coordinates of the third corner
|
||||||
|
* @param y3 the screen coordinates of the third corner
|
||||||
|
* @param u1 the UV coordinates of the first corner
|
||||||
|
* @param v1 the UV coordinates of the first corner
|
||||||
|
* @param u2 the UV coordinates of the second corner
|
||||||
|
* @param v2 the UV coordinates of the second corner
|
||||||
|
* @param u3 the UV coordinates of the third corner
|
||||||
|
* @param v3 the UV coordinates of the third corner
|
||||||
|
* @param useMap if false (default), the triangle's texture is read from SPRITES RAM. If true, the texture comes from the MAP RAM.
|
||||||
|
* @param trans index (or array of indexes 0.80) of the color(s) that will be used as transparent
|
||||||
|
* @param z1 depth parameters for texture correction
|
||||||
|
* @param z2 depth parameters for texture correction
|
||||||
|
* @param z3 depth parameters for texture correction
|
||||||
|
*/
|
||||||
|
declare function ttri(
|
||||||
|
x1: number,
|
||||||
|
y1: number,
|
||||||
|
x2: number,
|
||||||
|
y2: number,
|
||||||
|
x3: number,
|
||||||
|
y3: number,
|
||||||
|
u1: number,
|
||||||
|
v1: number,
|
||||||
|
u2: number,
|
||||||
|
v2: number,
|
||||||
|
u3: number,
|
||||||
|
v3: number,
|
||||||
|
useMap?: boolean,
|
||||||
|
trans?: number,
|
||||||
|
z1?: number,
|
||||||
|
z2?: number,
|
||||||
|
z3?: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of milliseconds elapsed since the cartridge began execution. Useful for keeping track of time, animating items and triggering events.
|
||||||
|
* @returns the number of milliseconds elapsed since the application began.
|
||||||
|
*/
|
||||||
|
declare function time(): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of seconds elapsed since January 1st, 1970. Useful for creating persistent games which evolve over time between plays.
|
||||||
|
* @returns the current Unix timestamp in seconds
|
||||||
|
*/
|
||||||
|
declare function tstamp(): number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a service function, useful for debugging your code. It prints the message parameter to the console in the (optional) color specified.
|
||||||
|
* @param msg the message to print in the console. Can be a 'string' or variable.
|
||||||
|
* @param color the index of a color in the current palette (0..15)
|
||||||
|
*/
|
||||||
|
declare function trace(msg: any, color?: number): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a triangle filled with color, using the supplied vertices.
|
||||||
|
* @param x1 the x coordinate of the first triangle corner
|
||||||
|
* @param y1 the y coordinate of the first triangle corner
|
||||||
|
* @param x2 the x coordinate of the second triangle corner
|
||||||
|
* @param y2 the y coordinate of the second triangle corner
|
||||||
|
* @param x3 the x coordinate of the third triangle corner
|
||||||
|
* @param y3 the y coordinate of the third triangle corner
|
||||||
|
* @param color the index of the desired color in the current palette
|
||||||
|
*/
|
||||||
|
declare function tri(
|
||||||
|
x1: number,
|
||||||
|
y1: number,
|
||||||
|
x2: number,
|
||||||
|
y2: number,
|
||||||
|
x3: number,
|
||||||
|
y3: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function draws a triangle border with color, using the supplied vertices.
|
||||||
|
* @param x1 the x coordinate of the first triangle corner
|
||||||
|
* @param y1 the y coordinate of the first triangle corner
|
||||||
|
* @param x2 the x coordinate of the second triangle corner
|
||||||
|
* @param y2 the y coordinate of the second triangle corner
|
||||||
|
* @param x3 the x coordinate of the third triangle corner
|
||||||
|
* @param y3 the y coordinate of the third triangle corner
|
||||||
|
* @param color the index of the desired color in the current palette
|
||||||
|
*/
|
||||||
|
declare function trib(
|
||||||
|
x1: number,
|
||||||
|
y1: number,
|
||||||
|
x2: number,
|
||||||
|
y2: number,
|
||||||
|
x3: number,
|
||||||
|
y3: number,
|
||||||
|
color: number
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use ttri() instead.
|
||||||
|
*/
|
||||||
|
declare function textri(
|
||||||
|
x1: number,
|
||||||
|
y1: number,
|
||||||
|
x2: number,
|
||||||
|
y2: number,
|
||||||
|
x3: number,
|
||||||
|
y3: number,
|
||||||
|
u1: number,
|
||||||
|
v1: number,
|
||||||
|
u2: number,
|
||||||
|
v2: number,
|
||||||
|
u3: number,
|
||||||
|
v3: number,
|
||||||
|
useMap?: boolean,
|
||||||
|
trans?: number | number[]
|
||||||
|
): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the VRAM bank. More information: https://github.com/nesbox/TIC-80/wiki/vbank
|
||||||
|
*
|
||||||
|
* @param bank the vram bank id to switch to
|
||||||
|
*/
|
||||||
|
declare function vbank(bank: 0 | 1): void
|
11
day3/tsc80-config.json
Normal file
11
day3/tsc80-config.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"tic": {
|
||||||
|
"ticExecutable": "C:\\Users\\cambi\\AppData\\Roaming\\com.nesbox.tic\\TIC-80\\tic80.exe"
|
||||||
|
},
|
||||||
|
"compression": {
|
||||||
|
"compressedFile": "build/compressed.js",
|
||||||
|
"indentLevel": 1,
|
||||||
|
"compress": false,
|
||||||
|
"mangle": false
|
||||||
|
}
|
||||||
|
}
|
9
day3/tsconfig.json
Normal file
9
day3/tsconfig.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"compileOnSave": true,
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["es2020"],
|
||||||
|
"target": "es2020",
|
||||||
|
"outFile": "build/compiled.js",
|
||||||
|
"strict": true
|
||||||
|
}
|
||||||
|
}
|
BIN
gifs/day3.gif
Normal file
BIN
gifs/day3.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
Loading…
Reference in New Issue
Block a user