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



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 !



@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.



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



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



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.
[Please log in to post a comment]