So I have a 4-colour game with 8-bit colour depth in 320x420 resolution and in the game setup the software driver is set as graphics driver.
But for some (unknow to me) reason the object sprite's black color isn't updating after updating the palette codewise.
The same black in the room's background is correctly updating though...
I hope someone can explain this tpo me, I can't figure out why it works correctly for the room bg but not for object sprite...
This is the colours setting panel:
Spoiler
(https://dam1976.home.xs4all.nl/AGS/curse/colours.png)
Here's an object's sprite seting:
Spoiler
(https://dam1976.home.xs4all.nl/AGS/curse/sprites-object_details.png)
Here's the room background and the object with said sprite:
Spoiler
(https://dam1976.home.xs4all.nl/AGS/curse/roombg.png)
when running this to update the palette to game boy colors:
Spoiler
//black
palette[0].r = 4;
palette[0].g = 14;
palette[0].b = 4;
//cyan:
palette[1].r = 12;
palette[1].g = 24;
palette[1].b = 12;
//magenta:
palette[2].r = 34;
palette[2].g = 42;
palette[2].b = 4;
//white
palette[3].r = 38;
palette[3].g = 46;
palette[3].b = 4;
UpdatePalette();
This is how it looks, for some reason the object's black color is not changing...
It has the same black (sprite-wise) as the background... (the black color of the gate is also not changing correctly, which is another object)
Spoiler
(https://dam1976.home.xs4all.nl/AGS/curse/run_game_after_paletteupdate.png)
There may be some quirks when you change the "fixed" colours (usually means #0 - 16 (https://www.adventuregamestudio.co.uk/wiki/256_Colour_Tutorial_Part_1#Making_your_first_sprites_in_256_colours)) of the palette, especially entry #0.
Instead use the entries after #16 (i.e. #17 onwards, or for better management, use #32 - 35 for these backgrounds, which would be the first 4 entries of the third row).
Thanx for responding, will try that!
I've seen some more quirks indeed, all seem to be related to entry #0...
Well, I tried but I'm still failing to update the black colour of the object-sprites...
1. in file>preferences, option 'remap palette of room bg into allocated background palette slots': no
2. in colours panel :
slot 0-4 are set as 'background' colourtype, using the following colours:
slot 0: 0, 0, 0
slot 1: 84, 252, 252
slot 2: 252, 84, 252
slot 3: 252, 252, 252
slot 32-35 are set as 'gamewide' colourtype, using the (same) following colours:
slot 32: 0, 0, 0
slot 33: 84, 252, 252
slot 34: 252, 84, 252
slot 35: 252, 252, 252
3. object sprite has been imported using the following options:
import options:
-import alpha channel: no
-remap palette: yes
-use room background: no
Transparant colour:
-bottom-right pixel (which is 84, 84, 252)
(the room's object sprite and background both contain the same 4 cga colors as shown in the 4 color slots of ags' colours panel, see link to both files in bottom of post)4. running the palette update, the 4 colours of the background do change correctly, but the object sprite's black color is not changing:
Spoiler
//room background:
//black
palette[0].r = 4;
palette[0].g = 14;
palette[0].b = 4;
//cyan:
palette[1].r = 12;
palette[1].g = 24;
palette[1].b = 12;
//magenta:
palette[2].r = 34;
palette[2].g = 42;
palette[2].b = 4;
//white
palette[3].r = 38;
palette[3].g = 46;
palette[3].b = 4;
//objects:
//black:
palette[32].r = 4;
palette[32].g = 14;
palette[32].b = 4;
//cyan:
palette[33].r = 12;
palette[33].g = 24;
palette[33].b = 12;
//magenta:
palette[34].r = 34;
palette[34].g = 42;
palette[34].b = 4;
//white
palette[35].r = 38;
palette[35].g = 46;
palette[35].b = 4;
UpdatePalette();
Result:
(https://dam1976.home.xs4all.nl/AGS/curse/result.png)
Here's the original (cga-colors) background and the object sprites:
https://dam1976.home.xs4all.nl/AGS/curse/BG.png
https://dam1976.home.xs4all.nl/AGS/curse/object1.png
https://dam1976.home.xs4all.nl/AGS/curse/object2.png
Try setting remap palette to "no". Setting it to "yes" would probably remap the black colour of the sprites to colour entry #0.
(The advices on sprite importing in my linked tutorial above should still be relevant.)
I'm utterly confused now, nothing seem to work. 8-0
I'm still not able to switch the black sprite color for the objects to dark green (using UpdatePalette), and importing sprites using "remap palette" set to "no" messes up some sprites...
It seems I have to give up on it, i just can't seem to get it to work correctly.
Some info
slot 0-4 are set as 'gamewide' colourtype, using the following colours:
slot 0: 0, 0, 0
slot 1: 84, 252, 252
slot 2: 252, 84, 252
slot 3: 252, 252, 252
slot 16-19 are set as 'background' colourtype, using the following colours (the same as the 4 gamewide colors):
slot 32: 0, 0, 0
slot 33: 84, 252, 252
slot 34: 252, 84, 252
slot 35: 252, 252, 252
all other slots are unused, I've set them to black (0,0,0) and to background.
when importing the sprite (the one shown in the upper righthand corner of the screenshot in my previous post) using these settings:
import options:
-import alpha channel: no
-remap palette: no
-use room background: no
Transparant colour:
-bottom-right pixel (which is 84, 84, 252)
it got its colours messed up.
importing and imported the object#1 sprite (messed up):
(https://dam1976.home.xs4all.nl/AGS/curse/1/Import_Sprite.png) (https://dam1976.home.xs4all.nl/AGS/curse/1/Imported_Sprite.png)
importing and imported the object#2 sprite (imports correctly):
(https://dam1976.home.xs4all.nl/AGS/curse/1/Import_Sprite_object2.png) (https://dam1976.home.xs4all.nl/AGS/curse/1/Imported_Sprite_object2.png)
colours are setup like this:
(https://dam1976.home.xs4all.nl/AGS/curse/1/palettes.png)
room in editor with object#1 sprite having messed up colors and object#2 showing correctly):
(https://dam1976.home.xs4all.nl/AGS/curse/1/room%20in%20editor.png)
running the UpdatePalette, still black background instead of GB 'darkgreen' (should be 4,14,4 as in values from 0 to 63 or 15,56,15 values from 0 to 255):
(https://dam1976.home.xs4all.nl/AGS/curse/1/paletteupdate_to_gbm.png)
I know this won't solve the original problem, but have you tried not using pure black? And using the next closest to black possible? Even if only to test that works, and that the problem is in fact pure black.
I tried this the other way around, starting with the gameboy palette, sprites and bg. Switching to cga works fine but switching back to gb fails showing pure black instead of dark green. So yes, it seems black or slot#0 is the problem. I just don't understand how to tackle this. I read Gilbert's tutorial but I still can't find the solution... It looks so simple, just four colors, but i have no clue that the true problem is...
Is it possible to ignore slot zero and always work with the ones after? Just in case there's something different with slot 0.
Haven't read it all as I'm on mobile.
If slots 16-19 are set to bg colours and you import sprites with "use room bg" set to "no" then the sprites won't use these colour slots.
Try either importing sprites with "use room bg" set to "yes", or just set these colours gamewide also (if you don't need bgs to have different colours anyway you actually do not need to have bg slots).
Finally I got it working!
When the sprites and the backgrounds all use the same 4-color palette one would think to setup the ags colour panel palette to be used for both the sprites and backgrounds, having only 4 slots needed for the 4 game colors.
But ags colour slot #0 (which must be black) seems to be problematic for sprites but works fine for backgrounds when switching its color codewise.
So you'll end up having 2 sets of identical slots color-wise, the first set is set to background, the 2nd one is set to gamewide.
(i had these 2 sets set up the other way around. which works fine except for slot #0 not changing for the sprites)
So slots #0-3 set to background and (for example) slots #16-19 set to gamewide in combination with importing the sprites using RemapToGamePalette = yes was the solution.
(of course code-wise you'll need to switch the background and the sprites separated since they are 2 sets now instead of 1)
So, to sum it all up:
- File - Preferences: Remap palette of room backgrounds into allocated background palette slots (8-bit games only) = unchecked
- colour-panel: slot #16-#19 are set to gamewide,
- colour-panel: slot #0-3 are set to background,
- colour-panel: both slot sets use the exact same colors (black, cyan, magenta, white)
- sprite import - RemapToGamePalette = yes
- sprite import - RemapToRoomPalette = no
- sprite import - the tranparent color can be anything, it has obviously no influence for the colour panel layout
- code: run UpdatePalette for bot slot sets
Result:
(switched from cga palette to game boy palette)
(https://dam1976.home.xs4all.nl/AGS/curse/3/finally.png)
One last question:
Currently when switching palette, all the sprites are switch from palette over the whole game, while only the current room background is switched.
It would be nice if I don't need to switch the palette for the background each time the player enters another room...
So:
Is it - outside the 'workaround' option of using an object and sprite as background - somehow possible to let the backgrounds act as being set 'gamewise' instead of 'background'?
I do need to keep the first 4 slots being set as background and the second set of 4 slots as being gamewide to avoid the sprites black color not switching correctly.
I have no palette experience, but you can use event handles in a script module to deal with room leave and entering:
void on_event (EventType event, int data) {
if(event == eEventEnterRoomBeforeFadein) {
// Before fade in (room_Load)
} else if(event == eEventLeaveRoom) {
// On Leave
}
}
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Event.html#on_event
Yep, event handle works fine :)