Log In  
Follow
spellcaster
[ :: Read More :: ]

Here's a small code snippet that allows you to enter "debug mode" and then go frame by frame through your game.

The idea is, that _update() wraps the actual update() function, and _draw() wraps the actual draw() function.
So you can have extra output only drawn in debug mode, and go frame by frame through the game to do some bug hunting.
It would also allow to append to a debug file only if debug mode is enabled.

It's pretty simple code, but quite helpful.
To switch to release mode, all you need to do is to swap the names of _draw() and draw() and _update() and update().

function _init()
 poke(0x5f2d, 0x01)
 debug=false
 waitframe=false
 t=0
end

function _update()
 if stat(30) then
  local ch=stat(31)
  if ch == "d" then
   if debug then
    waitframe = false
    debug = false
   else
    debug=true
   end     
  end
  if debug and ch==" " then
   waitframe = false
  end
 end

 if not waitframe then
  update()
  if debug then
   waitframe = true
  end
 end
end

function update()
 t+=1
end

function _draw()
 draw()
 -- debug information here
 if debug then
  print(debug,0,123,7)
 end
end

function draw()
 cls()
 print(t,2,2,7) 
end
P#113573 2022-06-24 10:34

[ :: Read More :: ]

This is a very small arcade game for a game jam.
Theme was "paranormal Activity"
In this game you're a wraith. Get close to those pesky humans to suck out their life force.
Move to the magic circle to feed the portal the life force you gathered.
Avoid those priests...

Spent roughly a day, so don't expect too much :)

Cart #gubihuhoru-1 | 2021-09-19 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

P#97531 2021-09-19 06:47 ( Edited 2021-09-19 21:57)

[ :: Read More :: ]

Cart #isoheight-0 | 2020-08-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
13

Inspired by @slainte 's post, I wanted to code a simple isometric map renderer with height information.
This is my first try - feedback on tiles and general how to approach this stuff is very welcome.

Right now the height is bruteforced rendered by overlaying the tile sprites height times. This could be optimized by checking the surrounding height and not drawing the area that will be painted over anyway.

Feedback very welcome :)

P#80459 2020-08-07 15:47 ( Edited 2020-08-07 15:48)

[ :: Read More :: ]

Cart #kitty-1 | 2020-07-24 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

I took the wander demo and changed it a bit by making it slightly more "frogger"-y. I thought it might be fun if somebody else would grab the cart and add something else to it, until we have a pico8-kitty frogger.

:)

P#79844 2020-07-24 10:45 ( Edited 2020-07-24 10:46)

[ :: Read More :: ]

Cart #picomol-0 | 2020-07-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

New version below, this is the first version

This is a remake of a game I coded mumble years ago with allegro.
It's still very much WIP, I started today and just got the basics working and some rough sprites drawn.

You can switch from joypad to mouse using a flag in the the code - which I would recommend if you can.
I enabled the mouse emulation in this cart, since the manual mentioned problems with mouse support on the bbs.

