Log In  

EDITED 2/14/2020

I came up with several functions that I think would go good in pico8 and would reduce file size for larger games

--math

function ldx(d,l)  --stands for lengthdirx
    return cos(d)* l or 1
end
function ldy(d,l) --stands for lengthdiry 
    return sin(d)* l or 1
end
function ptl(x1,y1,x2,y2) --stands for point length
    return sqrt(((y2-y1)^2)+((x2-x1)^2))
end
function ptd(x1,y1,x2,y2) --stands for point direction
    return atan2(y2-y1,x2-x1)
end
function wrp(v,l,h) -- stands for wrap
    local o=v
    while(o < l) o += (h-l)
    while(o > h) o -= (h-l)
    return o
end
function rng(v, l1, h1, l2, h2) -- stands for range
    return l2 + (v - l1) * (h2 - l2) / (h1 - l1)
end

--vectors

function vec(vx,vy) --stands vector
    local m=
    {
        __eq =function(a,b)
            return (a.x==b.x and a.y==b.y)
        end,
        __add=function(a,b)
            return vec(a.x+b.x, a.y+b.y)
        end,
        __sub=function(a,b)
            return vec(a.x-b.x, a.y-b.y)
        end,
        __mul=function(a,b)
            return vec(a.x*b.x, a.y*b.y)
        end,
        __div=function(a,b)
            return vec(a.x/b.x, a.y/b.y)
        end
    }

    local v=
    {
        x=vx,
        y=vy,
    }

    return setmetatable(v,m)
end

--tables

function new(orig) --stands for new table
    local orig_type = type(orig)
    local copy
    if orig_type == 'table' then
        copy = {}
        for orig_key, orig_value in next, orig, nil do
            copy[deepcopy(orig_key)] = deepcopy(orig_value)
        end
        setmetatable(copy, deepcopy(getmetatable(orig)))
    else -- number, string, boolean, etc
        copy = orig
    end
    return copy
end

some notes..

  • while ldx, ldy, ptl and ptd wouldn't save alot of space they would be easier to understand and would definitly be used by newer programmers

  • the wrp function would wrap a number around a low and high value and would be useful besides just saving space.
    for example if you wanted to make a spaceship game with wrapping borders

  • rng is another useful function that would take a value and 2 ranges of numbers and return a converted value between those ranges.

  • vec returns a 2d vector that allows operating on other vectors

  • new would just return a deep copy of the table u give it and would make oop easier and take less space up in the cart
P#55218 2018-08-15 22:36 ( Edited 2020-02-15 00:01)

How about some rotation in there too ? Not just rotating sprites but rotating the mapper too.

Add CHR() and ASC() for 8-bit.

Command to bring up standard FILEBOX, can IMPORT or EXPORT external files in it.

Ability to have sprites that act like hardware, they appear on top of everything else and do not require the background beneath them to be refreshed.

Ability to import/export font used in IDE editor. Would be 4x6 pixels, 1-bit per pixel.

Ability to change the pitch of any played sound without having to create new sounds just for that one pitch.

Ability to have numbers greater than 32767, say long integer at -2147483647 to +2147483647.

Ability to have 60fps without requiring the function for it. Flip(60) for instance.

Add INSTR() and RINSTR() ability for strings.
Hex(), Oct(), and Bin() without requiring string input.

Fix Cstore() to work correctly in export to Online .JS/HTML, Offline .JS/HTML, Bin/EXE, Mac, Linux.

Change key repeat delay and speed not just for IDE but for BTNP() as well.

Likely there are further functions and features other customers and members would like to have.

Thanks for Pico-8 , Zep !

P#55221 2018-08-15 22:56 ( Edited 2018-08-16 02:56)

@Shadowblitz16
FYI if you are not aware, zep has already said that he considers PICO-8 to be API complete at this point (as of 0.1.11). So, sorry to be the bearer of bad news, but I imagine any additions to the existing small and cozy API are unlikely.

see https://www.lexaloffle.com/bbs/?tid=30219

P#55244 2018-08-16 13:22 ( Edited 2018-08-16 17:22)

thats too bad since pico8 has limited memory
but its definitely still fun to use

P#55265 2018-08-16 17:26 ( Edited 2018-08-16 21:26)

SB, you might move this to category "SUPPORT" so ZEP will be certain to see it.

P#55329 2018-08-17 11:59 ( Edited 2018-08-17 15:59)

i'm not sure how to do that :(

P#55353 2018-08-17 22:26 ( Edited 2018-08-18 02:26)

Hi SB:

  • Click EDIT at the top and you will have the ability to change category as this is your own personal thread.

Please let me know if you are still having difficulty with this.

P#55354 2018-08-17 22:52 ( Edited 2018-08-18 02:52)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 10:41:12 | 0.017s | Q:18