Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Game Development / Newbie & Debugging Questions / Re: java 3d camera..... on: 2006-04-22 01:16:34
ok here's kind of specifically what i wnat to know

1. How to create a camera and be able tranform it, i.e. move it around and rotate.
2. Setting camera to follow an object
3. Just basic stuff really
2  Game Development / Newbie & Debugging Questions / Re: java 3d camera..... on: 2006-04-21 01:45:23
upping
3  Game Development / Newbie & Debugging Questions / java 3d camera..... on: 2006-04-14 02:19:44
Can some one give me a link to a site that tells me how to do camera things in java3d???

I looked around the net and couldn't much.
4  Game Development / Newbie & Debugging Questions / Re: Textures dont show up on models on: 2006-03-29 00:51:04
well this is how i installed java3d

i put the contents t in my jdk_1.5.06, jre_1.05.06, and also my jdk_1.5.06/jre_1.5.06
5  Game Development / Newbie & Debugging Questions / Re: Textures dont show up on models on: 2006-03-27 03:05:06
Also another problem, I can run my program as a Application just fine, but when I try to open it as an applet in html, it has an error initializing

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.vp.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.loaders.*;
import com.glyphein.j3d.loaders.milkshape.MS3DLoader;
public class LandTest extends Applet
{
   SimpleUniverse u;
   BoundingSphere bounds;
   ViewingPlatform ourView;
   OrbitBehavior B;
   
   public void init()
   {
      setLayout(new BorderLayout());
      GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
      Canvas3D c = new Canvas3D(config);
      u = new SimpleUniverse(c);
      BranchGroup scene = createSceneGraph();
      u.addBranchGraph(scene);
     
      ourView = u.getViewingPlatform();
      ourView.setNominalViewingTransform();
     
      B = new OrbitBehavior(c);
      B.setSchedulingBounds(bounds);
      ourView.setViewPlatformBehavior(B);
     
      add("Center",c);
   }

    public BranchGroup createSceneGraph()
    {
         BranchGroup objRoot = new BranchGroup();
      bounds = new BoundingSphere();
     
      String filePath="file://localhost/"+System.getProperty("user.dir")+"/";
      String texturePath=filePath + "stone.jpg";
     
     
      Land s = new Land(6, 6, texturePath);
     
     
     
      try
     
      {
         java.net.URL modelPath = new java.net.URL(filePath+"gun2.ms3d");
          Loader msLoader = new MS3DLoader();
          Scene ourScene;
         ourScene = msLoader.load(modelPath);
         BranchGroup modelBranch = ourScene.getSceneGroup();
         Shape3D model= (Shape3D)modelBranch.getChild(0);
         modelBranch.removeChild(0);
         
         /*Appearance modelapp = new Appearance();
         Color3f objColor = new Color3f(0.7f, 0.2f, 0.8f);
         Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
          modelapp.setMaterial(new Material(objColor, black, objColor, black, 80.0f));
          model.setAppearance(modelapp);*/

          objRoot.addChild(model);
      }
      catch(Exception e){
      }
     
      Color3f alColour = new Color3f(0.4f, 0.4f, 0.4f);
      AmbientLight aLgt = new AmbientLight(alColour);
      aLgt.setInfluencingBounds(bounds);
     
      Color3f DirColour = new Color3f(0.35f, 0.35f, 0.3f);
      Vector3f DirVec = new Vector3f(-0.5f, -0.2f, 0.6f);
      DirectionalLight DirLig = new DirectionalLight(DirColour, DirVec);
      DirLig.setInfluencingBounds(bounds);
     
     
      objRoot.addChild(DirLig);
      objRoot.addChild(aLgt);
      objRoot.addChild(s);
      objRoot.compile();
      return objRoot;
   }
   
    public static void main(String[] args) {
        new MainFrame(new LandTest(), 256, 256);
    }
}


error message:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
Java Plug-in 1.5.0_06
Using JRE version 1.5.0_06 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\peter


----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

