Java | retrieving data -


i have made tower defense game , there 1 thing bothers me. have set starting value of money cannot value carry on next level. ideas?

    public void define() {     room = new room(); save = new save();     store = new store();      if(level == 1){     coinage = 50;     health = 100;     }      if(level == 2){     coinage = 40;     health = 100;     }     if(level > 2){         coinage = 30;         health = 100;     }      if(level > 8){         coinage = 0;     } 

hmm tried this:

public static int coinage = 0, health = 100; 

and then

    if(level == 1){     coinage += 50;     }      if(level == 2){     coinage += 40;     } 

i sure doing wrong here. when second level comes starting value still 40. how fix that?

here a link full code!

if coinage money, can set global variable outside of define() function. let keep track of how money player has. instead of setting value direct number can instead add existing value. in example of level 2, coinage += 50;. take global value of coinage , add 50 existing number, instead of setting specific value. using = saying x/y. keeping global, can add/subtract onto , manipulate in more ways.

i think key though looking @ code have, switch use += instead of =. way adding existing value, instead of setting static number each time.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -