impossible dream i think!

hi its been a while since i last posted ive been busy rewriting my game code and i have come across an issue what i would like to know is if its possible to dynamicaly create static declarations


	for(int a;a<50;){
	public static BufferedImage[] (move+a);
	}

//to give me

public static BufferedImage[] move0;
public static BufferedImage[] move1;
etc etc ...


i know this wont work but you get the idea or am i dreaming and i have to declare them all manually?

Have you thought about using a two dimensional array for this?

it is at the moment well its an array of arrays i wanted to only add the moves when they have been selected
it gets more complicated the further i get into the game.
it would probably be easier to stop players from using a certain move if they havent aquired it just block the keypresses,
looks like it will have to be 50 million declarations and 50 million if else if statements.oh well worth a try ;D

java.util.Map?

I’m not really getting what you mean but I think programming some sort of class out of it seems the only solution.

Again, I don’t know what you are really after but try looking at that page for some inspiration.

Your last paranthesis fell outside the link giving the wrong page.

woops thnx

Are you just looking to be able to initialize the static members?

class staticInitializer {

public static BufferedImage[] move0;
public static BufferedImage[] move1;

Static {
    for(int a;a<50;) {
        public static BufferedImage[] (move+a);
    }
}

public void staticInitializer() {
...
}

etc etc ...

I think he wants to create variables blah1,blah2,blah3 etc without having to type each one out. The sort of stuff you can do with the C pre-processor.

It sounds horribly messy though.

Yeah that was the idea but i think its maybe impossible, it was that or dynamicaly create entire game instances
i.e game 1 would have 1 move, game 2 would have 2 moves etc etc.i have decided on a different approach create 1 game with all the possible moves but create a massive nested if else… if ladder(i dont like case switch things much,they seem like hard work and are confusing) for controlling what moves you can do depending on what moves you have aquired.
i might take another look after i have sorted out why i cant update a variable in my gtge game class from a swing chat message box

TBH it sounds to me like you just need to go more object oriented with this.


interface action {
  void doAction();
}

class action1 implements action {
  void doAction() {
    blah
  }
}

class action2...

etc

Have a think about it and hopefully you can see how that solves a lot of your problems…

thanks but i sorted it out, it was my stringtokenizer i was parsing the wrong string so it would never be true no matter how i did it…lmao
programming when your tired is not a good idea !