Page 1 of 1

SGDK VDP_setTileMapXY / sample/sprite

Posted: Mon Nov 19, 2018 7:14 am
by darkjoy2k2
Hello there!

I try to setup a tilemap engine.


a kind of "splash screen" in "plan a"

Code: Select all

    VDP_drawImageEx(PLAN_A, &bga_image, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
    ind += logo2_image.tileset->numTile;
filling tiles in "plan_b"

Code: Select all

	
for(z=0;z<38;z+=2)
    {
	for(i=0;i<22;i+=2) // when i reaches 42 tiles it stops drawing. it skips 2 tiles (block width)
	{
		 drawBlock(z+1,i+1,4); //Function drawBlock draws block at position horizontal i and vertical 20
	w+=2;
	if (w==41){
        w=81;}
	if (w==121){
        w=161;}
 ind+=4;
	}
	}

Code: Select all

void drawBlock(unsigned int px,unsigned int py, unsigned int tnum) //Function to draw block at px,py
{ //16x16 pixel block = four 8x8 tiles = 2 tile wide and 2 tile high
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum), px, py); //Tile 2 is upper left corner (8x8 tile)
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum)+1, px+1, py); //Tile 3 is upper right corner (8x8 tile)
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum)+40, px, py+1); //Tile 4 is lower left corner
	VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL0, 0, 0, 0, tnum)+41, px+1, py+1); //Tile 5 is lower right corner
}
The code works well as long as i dont exceed the 38 tiles per line / 22 lines.

If i try to put more tiles on screen the graphics i put in "PLAN_A" go messy.
(some tiles from "PLAN_A" start looking weird an do some twisting
kind of animation)

Except for

Code: Select all

    VDP_fillTileMapRect(PLAN_B, 1, 0, 0, 50, 38);
which fills the screen but isn´t very creative...



1.
is there a smarter way to fill the screen with "different" tiles?


2.
another thing i saw was that i always have to fill some "IND" value when i draw with VDP_setTileMapXY or VDP_drawImageEx, else everything looks crap too, except for the VDP_fillTileMapRect, which does´nt seem to need that value. ind = TILE_USERINDEX;
can someone explain that a little more?

Re: SGDK VDP_setTileMapXY / sample/sprite

Posted: Mon Nov 19, 2018 10:32 am
by Stef
I'm not really sure of what you're trying to do but did you had a look on VDP_setMap(..) and VDP_setMapEx(..) methods ? i think that is what you need here.

Re: SGDK VDP_setTileMapXY / sample/sprite

Posted: Mon Nov 19, 2018 6:13 pm
by darkjoy2k2
The DRAWIMAGEEX already added the "ind"-value and so i set it twice for mistake, everythig is fine now...

the stuff you mentioned really sounds interesting! can i use this to add a textfile or something and feed it as a map?

Re: SGDK VDP_setTileMapXY / sample/sprite

Posted: Sat Jan 19, 2019 12:32 am
by Okoboji
Is it possible to assign color pallets to individual tiles in the Map functions? For example I've noticed that you have VDP_setmap(..) with only a single defined base tile value. What I want to do is have 2 pallets on a background plan_b. where each tile can switch back and forth between PAL 0 and PAL 1. If this is impossible with the current implementation I totally understand. I've actually modified a bit of kcowolfs map example to load in individual pallets. But, it would be nice to use the built in Map functions for compression and such.