java.lang.NoClassDefFoundError: javax/media/j3d/Bounds
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
   at java.lang.Class.getConstructor0(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at sun.applet.AppletPanel.createApplet(Unknown Source)
   at sun.plugin.AppletViewer.createApplet(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-4" java.lang.NullPointerException
   at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
   at sun.plugin.AppletViewer.showAppletException(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
   at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
   at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
java.lang.NoClassDefFoundError: javax/media/j3d/Bounds
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
   at java.lang.Class.getConstructor0(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at sun.applet.AppletPanel.createApplet(Unknown Source)
   at sun.plugin.AppletViewer.createApplet(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-8" java.lang.NullPointerException
   at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
   at sun.plugin.AppletViewer.showAppletException(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
   at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
   at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
6  Game Development / Newbie & Debugging Questions / Re: Textures dont show up on models on: 2006-03-27 02:23:31
ok I realized that in milkshape, you have to, when your done, regroup the entire model into one group,

I had it where i grouped it differently, to do textures (i.e. different colors for stuff), are I did this, the model imported with success.

ONLY problem is, and its a big problem, when I regrouped, all the texturing stuff got deleted, so do you know how to keep the textures?
7  Game Development / Newbie & Debugging Questions / Textures dont show up on models on: 2006-03-27 02:01:33
I made a gun model with Milkshape, and when i imported it, it kind of showed up, but  it was completely black, even though i had textured it, then I tried a model i downloaded and it worked fine, so whats the deal?
8  Game Development / Newbie & Debugging Questions / Re: 3d lighting on: 2006-03-26 17:29:00
nvm ^^ I figureded it out

but can someone tell me how to determine the radian for NormalGenerator
9  Game Development / Newbie & Debugging Questions / Re: 3d lighting on: 2006-03-26 04:34:56
ugh, i is really beginner

for (1) I just tried random normal values because i dont really know much about normals (0,10,30,60,120,270) and it didnt work
SO can you tell me what radian means??? i guess that would help alot, and HOW DO YOU CALCULATE THE APPROPRIATE RADIAN

for(2) im pretty sure its not that, sinc it works with the other object
10  Game Development / Newbie & Debugging Questions / 3d lighting on: 2006-03-26 03:08:56
well i read this source code that had the lighting done pretty good
but it was kind of hard to understand ( not the lighting part, but everything else )

so I wrote my own program but using the lighting part of the source code, and........my lighting doesnt work.

this is my class code for the geometry + lighting part
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
GeometryInfo gf = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
      gf.setTextureCoordinateParams(1,2);
      gf.setTextureCoordinates(0,txt);
      gf.setStripCounts(strips);
      gf.setCoordinates(pts);
      gf.setContourCounts(contours);
     
      NormalGenerator ng = new NormalGenerator();
      ng.setCreaseAngle ((float) Math.toRadians(30));
      ng.generateNormals(gf);
     
      Appearance app = new Appearance();
      Material mat = new Material();
      mat.setShininess(0.01f);
      mat.setEmissiveColor(0.0f, 0.0f, 0.0f);
      mat.setAmbientColor(0.1f, 0.1f, 0.1f);
      app.setMaterial(mat);
     
      try{

      TextureLoader txtLoader = new TextureLoader(new java.net.URL(texture),null);
      Texture2D textImg = (Texture2D) txtLoader.getTexture();
      TextureAttributes texatt=new TextureAttributes(TextureAttributes.BLEND, new Transform3D(), new Color4f(1.0f, 1.0f, 1.0f, 1.0f), TextureAttributes.NICEST);
      app.setTextureAttributes(texatt);
      app.setTexture(textImg);
      }catch(java.net.MalformedURLException e){
         System.out.println("he");
      }
      setGeometry(gf.getGeometryArray());
      setAppearance(app);


and this is the tester class that I use for both the other source code and my code.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.vp.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class LandTest extends Applet
{
   SimpleUniverse u;
   BoundingSphere bounds;
   ViewingPlatform ourView;
   OrbitBehavior B;
   
   public void init()
   {
      setLayout(new BorderLayout());
      GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
      Canvas3D c = new Canvas3D(config);
      u = new SimpleUniverse(c);
      BranchGroup scene = createSceneGraph();
      u.addBranchGraph(scene);
     
      ourView = u.getViewingPlatform();
      ourView.setNominalViewingTransform();
     
      B = new OrbitBehavior(c);
      B.setSchedulingBounds(bounds);
      ourView.setViewPlatformBehavior(B);
     
      add("Center",c);
   }

    public BranchGroup createSceneGraph()
    {
         BranchGroup objRoot = new BranchGroup();
      bounds = new BoundingSphere();
     
      String texturePath="file://localhost/"+System.getProperty("user.dir")+"/stone.jpg";
     
      Land s = new Land(6, 6, texturePath);
     
      Color3f alColour = new Color3f(0.4f, 0.4f, 0.4f);
      AmbientLight aLgt = new AmbientLight(alColour);
      aLgt.setInfluencingBounds(bounds);
     
      Color3f DirColour = new Color3f(0.35f, 0.35f, 0.3f);
      Vector3f DirVec = new Vector3f(0.5f, -0.2f, 0.6f);
     
     
      DirectionalLight DirLig = new DirectionalLight(DirColour, DirVec);
      DirLig.setInfluencingBounds(bounds);
     
     
      objRoot.addChild(DirLig);
      objRoot.addChild(aLgt);
      objRoot.addChild(s);
      objRoot.compile();
      return objRoot;
   }
   

    public static void main(String[] args) {
        new MainFrame(new LandTest(), 256, 256);
    }
}
11  Game Development / Newbie & Debugging Questions / Re: Ah! Im so stupid on: 2006-02-13 07:43:10
yay thank you, its 1:43 am and my game is finally done (well sort of) thx
12  Game Development / Newbie & Debugging Questions / Re: Need help bad! on: 2006-02-13 02:08:45
LOOOLLLLLLL, wow i just realized i had a row and col assignment switched, wow thats a terrible mistake
13  Game Development / Newbie & Debugging Questions / Re: Need help bad! on: 2006-02-13 01:50:36
i've already done 1-3, and it is null after iterator.next(), but tracing through the code for the 30th time, i just cant  locate it for some reason! ARGGGGGGGGg
14  Game Development / Newbie & Debugging Questions / Re: Need help bad! on: 2006-02-13 01:34:13
yes i know currentI probably at some point is null, but i m having a hard time trying to find why its null
15  Game Development / Newbie & Debugging Questions / Re: Need help bad! on: 2006-02-13 00:21:45
help lol..
16  Game Development / Newbie & Debugging Questions / Re: Need help bad! on: 2006-02-12 21:44:21
What this code is suppose to do is, when I kill an enemy, he drops a item, and that item goes in the ArrayList,

the thing is, this works only for the first item that gets dropped, if i try to get any other one BESIDES the one being dropped then i get error
17  Game Development / Newbie & Debugging Questions / Re: Need help bad! on: 2006-02-12 21:41:04
it says NullPointer Exception at line 355 which is this line

1  
if(!( currentI.getBounds().intersects( quix.getBounds() )))


and if i make it a comment (/* */) then the error goes to

1  
quix.itemTask( currentI.task() );

and if i comment that it goes to
1  
   level.setGarbage( currentI.getIdRow(),currentI.getIdCol() );
18  Game Development / Newbie & Debugging Questions / Ah! Im so stupid on: 2006-02-12 21:22:57
My game is due tomorrow and im far from done so plz help

ArrayLists are making me so angry!!
I keep getting a nullpointer exception while using a iterator to go through an arrayList, but When i looked through my code, there was nothing I found that removes the element during iteration (besides the code that removes the current element after using it)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
for(int row=0;row<4;row++)
{
      if(row!=2)
      {
         currentIndex = row*level.getLevelWidth()+quix.getCol();
           
         eIterator = iList[ currentIndex ].iterator();
               
         while(eIterator.hasNext())
         {
            currentI = (Element)eIterator.next();
                 
               
            if(!( currentI.getBounds().intersects( quix.getBounds() )))
                 {
                     
                     continue;
                     
                     
            }
               quix.itemTask( currentI.task() );
               level.setGarbage( currentI.getIdRow(),currentI.getIdCol() );
               eIterator.remove();
                 
         }
               
               
               
                 
      }  
                           
}

when i execute it tells me that currentI is null, but i never made it null
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
{
   public void generateItem(int enemyIndex)
   {
      randnum = random.nextInt(60);
     
      if(randnum>40)
      {
         
           
            int index = (Integer)blankIndex.get(0);
            System.out.println(index);
            int row = index/4;
            int col = index%getLevelWidth();
           
            elementsArray[row][col] = new Element("potion",enemyIndex/getLevelWidth(),enemyIndex%getLevelWidth(),row,col,applet,app);
           
               
            itemList[enemyIndex].add(elementsArray[col][row]);
           
            blankIndex.remove(0);
           
         
         
      }
      else if(randnum>35)
      {
     
           
            int index = (Integer)blankIndex.get(0);
            int row = index/4;
            int col = index%getLevelWidth();
           
            elementsArray[row][col] = new Element("hbook",enemyIndex/getLevelWidth(),enemyIndex%getLevelWidth(),row,col,applet,app);
           
               
            itemList[enemyIndex].add(elementsArray[col][row]);
           
            blankIndex.remove(0);
           
         
         
      }
      else
      {
         
         
         
           
            int index = (Integer)blankIndex.get(0);
            int row = index/4;
            int col = index%getLevelWidth();
           
            elementsArray[row][col] = new Element("money",enemyIndex/getLevelWidth(),enemyIndex%getLevelWidth(),row,col,applet,app);
               
            itemList[enemyIndex].add(elementsArray[col][row]);
           
            blankIndex.remove(0);
           
         
         
      }
     
   }
}

1  
2  
3  
4  
5  
6  
public void setGarbage(int row, int col)
   {
      //elementsArray[row][col] = null;
     blankIndex.add(row*getLevelWidth()+col);
     
   }
19  Game Development / Newbie & Debugging Questions / help! weird problem on: 2006-02-11 19:41:43
In my game, when the character's position is 0 or less, he cant move left (left edge of the game)

My code works when he is walking on ground level (he cant move left when reach edge), but when character is jumping, in the air, then he can MOVE left. i dont know why this happens

my code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
if(key == Event.LEFT)
 {
   if(quix.getXposLeft()<=0)
   {
        quix.isWalkingLeft(false);
        quix.isFaceLeft(true);
   }
}
........................
else if (key == Event.UP)
{
   if(!quix.getJumpLock())
       quix.isJumping(true);
}
20  Game Development / Newbie & Debugging Questions / Re: Efficiency Question? on: 2006-02-10 05:34:56
but isn't time consuming to recreate objects?

I read somewhere that instead of deleting an element in the list ( that you would need later, but not at the moment), its best to not delete it, but put it in a arrayList and pull it out of the arrayList when you need it.

im pretty sure that is faster than the first two,..................right?

21  Game Development / Newbie & Debugging Questions / Efficiency Question? on: 2006-02-09 00:42:58
If I have a grid and each position on grid is an ArrayList

is it better to

1. Construct all the ArrayLists at initialization, and just leave them active, even if their is nothing in there.

2. don't make any ArrayList at initialization, but when an object moves to that spot, that instantiate an ArrayList and add it to the list, but if that object moves to a different grid, then delete that ArrayList, and make a new ArrayList, at that Enemies position

I've already done the first, and it works fine, but just wondering if is faster to do option 2.
22  Game Development / Newbie & Debugging Questions / Re: ack? Why does this code make my game freeze on: 2006-02-07 02:57:29
i did read javadoc along time ago to open a appletviewer
but
i changed my class path to jre  instead of jdk (by acc), thats why i couldnt get appletviewer to work until now
23  Game Development / Newbie & Debugging Questions / Re: quick ArrayList question on: 2006-02-07 02:55:53
ok thanks i kind of understand
24  Game Development / Newbie & Debugging Questions / Re: quick ArrayList question on: 2006-02-07 01:41:16
lol thats funny cause my Comp Sci teacher is telling me that get() returns only a copy.

but i dont understand something

in my previous 2 examples, the original list gets changed

but when i did another test, this time with Strings, the original list did NOT get changed, why is that?
1  
2  
3  
4  
5  
ArrayList b = new ArrayList();
      b.add("hey");
      String tester = (String)b.get(0);
      tester = tester.substring(0,1);
      System.out.println((String)b.get(0));
25  Game Development / Newbie & Debugging Questions / quick ArrayList question on: 2006-02-07 01:23:54
is it me or does the get() method return the address of an object instead of a copy of an object

 like for example

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
public class z 
{
   public static void main(String[] args)
   {
     
      ArrayList list = new ArrayList();
      list.add(new Bob());
     
      System.out.println("Before Change");
     
      System.out.println( ( (Bob)list.get(0) ).getX() );
     
      Bob testObject = (Bob)list.get(0);
      testObject.a();
     
      System.out.println("After Change");
      System.out.println( ( (Bob)list.get(0) ).getX() );
   }
}
class Bob
{
   private int x =0;
   public Bob()
   {
     
   }
   public void a()
   {
      x++;
   }
   public int getX()
   {
      return x;
   }
}


Considering this code, if testObject is only a copy of whats in get(0), then if i do anything to testObject, wouldn't the element in get(0) stay the same??? but when i execute the code, the element at get(0) becomes changed when I didn't use any set methods at all.

Another example with iterator.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
public class test
{
   ArrayList a = new ArrayList();
   public test()
   {

      a.add(new bob());
   }  
   public ArrayList getList()
   {
      return a;
   }
}
class Bobtester
{
   public static void main(String[] args)
   {
      test t = new test();
      ArrayList b = t.getList();
      Iterator bi = b.iterator();
      while(bi.hasNext())
      {
         bob c = (bob)bi.next();
      }
      System.out.println(b);
      System.out.println(t.getList());
   }
}
class bob
{
   int x=0;
   public void at()
   {
      x++;
   }
   public String toString()
   {
      return Integer.toString(x);
   }
}


Basically ArrayList b is suppose to be a copy of ArrayList a, but when I remove each element from ArrayList b, each element is also removed from ArrayList a..........................why is that???
26  Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException on: 2006-02-07 00:44:50
Ah ok! I understand now why I get this error (after making a few test appliacations),

My code was suppose to put the enemy in a different ArrayList each time he moves, but sometimes he would be in the same arrayList, and therefore adding to the current ArrayList while iterating through it at the same time will cause the error!!
27  Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException on: 2006-02-06 20:13:30
Read the JavaDocs for that method



if you read my first post , i said i already read the java docs but i didnt understand the circumstances for the error to happen.

But so i am guessing the error happens BECAUSE im trying to change the arrayList while im iterating through it? am i correct?

if that is the case, than whats some options that i could use???
wouldnt a CopyOnWriteArrayList be too slow
28  Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException on: 2006-02-06 14:17:54
my bad lol, but why would this error happen?
29  Game Development / Newbie & Debugging Questions / ConcurrentModificationException on: 2006-02-06 04:19:09
I keep getting this error with this code

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
   public boolean attackElement(int arrayIndex, int listIndex, int damage)
   {
     
      ((Enemy)enemyList[ arrayIndex ].get(listIndex) ).attack(damage);
      if( ( (Enemy)enemyList[ arrayIndex].get(listIndex) ).getHp()<=0)
      {
         elementsArray[( (Enemy)enemyList[ arrayIndex].get(listIndex) ).getIdRow()][( (Enemy)enemyList[ arrayIndex].get(listIndex) ).getIdCol()] = null;
         enemyList[arrayIndex].remove(listIndex); // this code causes error
        return true;
      }
      else
         return false;
   }      


what does that mean? I read the definition but i didn't understand it
1  
30  Game Development / Newbie & Debugging Questions / Re: ack? Why does this code make my game freeze on: 2006-02-06 01:17:14
blah i think i fixed it...............thanks guys




btw someone tell me how open the applet with an appeltviewer, i cant get it to work
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

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

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

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

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
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!