Log In  

I really wish you could use the alternate colors (the ones shown in this video: https://youtu.be/AsVzk6kCAJY) in the sprite editor, because one of the colors is perfect for a sprite I need, and none of the other base colors do it for me. It would be nice if you could hold down a key combo and the colors would change to the alternate ones.
Edit: And yes, I understand that you can only have 16 colors on screen at a time. But it would be nice if you could toggle certain colors, so you only have to replace some of them.

P#84249 2020-11-15 04:20 ( Edited 2020-11-15 04:24)

poke(0x5f2e,1)
? does this not work?
along side keeping track of pal()s?

P#84254 2020-11-15 09:06 ( Edited 2020-11-15 09:06)

It probably would, but I only want to replace 1 or 2 of the colors.

P#84271 2020-11-15 16:14

I'm very confused.. you could just store a table with the colors you want and then choose them that way if you wanted, you don't have to change all colors to altpal, it's done with applying 128+ to the value if in screenpal mode.

t={
 0,1,2+128,3,4,
 5,6+128,7,8,
 9,10,11,12+128,
 13+128,14,15
}
for i=0,15 do
 pal(i,t[i+1],1)
end

for i=0,3 do
 for j=0,3 do
  rectfill(i*32,j*32,i*32+32,j*32+32,i+j*4)
 end
end
function _draw() end

-- this example is a lot more fun since it randomly chooses
local t={
 0,1,2,3,4,
 5,6,7,8,
 9,10,11,12,
 13,14,15
}
for i=0,15 do
 local rng=flr(rnd(2))*128
 pal(i,t[i+1]+rng,1)
end

for i=0,3 do
 for j=0,3 do
  rectfill(i*32,j*32,i*32+32,j*32+32,i+j*4)
 end
end
function _draw() end
P#84277 2020-11-15 18:15 ( Edited 2020-11-15 18:18)
1

so, if I wanted to replace white with the color in the image, how would I do that?
Also, I'm very new to Pico-8, so you'll have to forgive me if I don't understand some things.

P#84278 2020-11-15 18:28 ( Edited 2020-11-15 18:31)
1

Replacing a colour with another looks like this: 'pal(9, 2)' means that the next drawing operations will use burgundy for orange (colour index 9), then you can reset with 'pal()' so that operations after that use regular orange.

To replace all uses of white with burgundy, regardless of if they were drawn before or after the pal call, add a parameter: 'pal(7, 2, 1)'

(So we say that the first version changes the draw palette, and the second the screen palette.)

For secret colours, it is required to use the second form: 'pal(7, 135, 1)' replaces all uses of white (colour index 7) on screen with the custom pale yellow.

To see your custom palette in the editor too, add this to your code after your pal calls: 'poke(0x5f2e,1)', then run the game and press Escape to go back to editor.

Finally, to redefine many colours at once, you have two options:

  • 'pal({[9]=1, [10]=2})' table with specific keys set to change these indices

  • 'pal({1,1,5,5,5,6,7,13,6,7,7,6,13,6,7})' table with 15 values to change all indices from 1 to 15 (you can add '[0]=4' at the beginning to also change index 0)

These two versions can also have '1' as second parameter to change the screen palette instead of the draw palette.

And have a look at these tools:
https://www.lexaloffle.com/bbs/?tid=35254
https://www.lexaloffle.com/bbs/?tid=39910

P#84280 2020-11-15 18:50 ( Edited 2020-11-15 18:56)

cool beans, thanks!

P#84288 2020-11-15 20:47

[Please log in to post a comment]