Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  impossible dream i think!  (Read 2222 times)
0 Members and 1 Guest are viewing this topic.
Offline markmistry

Junior Member





« Posted 2009-07-18 03:00:09 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
   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?
Offline davidc

Senior Member


Medals: 5
Projects: 2



« Reply #1 - Posted 2009-07-18 05:20:49 »

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

Junior Member





« Reply #2 - Posted 2009-07-18 05:48:04 »

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  Grin
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pjt33
« Reply #3 - Posted 2009-07-18 09:41:06 »

java.util.Map?
Offline Michiel

Senior Newbie





« Reply #4 - Posted 2009-07-20 06:51:22 »

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

http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

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

JGO Wizard


Medals: 74
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #5 - Posted 2009-07-20 08:06:45 »

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

http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

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.

http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline Michiel

Senior Newbie





« Reply #6 - Posted 2009-07-20 12:44:07 »

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

http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

woops thnx
Offline Wildern

Junior Member





« Reply #7 - Posted 2009-07-20 15:51:11 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
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 ...
Offline TimB

Junior Member


Medals: 1
Projects: 1



« Reply #8 - Posted 2009-07-20 16:36:40 »

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.
Offline markmistry

Junior Member





« Reply #9 - Posted 2009-07-20 21:05:30 »

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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline TimB

Junior Member


Medals: 1
Projects: 1



« Reply #10 - Posted 2009-07-21 08:58:03 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
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...
Offline markmistry

Junior Member





« Reply #11 - Posted 2009-07-21 15:02:23 »

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 !
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (18 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

atombrot (39 views)
2014-08-19 09:29:53

Tekkerue (36 views)
2014-08-16 06:45:27

Tekkerue (33 views)
2014-08-16 06:22:17

Tekkerue (22 views)
2014-08-16 06:20:21

Tekkerue (33 views)
2014-08-16 06:12:11

Rayexar (70 views)
2014-08-11 02:49:23

BurntPizza (47 views)
2014-08-09 21:09:32

BurntPizza (38 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!