Quote:
rubengar wrote:
Hi I leave the new file!!
One question, when I load a new background (the backgrounds go one after another if the character progresses,
are not independent levels)
example:
if ((marix>383) && (lives>0)) level=level+1;
I want to eliminate the enemies of the previous background, how?
the world of enemies is:
vbSetWorld(27, WRLD_ON|3, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48);//enemie1
vbSetWorld(26, WRLD_ON|3, dbakalax, 0, dbakalay, dbframe*24, 0, 96, 24, 48);//enemie2
copymem((void*)BGMap(3), (void*)FONTMAP, 256*16);//font and enemies
thanks!!!!
Woot! El capitán puede saltaaaaaar!

If you want to stop displaying a World, you just have to leave the "WRLD_ON" (or WRLD_LON or WRLD_RON) part out of the "flags" part of the header. If you're calling vbSetWorld() every frame to update the position of the enemies (which is a little wasteful of cycles, but probably not a big deal in this particular game) you can just keep the flags part in a variable or structure, and change it at will, like this:
u16 enemy1header = WRLD_ON | 3;
.
.
.
// Update inside the loop
vbSetWorld(27, enemy1header, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48); // Enemy 1
.
.
.
// Disable
enemy1header = 3;
// Enable
enemy1header = WRLD_ON | 3;
Otherwise, you can use the WA structure array in world.h to just change the flags, like this:
// Setup
vbSetWorld(27, 3, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48); // Enemy 1
.
.
.
// Disable
WA[27].head &= ~(WRLD_ON);
// Enable
WA[27].head |= WRLD_ON;
// Move
WA[27].gx = bakalax;
WA[27].gy = bakalay;
// Animate
WA[27].mx = bframe * 24;
Note: the "~" inverts each bit of the argument.