Hi,
I have a problem with my enemies system.
When I load directly level 5, the enenies are moving properly. But if I finish the 4 fourth level and then go to level 5 the enemies don't work. The enemies that are in level 4 are just repositioned to match in the level.
This is the enemy loop.
void enemy()
{
int poz;
poz=dbObjectPositionZ(enem_1);
dbMoveObject(enem_1,depl);
dbMoveObject(enem_2,-depl);
dbMoveObject(enem_3,depl);
dbMoveObject(enem_4,-depl);
if (poz==min_enem)
depl=enem_speed;
if (poz==max_enem)
depl=-enem_speed;
if(dbObjectCollision(ball,enem_1)==1)
{
lives--;
liveminus();
}
if(dbObjectCollision(ball,enem_2)==1)
{
lives--;
liveminus();
}
if(dbObjectCollision(ball,enem_3)==1)
{
lives--;
liveminus();
}
if(dbObjectCollision(ball,enem_4)==1)
{
lives--;
liveminus();
}
}
This is the making of the enemies at level 4
max_enem=-260;
min_enem=-320;
dbMakeObjectSphere(enem_1,10);
dbTextureObject(enem_1,ball_texture);
dbPositionObject(enem_1,-280,300,max_enem);
dbMakeObjectSphere(enem_2,10);
dbPositionObject(enem_2,-250,300,min_enem);
dbTextureObject(enem_2,ball_texture);
dbMakeObjectSphere(enem_3,10);
dbPositionObject(enem_3,-220,300,max_enem);
dbTextureObject(enem_3,ball_texture);
dbMakeObjectSphere(enem_4,10);
dbPositionObject(enem_4,-190,300,min_enem);
dbTextureObject(enem_4,ball_texture);
ene_speed=1;
This is the repositioning from level 5
clean();
dbMakeObjectSphere(enem_1,10);
dbTextureObject(enem_1,ball_texture);
dbPositionObject(enem_1,-240,10,min_enem);
dbMakeObjectSphere(enem_2,10);
dbPositionObject(enem_2,-230,10,max_enem);
dbTextureObject(enem_2,ball_texture);
dbMakeObjectSphere(enem_3,10);
dbPositionObject(enem_3,-220,10,min_enem);
dbTextureObject(enem_3,ball_texture);
dbMakeObjectSphere(enem_4,10);
dbPositionObject(enem_4,-210,10,max_enem);
dbTextureObject(enem_4,ball_texture);
enem_speed=2;
I make them again because I have a function that delete's what was used in level 4. I tried not using it and just positioning the enemies, but it still doesn't work, it just goes into one direction and never stops.
In the main loop I have
if (level==5||level==4) enemy();
Forward thanks