Issues:

  • There is a bug when picking up an atom (it doesn't connect the free electrons to nearby other free electrons)
  • in mouse emulation there is no bounds checking

Todo:

  • an actual goal for the game
  • removing molecules when all electrons are bound
  • levels
  • game over mechanic
  • and a lot more
  • sound
  • music

Feedback welcome.

P#79777 2020-07-22 21:38 ( Edited 2020-08-04 21:36)

[ :: Read More :: ]

Cart #rle_demo-4 | 2020-07-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

I needed a way to display graphics without using sprites/ or tiles.
So I wrote a small python script that takes an 128x128 image, finds the best matching colors from either the normal or secret palette (or the best 16 colors of both) and stores that in a data string.

If there's interest I can share the python code - main reason I haven't done so is, that I haven't made he python script user friendly :)

No sprites used in this demo.

You can download the image -> string conversion tool and some example code here:
https://github.com/iSpellcaster/pico8rle

P#79504 2020-07-17 17:52 ( Edited 2020-07-21 13:55)

[ :: Read More :: ]

I wanted to create background images w/o having to use tiles/sprites for that.
So I'm wroting a small python script, that takes a 128x128 png, reduces it to the most commonly 16 used colors from the pico8 palette, does RLE encoding on them and outputs the values as a string.

This string can then be imported into pic8 and used to render your background image.

The python part is not yet perfect (I need to write the custom palette generation code), but if you limit it to one of the two pals, it kinda works.

End even when re-drawing the bg from the data every frame, it's kinda ok.

The encoder and the functions to use the result can now be found at: https://github.com/iSpellcaster/pico8rle

Here's the code of the latest version.
Includes base64 encoded of variable sized sprites than can be flipped. Should run after copy and paste, nothing else required.
To encode your own images, check the github link above.

function _init()
 state  = "title"
    title = explode64(kanji_rle)
 batman= explode64(bat_rle)
 antiriad = explode64(antiriad_title_rle)
 ryu=explode64(ryu_rle)
 t=0
 _draw = draw_title
 start_t = time()
end

function _update()
    t+=1
 if btnp(❎) then
    if state == "title" then
        _draw= draw_batman
        setpal(bat_pal)
        state="batman"
    elseif state == "batman" then
     _draw= draw_antiriad
   state = "antiriad"
     start_t = time()
     pal2()
  else
   _draw= draw_title
   state = "title"
     start_t = time()
     pal()
        end
 end
end

function draw_title()
 local i,ofs,y
 ofs = flr((time()-start_t)*45)
 ofs2= flr((time()-start_t)*2)
 --rectfill(0,0,127,127,ofs2%4) 
 cls()
    y = ofs%250-100
    if y > -127 then
        spr_rle(title,(128-title[1])/2,y)
    end 
    spr_rle(ryu,15,20)
    spr_rle_flip(ryu,70,20)
    print("cpu:"..stat(1),5,5,7)
 cprint("press ❎",nil,110,{9,10,9})
end

function draw_batman()
    draw_rle(batman,0,0)
 print("cpu:"..stat(1),5,5,7)
 cprint("press ❎",nil,110,{9,10,9})
end

function draw_antiriad()
    draw_rle(antiriad,0,0)
 print("cpu:"..stat(1),5,5,7)
 cprint("press ❎",nil,110,{9,7,9}) 
end

-- util
base64str='0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()_-+=[]}{;:<>,./?~|'

bat_pal="94,90,95,9d,92,96"
bat_rle="20201,g61,461>g1461>471>471>471<481<481<481:491:491:491;g1491;4a1;4a1;4a0%411c4b0%420441164b0%47164b0%43g143154c0$44k243144c0$45g142g1144c0$49g112g14c0#4b124d0#4b124d0p47064b10g14e0o4a034b0|g14g0n4p0?4j0n4o0.g14l0m4o0.4n0m4p0>g14n0l4q0>g14n0l4r0<4o0l4s0;g14o0k4v0}g14o0k4x0[g14o0j4z0=4p0j4!0-g14p0j4@0_g14p0i4#0_gq0i4a014r0_g24o0i49034r0(g44n0h4a044v0$gr0f4b064%0tgr0f4a085bgk0f49075hgg0e49075mgc0e49075pg90e48085tg50d48095wg20d470a5y0e46095z0e450a5z0e440a5xg30e45095xg181g10d47075!g10d47075@0d47065s88g1810e46055t81g186g1810f44065tg186g2810o5v86g1820o5v86g1820n5x880n5y83g1830m5z83g1830m5qg182g146860l4b035c8744g1850k4b045b8a43g1840k4a055ag18b43840j49074/844ag18d41g1830i49084-034a85g1488j0i48094-054886g147g18i0h480a4-064781g185g1478i0f490c49024z08458946g18h0d490e49034z08448ag1458h0c490f49044p024807g1438c4589c185c10b490g49054n05460782428e4389c185c10a490h48074m07450584418f4387c285c109490i48084m08430584g18gg14187c185c209490i48094l0a42048uc185c2084a0i48094m0b41028hc185c285c284c308490j470b4d05430e8ac185c285c285c284c3074a0j460d4b08420d8ac185c284c384c384k1c207490k460e4a09420c84c184c285c284c483c1k1c183c1k1c18106490l460f490m84c284c284c285c7k2c5k1c18106480l470g4401430m84c283c285c284c8k1c5k2c18105480l470i4204420l83c284c284c8k1c6k1c5k2c18105480l470i4205410kc282c284c482c8k1c5k2c5k2c205470m470j420pc683cek2c5k2c4k2c304470m480k410pcgk1c6k1c6k2c4k2c304460n480l420mchk1c5k2c5k2c5k2c303460o480m420lcak1c5k2c5k2c5k2c4k3c303450p470o420kc4k1c5k1c5k2c4k3c4k3c4k3c34102440q470)c5k1c4k2c5k2c4k3c4k3c3k3c4470q470)c4k2c4k2c4k3c4k3c4k3c3k3c4460r470)c4k2c4k2c4k3c3k3c4k4c3k3c4490p460)c4k2c3k3c3k3c4k3c4k3c3k3c1814181c14c0m460(c4k3c3k3c3k3c4k3c3k4c5g144g14f0j460(c4k3c2k3c4k3c3k4c3k3c182g1484h0h460(c3k3c3k3c4k3c3k3c582g14b4k0e460*c4k3c3k3c3k3c4k3c181g14g4n0c440(c4k3c3k3c3k3c4k1c1814j4q09440(c3k4c2k5c1k4c182g14m4s07440*c4k4c2k4c2k281g14q4v04440*c4k4c1k4c182g14t4y01440*c3k4c3k1c1814x4$0&c4k3c181g14@4$0&c6814%4^0%83g14*4(0zg14+4-0tg14gg14gg44e4[0ng14ig348gc43g2484{0gg445g147gy484:0a81g;484,0481g>48g14?gu8kg186g14883g14?gl8xg14885g14?g28[4988g14?g18+498bg14/g18_498e4?g18&g1498gg14?g18$4a8j4?g184c186c18p4a8j5082c186c18p4a8j4383g14.g186c186c185c18bg14a8ig14386g14/82c285c285c18b4b8i44894/81c185c285c18b4b8i43g18bg14.g184c284c284c2854b"

kanji_rle="0^1s0eo1s2o2k20k0fk1s5o1410i0g41k1s5k10h0h41s5o10h0ho1s5o10h0gk1o1k2410747060g4105k2o4s7o2k1030i41k1o1sik1010fk1o2s8o6s8410ck1o1s6o2k209k1s6k109k1o2s5o1k141k1o34108k1s64105o1k102k1o1s1o2k203k1s4o107k1o1s5k10104o1s1410bk1s6410441o1s5o1410203k1s1o10co1k141s44103k1s5o1k10403s2k10e41s3o103o1s3o1k1410602k1s24107k205k1s3k10341k1410a02o1s1o108k1s14104o1s2o10h01k1s2o108k1s1k104o1s2o10h01o1s2k108s2o104o1s3k2410ek1s3k107k1s2o10441o1s5o10dk1s34107o1s2k106o1s4o10dk1s308s34107s4k10d0141o1k108k1o1k10641o1s3k10e0j41k1s3o1410f0ik1s3k1410h0hk1o2k10k0h4104k1o1s2k10e0j41k1o1s4o10e0h41o1s7o10e0ck4o1s9410e0c41o1s5o1s5o10f0ek1o1k241k1s4o1410f0jo1s4410g0i41s4k10h0io1s3k10i0h41s3o10j0hk1s2o10141k2o7k241060gk1s3o1seo241030ck3o1slo1030441o4stk10205o1sbo5k245k1o4s4k1020641k1o6k2410h44030^0^0^0^0^0^0^0o410g0mk1o1s1o1k10e0lo1s5k10d0j41o1s6o10d0ik1s7o10e0ho1s6o1k10f0f41o1s6k10h0ek1s5o2k20h0c41o1s4o1k101k1s2o10g0bk1o1s2o2k104o1s2o2k1410c0ao1s2o1k107o1s6k10b0jk1o1s8o10b0h41o1sb0b0fk1o1s9o2k20b0d41o1sao10f0ck1s3o2k24101o1s2o10f0bk1s1o1k14106k1s2o10f0mk1s2o10f0mk1s2o103k2o2k141060mk1s3o2s7o141040mo1se41030jk2o1s4o5s6k1030hk1o1s70541k1o1s2o1k1030ek1o1s4k2o1s2o10f0ck1o1s3o1k103k1s2o10f09k1o2s2o1k14105k1s2o10f07k1o1s3o1k108k1s2o10f0441o2s2o1k1410ak1s2o10f0241o1s2o2k10dk1s2o10fk1o1s2k20gk1s2o10fk30jk1s2o10f0mk1s2o10f0mk1s2o10f0mk1s2o10f0mk1s2o10f0mk1s2o10f0mo1s2o10f0fk2410341s3o10f0go1s2o2s4o10f0hk1s7k10f0ik1o1s5410f0ko1s3k10g0lk30h"
ryu_rle="0^1g0ig50i0hg284g20g0gg181g285g10f0go1g181g284g10f0go2g181g581g10e0g81o181o281o1g1k181g10e0fg181g2o182o1g1o1g20e0f81g1/1g1<1g142/1g20f0bo1k101k1o1g1/1g1/1s141g20h09s1o1s2k1o2<1g2/1<1/2g20g05g5s1o1k1s1o1<1/1g2/5g10g04g1<1/3g1s1o1s1o1g1/2<1g1<1/1g40g03g1<1/3s2o2s1g2/1<1g3<1/2g1o1k104o10a03g1/5o2s2<1g1<1g1/1g1<1g3o6s1o10a03g1/4<1o2s1o1/1<1g2/1g1<2g1o3s1o1s2o30903g1<1/2<1g1o2s1<2/1g1/1g4o1s1o1s3g1<2g10a02g1<1g3<2g1o1s1g1<2w1g1<1/1g2o1s1o1s1o1g1/3<1g10902g1<1/2<1/3g1o1g2w2g6o1s3/5g10901g1/1g1<1/1g1<1/2g1o1g2w3g1<1/2<1o1s1o2g1<1/3g10901g1/2<2g3<1g4w3g5s2o1<1/3<2g10901g1/2g1/3<1g2w2g1w3g1<1/2g1s2g1<6g20801g1<1g1/3<2g2w2g2w1g6o1s1o1g1<4g30801g3/6w4g341/2g2o1s3g80701g2<3/3<1w5g1<141g3s1o1s2g2<1g2<1g1<1g10702g2<4g3w3g3s1o1s2o3s1g1<5g1<1g10702g1<9g2o1s2o1s3o4g3<2g40702g1<7g3o4s4o5g4<1/1<1g20602g1<1g1<4g2o6s3o5g3<4/2g10603g6ofg1/1g5<2/1g10608ofg1/1g241g80508k1oeg2/2<1g1w1g3<1g20509k1oeg3/1g2w1g2<2g1050943o943g1<1/2g2w1g2<2g1050941k14eg3/1g1w1g2<1g10609k1o14ak1o241<1/3g1w1g40608k1o347k1o5g3<1w1g40708o441k1o142k1o4k1o2g1<201g40807k1o342o2k141k1o5k1o2g20d07k2o242o342o5k1o20f07k1o2k142o342o5k1o20f07o442o342o6k20f06k1o442k1o242o6k1410f05k1o2s2o142o1k242k1o6k10f05o2s3o142k1o242o80f04k1o1s542k1o242o3s3o1k10f04o1s6o141k1o242o2s5o10f03k1o1s6o141k1o241o2s6o1k10e03o2s6o3k1o4s7o10e03o1s8o3k1o3s7o10e02k1o1s8o3k1o3s7o1k10d02k1o1s7o3k2o3s7k20d02o1s7o4k2o3s7o1k10d02o1s6o2s1o202k1o2s7o1k10d02o1s8o2k102k1o2s7o20d01k1o1s8o2k102k1o3s6o2k10c01k1o2s6o2k104o3s6o1s1o1k10b01k1o5s2o2k1o104k1o1s1o1s6o1s1o1k10a01k1ob05o2s1o1s1o1s3o1s1o1k10a01k1o8s1o1k105k1o1s3o5s1o20a01k1o7s2o1k106k1o1s3o7k10901k1o6s2o2k107k1o1s2o7k10902obk106k1oak10902obk107k1oa0902k1oak107k1oak10802k1oa09oak10802k1o9k109k1o9k1080241o9k10aoa080241oa0ak1oa0703oa0ak1o9k10703oa0bk1o9k10602oc0ak1o7g20702o8k1o1k10bk1o7g30603k1o5k101k10ck1o7<1g20604g2o2g20ek1o1k1o1k1o2g1<2g10604g1<2g40ek101o101g2<3g20503g1<4g1<1g10hg1<6g20402g1<6g30fg3<5g204g2<4g1<2g30fg1/2g803g2<1g3<2g40fg1<1/1g1/1g1/1g1<1g203g1<1g1/1g1<1/1<1g30ggb03"
antiriad_title_rle="20202020202020202020200jg1w5g105w#0.0jg1w6g104g1w!0/0kg1w6g104g1wy0?0lg1w6g10gw50lg20:0mg1w70fw50kw40;0ew6g102g1w706g1w403w503w4g102g1w404w607g1w40cg1w6g102g1w6g10b0dg1w703w805g1w403w502g1w4g102g1w403w806g1w40cw7g102g1w70b0cg1w803w8g104g1w403w502g1w4g102g1w402wa05g1w40bw8g102g1w80a0cw903w9g103g1w403w502g1w4g102g1w4g1wc04g1w40bw8g102g1w8g1090bwa03wag102g1w403w502g1w4g102g1w902w703g1w40aw9g102g1w9090ag1wa03wc01g1w403w502g1w4g102g1w804w702g1w409g1w9g102g1wa080awb03w5g1w7g1w403w502g1w4g102g1w706w701g1w408g1wag102g1wag10709g1wb03w4g101g1wb03w502g1w4g102g1w6g107w6g2w408wbg102g1wb0704g1w1g101g1w6g1w503w4g103wa03w502g1w4g102g1wk01g1w403g103w7g1w4g102g1w4g2w60604w3g1w701w503w4g103g1w903w502g1w4g102g1wj02g1w402g1w2g101w6g2w4g102g1w4g101w6g10503wb02w503w4g104g1w803w502g1w4g102g1w4g1wd03g1w401g1wag102w4g102g1w4g102w60502g1wag102w503w4g105g1w703w502g1w4g102g1w402g1wa04g1w4g1wb03w4g102g1w4g102g1w60402wb03w503w4g106g1w603w502g1w4g105w203g1w805g1w4g1wa04w4g102g1w4g103w6g10303g1w804w503w4g107g1w503w502g1w40181+58104w706g1w402w904w4g102g1w4g104w60304g1w6g104w503w4g108g1w403w502g1w2g101+904w705g1w403w7g104w4g102g1w4g104w70204w8g103w503w4g108g1w403w502g1w1g101+1810181+4s1}1+104w704g1w403w8g103w4g102g1w4g105w6g10103wag102w503w4g108g1w403w4g103g101+20381g1s3g1+204g1w603g1w402wag102w4g102g1w4g105g1w60102g1wbg101w503w4g108g1w403w30181+20281+302g1w2!1s1+3810181+2w702g1w401wcg2w4g102g1wh0102wj03w4g108g1w403g202+38101+581g1w1g1+58101+4g1w5g101g1w3g101wig102g1wg0201g1w601g1wb03w4g108g1w40281+382s282+6g2w1+601+1s281+3}1w3g101g1w1g101w7g1wbg102g1wf0301w603g1wa03w4g108g3}1+4s3+101+381+482g20181+581+381+1s3+3}18103g1w603wag102g1we0401w604g1w903w4g10781+4s6+201+3820e+382+3s4+5g1w5g104w9g102g1wd0502w406g1w803w4g105+4s4+48401+307g107+385+4s4+381w306w8g102g1wc0603w2g107g1w703w4g10581+1s2+485+301+3810481+30581+282+385+4s2+1}1w208w7g102g1wb070fg505g30781+284+882+28104}1s2+1}104+382+883+38101g10ag604ga0806gs0282+d0181+203+2s2+2810281+282+c8201w103gq0b06wug181+c83+28101+4s1+3810181+283+b82w2g101ws0a07wv0f+301+4s1+401+30ew401g1wr0b08wu028302820a+4s1+40983028301w301g1wr0c09ws02+58409+90984+504g1wq0d0#81+5810181+188+28105+387+18201+60(0#81+5810281+88102+2s1+1810181+98102+6810*0@+2s1+4810381+58103+68103+60481+70&0z81+3s1+381018308+a81088202+4s1+30^0z81+802+286+4810481+487+1810181+80^0z81+80281+981028502+a0281+8810%0z85+3810381+6810281+7810281+68103+4850%0%81+2068304+b04830581+20_0!81+382+10a81+403g10281+4810a+10181+3810^0z81+5098201+4g881+3830a+50^0z+609+28101+20a81+201+309+5810%0y81+281+1820881+30181+1g109}1+18101+30982+40%0y81+4810981+281028102g203g202810281+20a+4810%0x81+681088101+304g1!103!105+3820881+60$0x+80581+68104g1s1!2s2g104+70581+80#0v81+48102+30481+68204g2!1g205+705+30281+4810!0t81+70181+30481+704g2!1s1g20481+705+382+70z0t81+a810581+6}1g202!1s1!3s1g101g1s2!2}1+406+481+60z0u81+6830681+4!1s2!1g102g1!2g1!202g1!2s3g1+30783+6810z0v+28202830681+3!1s2!1g104g1!303g2!1s4}1+207830281+30!0_81+2g1s4!1g104g1!1g105!1s4}1+1810}0)+481/1s3g309g3!1s1/1!181+3810[0(+501!1s2!1g1!208!1/1s1!4g101+50=0(+502g1!1g1s3!204g1!1s4!1g103+50=0(+504!1s5g103s6!2g3}1+40=0(+501g201g1s5/1!101!1s5!2s2!2g1+40=0(+5g1s2g101g1!1s3/1!101!1s3/1!1g2s4g1+40=0(+5s4g101g2!3g3!3g201g1!1s2!1g1+40=0(81+183s3!10hg1!4}1830=0+g1s2!1g106g407g1!1s2!10{0+!3g106g1!2g1s1g303g1s4g10{0-g1s1g1038103g1!5g302g1s3/1!20{0_81s2g2!1018202g1!301!302s3!401810}0_81s2g1!1g1018104g301g3s3!2g301+20}0)81g1s2!20181+18103g1!2g3s2!1g304+2810]0_!1s1!2g182+18103g301g2!2g10781+1810]0*81+181!1s2!10281+181s1}20h81+3810+0&81+281s2!101+28103s2}2820c+6810-0)!1s2!101+382s1}1s1820e+4820+0&8101!1s2!1g101+1810181}181s1}2g1}2810g820-0%+3g1!2g201+181g40181g1810181}1810b81+7810)0$+401g1!1g5!1s2!101g2s2g10c81+9810(0#81+18401g201g1!1s4/1g10181}1g382}10882+2870(0#+38402g1!1s5!1g2018102}1s1}10989+30*0r83}281}1w2}10181+7g1!1s4!2g402g30982+a8101w4}1w1}3830u0l82}3/1w1/9810186w1!1s2!4s2!10g82+487}1/1s1/3s1/3w3}4810p0g}4w1/c85/1}18103g1!3g2s3!2g1098307820581}1/2s1/5s1/9w1}2820l0b81}4w1/5}1w1/2}181}2w2/5s4/3w1g101g3s1!1g1048104s1/3s18104/3g1}1w2/4w1}186}1/f}1830h0883}2w1/8}2w2/4s1/1sc/105g104}1/204s4/104}1s1/3w5/bw3}3w7}481}1820f0883}2w2/6w1}2w1/6s7/1s5/18107}1/38104}1w1/30481w2/7sb/3}2/9w1}281}1820f0784}1w2/bw2}2w1/cw1}2810381}1/5w1088105w1/3sc/3s1/4}1/2s2/8w1}18201830c07}183}1w2/8s3/3}282w2/4w1}182g1s8/3w1810dg1!1w2/5s9/1s2/4}1/2s4/8w1}181}2820c08810182}1/1w1/b}2/5}5/3}2/1s4/1g1}1810g!1s2g103w2/3s7/6}1/2s6/7}2830e0983}4w2}1w1}1w2}1w1/3s5/3s1/1s2/2w181}2810kg1!1s2!1g10581}1/aw1}1w1/3s2/7w3}281}1810f0c}181}5w3/5s2/1s9/2}20p!1s3!107}1/6w1}1w1/3s4/9w1}3820g0e83}1w3/bs7/2}10qg1!1s3!10481w2}5/1w1}2w1/dw2}1820j0i81}3/1w1/3s1/4s1/1s1/80q!2g1!2g1w2/9s2/381}1/8w1}28101810l0k810182}3w2/1w1/d}10k81w1}101g1!3g1w1/1s5/3s3/2w1/3w1}6840o0q810184w5/1w1/7w182}1/3}1810a}1/2}1g1!1g2}1/1w1/ag1/1w1}6810w0y810182}7w4/5w10a}1/3w1}181}1w4}981}2810#0-81}70b}281}582}18101820-2020202020202020202020202020202020202020202020"

function test(x)
 print("hi "..x)
end

base64str='0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()_-+=[]}{;:<>,./?~|'

function explode_hex(s, delimiter)
 local retval,i=split(s,delimiter,false)

 for i=1,#retval do
  retval[i] =("0x"..retval[i])+0
 end
 return retval
end

function explode64(s)
 local retval,lastpos,i = {},1,2

 while i <= #s do
  add(retval,base64decode(sub(s, lastpos, i)))

  lastpos = i+1
  i += 2
 end
 return retval
end

function base64decode(str)
    val=0
    for i=1,#str do
     c=sub(str,i,i)
     for a=1,#base64str do
        v=sub(base64str,a,a)
        if c==v then
            val *= 64
            val += a-1
            break
            end
     end
    end
    return val
end

function base64encode(val)
 local res,cur,i="", val
 while cur > 0 do
  i=cur%64
  res=sub(base64str,i+1,i+1)..res
  cur=flr(cur/64)
 end    
 return res
end

function spr_rle(table,_x,_y)
 local x,y,i,col,rle,w=0,0,3,0,0,table[1]
    while i <= #table do
        col = shr(table[i] & 0xff00,8)--% 16        
        rle = table[i] & 0xff
        i+=1
        if col!=0 then
            --rectfill is slightly faster
            --line(x+_x,_y+y,_x+x+rle,_y+y,col)
         rectfill(x+_x,y+_y,x+_x+rle-1,_y+y,col)
        end
        x+=rle
        if x >=w then
            x = 0
            y += 1
        end
    end
end

function spr_rle_flip(table,_x,_y)
 local x,y,i,col,rle,w=0,0,3,0,0,table[1]
    _x+=w
    while i <= #table do
        col = shr(table[i] & 0xff00,8)--% 16        
        rle = table[i] & 0xff
        i+=1
        if col!=0 then
            --rectfill is slightly faster
            --line(x+_x,_y+y,_x+x+rle,_y+y,col)
         rectfill(_x-x-rle+1,y+_y,_x-x,_y+y,col)
        end
        x+=rle
        if x >=w then
            x = 0
            y += 1
        end
    end
end

function draw_rle(table,_x,_y)
 local x,y,i,col,rle,w=0,0,3,0,0,table[1]

    while i <= #table do
        col = shr(table[i] & 0xff00,8)--% 16        
        rle = table[i] & 0xff
        i+=1
        --rectfill is slightly faster
        --line(x+_x,_y+y,_x+x+rle,_y+y,col)
        rectfill(x+_x,y+_y,x+_x+rle-1,_y+y,col)

        x+=rle
        if x >=w then
            x = 0
            y +=1
        end
    end
end

function setpal(palstr)
    local i,palindex
 palindex=explode_hex(palstr,",")
    for i=1,#palindex do
        pal(i-1,palindex[i],1)
    end
end

function pal2()
    local i
 for i=0,15 do
        pal(i,128+i,1)
    end
end

function cprint(txt,x,y,cols)
 local len,org=#txt*4+4,clip() 
 local a
 x=x and x or 64-len/2
 for a=1,3 do
  print(txt,x,y,cols[a])    
  clip(x,y+a*2,len,2)
 end
 clip(org)
end

Is there interest for something like this?
Not sure if I should invest the time to make the python script "presentable" - right now it's quite a mess, and like I said not feature complete.

P#79494 2020-07-17 13:28 ( Edited 2020-07-20 17:22)

[ :: Read More :: ]

Cart #ghoulsatemyclassmates-0 | 2020-07-06 | Code ▽ | Embed ▽ | No License
2

Hello!
just started with pico8, and played around with it.. this is (at the moment) just something to get used to the API. There's a function in there, that might be interesting for some of you, though. It prints a string with different colors per scanline.

function _draw()
 cls()
 cprint("colored text",nil,20, {7,11,3})
 cprint("pass nil for x to center",nil,30, {12,6,13})

 cprint("press ❎ to start",nil,80,{9,10,9})
end

function cprint(txt,x,y,cols)
 local len,org=#txt*4+4,clip() 
 local a
 x=x and x or 64-len/2
 for a=1,3 do
  print(txt,x,y,cols[a])    
  clip(x,y+a*2,len,2)
 end
 clip(org)
end
P#78976 2020-07-06 09:10 ( Edited 2020-07-06 09:11)

Follow Lexaloffle:          
Generated 2024-03-29 07:47:25 | 0.087s | Q:32