I have 8 different 8x8 tiles that I'd like to random load and position in BPLAN. All tiles share the same palette but I'm not sure how to assemble them into a Image at runtime. Does anyone have an advice on this? It will be warmly welcome as always

Moderator: Stef
I've already got that farHik wrote:Maybe you could use a 2d array for this along with a random number generator where each number is a certain tile.
The random numbers could be put into the 2d array and the array would then build up an image.
That won't work as the PAL data will be different for each image you load in using ResCompHik wrote:If it has to be on the BPLAN then the best way I know of how to do it so far is to individually load each tile as an image.
I'm thinking you can just load that one palette and have all the tile images use that same one.
The code worked for me when using sprites. I'm thinking images work the same.matteus wrote:That won't work as the PAL data will be different for each image you load in using ResCompHik wrote:If it has to be on the BPLAN then the best way I know of how to do it so far is to individually load each tile as an image.
I'm thinking you can just load that one palette and have all the tile images use that same one.I think I need to load a tileset and then indicate where I want each tile vdp_tile.h has the functions I'm just not sure on the combo I need
Code: Select all
// load background
ind = TILE_USERINDEX;
VDP_drawImageEx(BPLAN, &placeholder1_image, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 8, 8, FALSE, TRUE);
ind += placeholder1_image.tileset->numTile;
VDP_drawImageEx(BPLAN, &placeholder2_image, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 8, 8, FALSE, TRUE);
ind += placeholder2_image.tileset->numTile;
memcpy(&palette[0], placeholder1_image.palette->data, 16 * 2);
VDP_setPalette(0, placeholder1_image.palette->data);
Mmm I'll have a go with this tomorrow see what happensHik wrote:The code worked for me when using sprites. I'm thinking images work the same.matteus wrote:That won't work as the PAL data will be different for each image you load in using ResCompHik wrote:If it has to be on the BPLAN then the best way I know of how to do it so far is to individually load each tile as an image.
I'm thinking you can just load that one palette and have all the tile images use that same one.I think I need to load a tileset and then indicate where I want each tile vdp_tile.h has the functions I'm just not sure on the combo I need
Just make sure if you put the palette into palette 0 (with memcpy(&palette[0]... and VDP_setPalette(0 ... ) that you put PAL0
into the code for each image you load (right after TILE_ATTR_FULL).
Code: Select all
// load background ind = TILE_USERINDEX; VDP_drawImageEx(BPLAN, &placeholder1_image, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 8, 8, FALSE, TRUE); ind += placeholder1_image.tileset->numTile; VDP_drawImageEx(BPLAN, &placeholder2_image, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 8, 8, FALSE, TRUE); ind += placeholder2_image.tileset->numTile; memcpy(&palette[0], placeholder1_image.palette->data, 16 * 2); VDP_setPalette(0, placeholder1_image.palette->data);
Code: Select all
ind = IndMarker;
VDP_setPalette(PAL2, map_tileset.palette->data);
VDP_loadTileSet(map_tileset.tileset, ind, 1);