Log In  
Follow
Werxzy
SHOW MORE

Cart #shmup_1k_werxzy-0 | 2024-02-23 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

After seeing LokiStriker's and Achie's shmups made in 1024 compressed bytes, I wanted to give it a go.

Here's the uncompressed source code.

--1k shmup
--werxzy

-- enemy data
ty=split("⁶:425affffe7662400,0.01,0,7,0,0.3,0,-0.0001,2,5,5`⁶:425affffe7662400,0.01,0,7,0,1.1,0,-0.01,1,3,3`⁶:22227f7f2a361c08,0,0,9,0,0.3,0,0.02,4,1,3`⁶:425affffe7662400,0,0,13,0,0.1,0,0,3,30,20`⁶:3c42bdbdbda5423c,0,0,5,0,0.25,0,-0.0005,5,20,25","`")
-- bullet data
bty=split("●,1,0,0,0.8,1,60`✽,1,-15,15,0.4,3,200`✽,0,-120,10,0.4,7,100`\feミ,0,0,180,1,2,20`✽,1,0,36,1,10,30","`")
cartdata"shm1k_werx"
function _init()
    en,bul,pb,px,py,ph,pi,pc,sc = {},{},{},64,80,3,0,0,0
end

function _update60()
    cls()
    if ph ~= 0 then
        -- spawn regular enemy
        if t() % 2 == 1 then
            e=add(en, split(ty[rnd{1,2,3}]))
            e[7]=rnd(e[2])-e[2]/2
            e.r,e[2]=rnd(20),rnd(100)+10
        end

        -- spawn boss enemy
        if t() % 20 == 1 then
            e=add(en, split(ty[rnd{4,5}]))
            e.r,e[2]=rnd(20),64
        end

        -- player movement and drawing
        p_=btn(4)and 0.5or 1.2
        px+=(tonum(btn(1))-tonum(btn(0)))*p_
        py+=(tonum(btn(3))-tonum(btn(2)))*p_
        px=mid(px,120)
        py=mid(py,120)
        ?(pi%20<=10and"⁶:081c362a7f7f3614"or""),px,py,11
        -- player fires
        if pc<=0 and btn(4)then
            pc+=10
            add(pb,{"⁶:1c3e3e1c1c080800",px,py,3,0,-3.5,0,0})
            ?"\as3i7gc",0,0
        end

        -- update bullets, and enemy ships
        for t in all{pb,en,bul} do
            for o in all(t) do
                o[2]+=o[5]
                o[3]+=o[6]
                o[5]+=o[7]
                o[6]+=o[8]
                if(not col(o,0,0,128,128))del(t,o)
                if o.r then
                    o.r-=1
                    if o.r<0then
                        b=split(bty[o[9]])
                        o.r=b[7]
                        nb(o[2],o[3],unpack(b))
                    end
                end
                ?unpack(o) -- draws ship or bullet
                 -- check player collision with enemy ships or bullets
                if pget(px+3,py+2) ~= 0 and pi==0 and t ~= pb then
                    ph-=1
                    pi=90
                    if(t==bul)del(t,o)
                    ?ph==0 and "\a<i6g1g2g1g2g1g2g1" or "\a<i6g1",0,0
                end

                if t==en then
                    -- check collision with each bullet
                    for b in all(pb) do
                        if col(o,b[2],b[3],5,5)then
                            del(pb,b)
                            o[10]-=1
                            ?o[10]==0 and "\a<i6g1g2g1g2g1g2g1" or "\a<i6g1",0,0
                            if o[10]==0 then
                                del(t,o)
                                sc += (o[11]>>16)*50
                            end
                        end
                    end
                end
            end
            if t == pb then
                pset(px+3,py+2,0)
            end
        end

        for i = 1,ph do
            ?"♥",i*6,118,8
        end

        -- high scores
        ?tostr(sc,2),6,1
        ?tostr($0x5e00,2)
        poke4(0x5e00, max($0x5e00, sc))
        -- cooldowns
        pi = max(pi-1)
        pc = max(pc-1)
    else
        ?"game over\n"..tostr(sc,2),50,50
        if(btnp(5))_init()
    end

