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

When running in full screen on macOS Big Sur, the display is around the screen is not cleared, resulting in a pattern of red lines.

P#86345 2021-01-11 08:36

[ :: Read More :: ]

Cart #rspr_greygraphics-3 | 2019-05-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

Hi,

I made a small demo of a function I have been working on. It is called rspr and can draw sprites with any rotation.
It has the following signature:

rspr(sx,sy,sw,sh,a,dx,dy,dw,dh)
--  sx,sy,sw,sh - pos,dimensions in spritesheet
--  a - angle
--  dx,dy,dw,dh - pos,dimensions on screen

It takes the angle in the same format as sin and cos and draws the sprite rotated around dx,dy.
You can scale the drawn sprite with dw,dh and it can draw sprites of any size.
However, large values for dw and dh cause some serious performance losses, so you should avoid scaling up sprites to unreasonable sizes.

Due to this slowdown, I would really like to have this function implemented natively in pico-8. What do you think, @zep?

Thank you, @freds72, for the suggestion of inlining the function calls. It does speed up the function remarkably.

P#64178 2019-05-04 22:55 ( Edited 2019-05-05 17:52)

[ :: Read More :: ]

When loading a file via #include, pico-8 crashes when running the program from the command line, like "run".
The code loaded is tested and used correctly and does not cause the crash. Also, running via Ctrl+R works and behaves as expected.

Editor:

Result:

#include multi.lua
m=multi(0,17)
m:draw(10,10)
-- this works when run with ctrl+r
-- it crashes when running with "run"

multi.lua

local multi = {}
multi.__index = multi
setmetatable(multi,{
    __call=function(cls,...)
        return cls.new(...)
    end
    }
)

local function getxy(index)
    local y = flr(index / 16)
    local x = index - y * 16
    return x,y
end

function multi.new(tl,br)
    local self = setmetatable({}, multi)
    local tx,ty = getxy(tl)
    local bx,by = getxy(br)
    local w = bx - tx + 1
    local h = by - ty + 1
    self.tx = tx
    self.ty = ty
    self.bx = bx
    self.by = by
    self.w = w
    self.h = h
    return self
end

local function getindex(x,y)
    return x + y * 16
end

function multi:draw(x,y)
    for u=0,self.w - 1 do
        for v=0,self.h - 1 do
            local index = getindex(self.tx + u, self.ty + v)
            spr(index, x + u * 8, y + v * 8)
        end
    end
end

It also would be great, if the folder for includes was the same folder as the cartridges (AppData).

P#63537 2019-04-15 16:04