Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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  
  Multidimensional Arrays Question  (Read 531 times)
0 Members and 1 Guest are viewing this topic.
Offline _Scyth_

Junior Member





« Posted 2013-05-23 20:59:14 »

ok, so I am a little bit lazy, and I kind of need the answer quickish.

   i have a multidimensional array of images(dont ask why) laid out like:
   
1  
2  
3  
4  
5  
6  
7  
8  
9  
EncodedImage[][] eImg = new EncodedImage[4][10];

eImg[0][0] = imgLoader.image1();
eImg[0][1] = imgLoader.image2();
eImg[0][2] = imgLoader.image3();

eImg[1][0] = imgLoader.image3();
eImg[1][1] = imgLoader.image2();
eImg[1][2] = imgLoader.image3();


now i have a constructor which accepts an array of these images like
1  
public Construct( EncodedImage[] enImg)


so my question is, can i use my multidimensional array to get only the array of images from say EncodedImage[0];
like could i do
1  
Construct cons = new Construct( eImg[0] );

to get enImage[] to be the array of the images  eImg[0][0], eImg[0][1], eImg[0][2]??

Tried to explain as best i could. Any advice would be appreciated
Offline DQQAYME

Junior Member


Medals: 1
Projects: 1



« Reply #1 - Posted 2013-05-23 21:21:04 »

1  
2  
3  
4  
5  
   public EncodedImage get_Val(int pos, EncodedImage ar[][]){
      int d_1 = pos / 10;
      int d_2 = pos % 10;
      return ar[d_1][d_2];
   }

=)

Offline _Scyth_

Junior Member





« Reply #2 - Posted 2013-05-23 21:27:57 »

can you explain what the pos is for?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DQQAYME

Junior Member


Medals: 1
Projects: 1



« Reply #3 - Posted 2013-05-23 23:24:26 »

I think you ask this.
1  
2  
3  
get_Val(0, eImg) == eImg[0][0]
get_Val(1, eImg) == eImg[0][1]
get_Val(39, eImg) == eImg[3][9]

Ups sorry i think i finally understand what you want Wink
1  
2  
3  
   int ar[][] = new int[3][3];
     
   int ar2[] = ar[0];// ar2[1] == ar[0][1];

If I know from start you ask this, then I even not start Reply you – for so easy question XD

Offline Danny02
« Reply #4 - Posted 2013-05-24 07:54:41 »

1  
Construct cons = new Construct( eImg[0] );

to get enImage[] to be the array of the images  eImg[0][0], eImg[0][1], eImg[0][2]??

yes you can, but why did you not just tried it???
press compile button -> max 5sec
ask in forum -> several days
Offline _Scyth_

Junior Member





« Reply #5 - Posted 2013-05-24 17:06:55 »

Thanks everyone, and because the program is all backwards, and to actually test it i would need to add a ton of code to a lot of files before finding out if it worked. then i'd need to delete that code again.
Offline ags1

JGO Ninja


Medals: 62
Projects: 3
Exp: 5 years


Make code not war!


« Reply #6 - Posted 2013-05-24 17:10:33 »

Just create a temp package in your project, and make a throwaway class in there to experiment with multidimensional arrays. No need to change any of your real code.

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.

radar3301 (11 views)
2014-09-21 23:33:17

BurntPizza (28 views)
2014-09-21 02:42:18

BurntPizza (18 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (47 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24: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!