Log In  

As mentioned in another thread, I had this bug while testing tline().

Notice that I use ctrl+click to swap c1 to c2, but some pixels are not changed.

I used a lot of commands and tools while doing it the first time, so it's hard to know what triggered it (1 and 2 to navigate between colors, V and F to flip, Ctrl+click to swap colors, ctrl+C, ctrl+V, copied sprites to map). I didn't use the new shape tool.

I tried to reproduce the bug with many combinations of the mentioned commands and tools with no success.

Here is a Ctlr+Y of the steps that introduced the bug (no bugs prior to that).

Notice that the grey pixels that only appear when running the cart aren't on the same pixels I drew, but 1 pixel to the right.

After that, I saved the card for the Nth time, but for some reason, I couldn't undo anything before saving the file. And the color bug also disappeared. Maybe the color bug has to do with something wrong with the Undo/Redo chain..?

P#76829 2020-05-18 13:20 ( Edited 2020-05-29 23:01)

:: Munro

ooh nice rotating sprite!

is possible to get the code for that?

P#77331 2020-05-28 20:15

@Munro Sure, here it is.

function rspr(sx,sy,sw,sh,dx,dy,a,f)
sx,sy,dx,dy are center,
not corner
 f=f and -1 or 1
 for i=-sh,sh do

SX, SY, SW, SH, DX, DY as seen in SSPR.
SX, SY, DX, DY are for the center of the sprite, not the corner like in other draw functions, and also determine the center of rotation.
SW and SH count in both directions from the center, so it's essentially doubled.

A is angle.

F is flip.

Notice that the last line argument is 1, so you have to set the sprite flags accordingly (or change/remove this argument).
In case you're not familiar with tline, the images are picked from the map, not the sprite area, so this function uses the map too, not sprites.

P#77371 2020-05-29 13:27
:: shy

I'd recommend an optimization here, of pulling the trig and divisions out of the for loop. It should give you much better performance. :)

function rspr(sx,sy,sw,sh,dx,dy,a,f)
 f=f and -1 or 1
 local sina8 = sin(a)>>3 --equivalent to sin(a)/8, but faster
 local cosa8 = cos(a)>>3
 sx>>=3 --since only used as sx/8 in loop, might as well change these variables as well
 for i=-sh,sh do
P#77382 2020-05-29 15:18 ( Edited 2020-05-29 15:31)
:: Munro

very nice, thank for the explanation and code!

P#77383 2020-05-29 15:23

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-07-06 19:27 | 0.025s | 2097k | Q:19