end

function col(o,x,y,w,h)
    x-=o[2]y-=o[3]
    return x<8and x+w>0and y<5and y+h>0
end

-- bullet generation function
function nb(x,y,ch,pt,as,ad,sp,c)
    a=atan2(px-x,py-y)*pt+as/360
    for _=1,c do
        add(bul,{ch,x,y,8,cos(a)*sp,sin(a)*sp,0,0})
        a+=ad/360
    end
end
P#141804 2024-02-23 02:23

SHOW MORE

I've been working on a table to binary converter that can help compress data and store it in cart rom. I know there have been different attempts in the past, but this version aims to fit only the necessary data and leaves the types to a format string. Though it's only really useful if you have some of the following.

  • A lot of data in tables
  • A consistent and known table format
  • A variety of table formats
  • Multiple carts

It works by taking in a table, a writing address, and a format, that generally look like this

tab = {1,2}
form = "[#8,#8]" -- an indexed array of 2 unsigned 8-bit integers
-- form = "[#4,#3]" -- also works with a different number of bits (up to 16)
tab2bin(tab, 0x8000, form) -- compress table to binary at 0x8000
tab2 = bin2tab(0x8000, form) -- decompress table

Though if a table can a varying number of entries, so it instead it would be better to loop through entries.

tab = {1,2,4,8,16,32,64,128}
form = "[#8(#8)]" -- can have up to 255 entries due to looping through (#8) a number of times read from the previous #8

There are also ways to store values that are expected to have decimals or be in a different range

tab = {-10, 1.25, 0x1234.5678}
form = "[#8-128,#8>4,#16>16@dec#16+dec]"
-- "-" subtracts from the read value 
-- ">" shifts the read value right
-- #16>16@dec#16+dec reads the first 16 bits and last 16 bits of a full fixed-point number and stores them in 32 bits

There's also support for strings, booleans, tables with keys(though not mixing them with indexed tables), and custom compression/decompression functions.

The table to binary (tab2bin) compression function is about 913 tokens. While the binary to table (bin2tab) decompression function is about 536 tokens. However, some of the lines of code can be removed to reduce the token count. I would recommend storing your data in a string format initially, only using tab2bin when packing the data for the final carts, and only using bin2tab in the final carts.

https://github.com/Werxzy/tab2bin

The full source and more details are on the github page, since there may be changes in the future. Feel free to send any issues or pull requests to help improve it.

P#139161 2023-12-25 15:54

SHOW MORE

Cart #sb_1800_v1-2 | 2023-10-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

I recently finished a game for the Cre8 Jam. You control a robot through commands to move through and scan a 3d environment. I would have added a bit more or fixed it up better, but I'm about out of time for the jam and really low on tokens. Even after using special functions to lower the token count.

You can get more information through the HELP command, but the main commands are:

MOVE (direction) (amount)
TURN (left/right) (amount)
WAVE
SWITCH [name]
SCAN (dot size)

And another important one is RSCAN, which is just SCAN, but repeatedly scans.

I would highly recommend checking out the itch.io page, as its design is special for this game.
https://werxzy.itch.io/sb-1800 The source code for the game and the map editor are also available on the itch.io page.

After an update you can now use controller inputs

MOVE - up/down
TURN - left/right
WAVE - X
SWITCH - O

SCAN is automatic

Saved data is shared between the Command and Controller modes.

P#135093 2023-09-29 08:48 ( Edited 2023-10-18 22:23)

SHOW MORE

Cart #slime_light-3 | 2023-08-29 | Code ▽ | Embed ▽ | No License
13

I just finished a game for a 1-bit game jam, requiring the use of only 2 colors . Slime's light is a small puzzle game that uses light and shadow to activate and deactivate doors and lamps. Unfortunately, I had to minify the code to make it fit into a single cart. You can access the unminified code on the itch page.

Controls:
Arrow keys - move
X - pickup / drop
Z - slow movement

P#133251 2023-08-19 03:42 ( Edited 2023-08-29 19:48)

Follow Lexaloffle:          
Generated 2024-02-26 23:29:50 | 0.084s | Q:18