Clearing plans and texts.
Moderator: Stef
Clearing plans and texts.
I'm using VDP_clearPlan and VDP_cleartext, but their seems to be left over text from the title screen.
It clears the Background title, and the title logo. Also clears "Play" text but not "Options"
here is the code.
VDP_clearText(18, 19, 40);
VDP_clearText(16, 20, 40);
VDP_clearPlan(APLAN, TRUE);
VDP_clearPlan(BPLAN, TRUE);
It clears the Background title, and the title logo. Also clears "Play" text but not "Options"
here is the code.
VDP_clearText(18, 19, 40);
VDP_clearText(16, 20, 40);
VDP_clearPlan(APLAN, TRUE);
VDP_clearPlan(BPLAN, TRUE);
Re: Clearing plans and texts.
How do you print the "options" string?
Re: Clearing plans and texts.
Using the function i wrote. The options text is the second vdp_drawtext line in drawGameTxt()nolddor wrote:How do you print the "options" string?
char* getGameTxt(int txtnum, int txtnumtwo)
{
mytxt[0][0] = "PLAY";
mytxt[1][0] = "OPTIONS";
return (mytxt[txtnum][txtnumtwo]);
}
void drawGameTxt()
{
if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
}
drawGameTxt is in main like this
while(TRUE)
{
entityInput();
entityAnim();
updateCamera();
drawGameTxt();
VDP_waitVSync();
}
And this is what triggers the events. assetLoader is another one of my functions.
static void joyEvent(u16 joy, u16 changed, u16 state)
{
if (changed & state & BUTTON_START)
{
if (loc == 1) loc++; assetLoader(loc);
}
}
void assetLoader(int pack)
{
if (pack == 1)
{
titlebgmap = unpackMap(titlebg_tiles.map, NULL);
ind = TILE_USERINDEX;
VDP_loadTileSet(titlebg_tiles.tileset, ind, TRUE);
VDP_setMapEx(BPLAN, titlebgmap, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
ind += titlebg_tiles.tileset->numTile;
titlelogomap = unpackMap(titlelogo_tiles.map, NULL);
VDP_loadTileSet(titlelogo_tiles.tileset, ind, TRUE);
VDP_setMapEx(APLAN, titlelogomap, TILE_ATTR_FULL(PAL3, FALSE, FALSE, FALSE, ind), 10, 1, 0, 0, 20, 17);
ind += titlelogo_tiles.tileset->numTile;
}
if (pack == 2)
{
ind = 0;
SYS_disableInts();
VDP_clearText(18, 19, 40);
VDP_clearText(16, 20, 40);
VDP_clearPlan(APLAN, TRUE);
VDP_clearPlan(BPLAN, TRUE);
SYS_enableInts();
// init jaris sprite
player1.hmirror = 0;
player1.vmirror = 0;
player1.zorder = 0;
player1.x = 150;
player1.y = 150;
player1.current_frame = 0;
player1.current_anim = ANIM_STANDSIDES;
player1.animspeeds[0] = 50;
player1.animspeeds[1] = 20;
player1.animspeeds[2] = 2;
//Citizen vars
cxypos[0][0] = 160;
cxypos[1][0] = 150;
czorder = 1;
VDP_setPalette(PAL0, sjaris_sprite.palette->data);
VDP_setPalette(PAL1, fcitizen_sprite.palette->data);
VDP_setPalette(PAL2, city_tiles.palette->data);
SPR_initSprite(&sprites[player1.zorder], &sjaris_sprite, player1.x, player1.y, TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_update(sprites, 0);
SPR_update(sprites, 1);
citymap = unpackMap(city_tiles.map, NULL);
ind = TILE_USERINDEX;
VDP_loadTileSet(city_tiles.tileset, ind, TRUE);
VDP_setMapEx(BPLAN, citymap, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), PlanXPosInTile, PlanYPosInTile, MapXPosInTile, MapYPosInTile, MapWidthInTile, MapHeightInTile);
ind += city_tiles.tileset->numTile;
}
}
Re: Clearing plans and texts.
I have discoverd the issue, and fixed it by dumb luck.
This
if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
Was changed to this.
if (loc == 1)
{
VDP_drawText(getGameTxt(0,0), 18, 19);
VDP_drawText(getGameTxt(1,0), 16, 20);
}
Why did it not work the first way?
This
if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
Was changed to this.
if (loc == 1)
{
VDP_drawText(getGameTxt(0,0), 18, 19);
VDP_drawText(getGameTxt(1,0), 16, 20);
}
Why did it not work the first way?
-
- Very interested
- Posts: 86
- Joined: Fri Sep 25, 2015 4:16 pm
Re: Clearing plans and texts.
I'm not sure, but your first syntax was absolute insanity so it's good to see the clean option worked better
Re: Clearing plans and texts.
Yeah, it is strange. Thinking how that would even conflict with the clearing of text.mikejmoffitt wrote:I'm not sure, but your first syntax was absolute insanity so it's good to see the clean option worked better
Usually i see people negate the curly braces if it can run on a single line, so i thought i should do it to.
There is a blog video coming on Saturday. Showing off the progress and a walk through my crap code. 8P
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Clearing plans and texts.
You need braces as soon you have more than 1 "instruction" (or operation) so here :
Only the first VDP_drawText(..) call is affected by the condition, second call is always executed whatever is loc.
As a general good practice is to always use the brace so you know what is affected by condition
Code: Select all
if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
As a general good practice is to always use the brace so you know what is affected by condition
Re: Clearing plans and texts.
Ah okay. Yeah i see that now. Thanks! <8BStef wrote:You need braces as soon you have more than 1 "instruction" (or operation) so here :
Only the first VDP_drawText(..) call is affected by the condition, second call is always executed whatever is loc.Code: Select all
if (loc == 1) VDP_drawText(getGameTxt(0,0), 18, 19); VDP_drawText(getGameTxt(1,0), 16, 20);
As a general good practice is to always use the brace so you know what is affected by condition