i have two classes, enemy class and level class.
in level class i am changing the counter value.
note i set up my if statment so it will only goes in onces and never again. so if u reach lvl 2 than it will go in lvl2 if statment onces reset counter to 10. than wait when player reach lvl 3.
if(...) //if lvl 1
{
//change counter = 20
}
if(...) //if lvl 2
{
//change counter = 10
}
if(...) //if lvl 3
{
//change counter = 5
}
enemy.class
this method just makes enemy to shoot bullet. and counter is the time between every shoot. so enemy shoot a bullet than wait 20 int. when reach 0 than shoot again.
loop/method
counter--;
if(counter <= 0 &&!shooting)
{
//create bullet object / add in arraylist
shooting = true;
counter = 20; //reset
}
if(counter != 0)
{
shooting= false;
}
the problem is that i am hard coding value of counter=20 in emeny class.but i value of counter change depends on wha level player is on.
i was thinking of making counter1, counter2, counter3, in level class. and in enemy class i can use getter method to get the value and do i test.
the problem with this is i end up making variable for every lvls. is there way so i only use one counter. and dont rewrite code.