Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 3 4
1  Java Game APIs & Engines / Xith3D Forums / Re: Node Cloning on: 2004-08-12 11:01:16
Quote

what about specifying the fully quantified class name as a string, e.g. "com.xith3d.scenegraph.Appearance"?  I just think Appearance.class.getName() is needlessly complicated when a simple String would do.


Well, Appearance.class.getName() actually does return the string "com.xith3d.scenegraph.Appearance".  Of course, since setNodeComponent(String key, NodeComponent component) takes a String as a key, there's nothing stopping a user from supplying any string he so desires.

In general, I think class.getName() is cleaner than hard-coding the string: it will cause compile errors if you mistype it, and it need not be changed if the class is ever refactored into a different package (not that I expect that to ever happen, but you never know).

Quote

Couldn't you simply use Appearance.getClass() and avoid the extra conversion to String?


I suppose I could, though personally I'm a bit happier using Strings as keys rather than Class objects as keys.  I sort of feel that String equality testing behaves in a somewhat more predictable way than Class equality testing.  Plus I think having strings as keys is more adaptable to strange cases.  For example, suppose I were to write a Node object that had two separate Appearance member variables.  With strings as keys, I could just do this:

1  
2  
3  
4  
5  
6  
7  
public void setAppearance1(Appearance appearance) {
  setNodeComponent(Appearance.class.getName() + "_1", appearance);
}

public void setAppearance2(Appearance appearance) {
  setNodeComponent(Appearance.class.getName() + "_2", appearance);
}


In fact, Appearance itself contains an arbitrarily sized array of TextureUnitState objects.  I'm still trying to figure out the best way to approach this one, but something similar to the above is certainly possible.  I'm also contemplating creating a NodeComponentArray wrapper class that is itself a child of NodeComponent, and simply contains an aribtrarily sized array of other NodeComponent objects.

Quote

Or you could even change the method setNodeComponent so it only takes one argument - the NodeComponent and calls getClass().getName() on it (the call to getNodeComponent would still need the string but).  


Quote

1  
2  
3  
4  
5  
6  
7  
8  
9  
public final void setAppearance(Appearance appearance) {
  setNodeComponent(appearance);
}
 
... setNodeComponent(NodeComponent x)
{
  // Register the component
 key=x.getClass();
}



I have to say, I think having setNodeComponent() only take a single argument is a patently bad idea.  The problem is, if I'm writing a child class of Node and I want to use this functionality to set node components, how do I know what to supply as the key for relevant getter? I don't.  By forcing the user to supply the key in the setter, I can gaurentee that said user will know exactly what to supply in the getter.  It's best to keep the definition of the key localized in a single class.

Paul
2  Java Game APIs & Engines / Xith3D Forums / Re: Node Cloning on: 2004-08-06 10:45:49
I figured it would be best to use class.getName() just in case there is ever an overlap of NodeComponent class names.  You never know, it could happen.  By using the fully qualified class name, we should be able to gaurentee uniqueness for any given NodeComponent.  

A series of constants in the NodeComponent class would do the trick as well, but then when creating a new NodeComponent child class you'd have to touch the NodeComponent class as well.  With the above, a newly created NodeComponent can be fully self-contained.

Paul
3  Java Game APIs & Engines / Xith3D Forums / Re: Node Clonings on: 2004-08-05 18:44:18
Looks like this is a bigger can of worms than I first thought.   Smiley

Looking at NodeComponent (which I had previously foolishy assumed was a child of Node -- not so) I see that the main use of this class is to be a super class of objects such as Appearance, Material, etc. in order to stream-line node cloning.  It sets up the base abstract method of duplicateNodeComponent that children must override, and the children classes do indeed override it.  Looking through the code of NodeComponent itself, it really doesn't do much else.

However, this is where the clone support ends.  There is no place where the Node class keeps any kind of list of registered NodeComponents. Node children such as Shape3D seem to simply have member instances of NodeComponent children, and nowhere do I ever see such an object being referred to by its base class of NodeComponent.

So for example, in Shape3D I see:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
 
    private Appearance appearance = null;

...

    public final Appearance getAppearance() {
        return appearance;
    }

    public final void setAppearance(Appearance appearance) {
        this.appearance = appearance;
    }


What I would recommend is having NodeComponent actually maintain a HashTable (or HashMap depending on which version of the JVM we require) of registered NodeComponents.  It would have private members to get/set node components based on class name.  Thus, the above code would actually look like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
 
    public final Appearance getAppearance() {
        // Actually, probably ought to have some checking here in
       // case the appearance node component is not set at all.
       return (Appearance)getNodeComponent(Appearance.class.getName());
    }

    public final void setAppearance(Appearance appearance) {
        setNodeComponent(Appearance.class.getName(), appearance);
    }


I have no problem making such changes, but I wanted to make sure it was ok to do, as it's going to be a much larger change than previously thought and widespread throughout the scenegraph package.

Paul
4  Java Game APIs & Engines / Xith3D Forums / Re: Node Cloning on: 2004-08-04 17:35:56
Ok, it's pretty clear this change isn't going to happen unless I do it myself.  I'm not at all against that either.  So I must ask: what are the official channels for submitting such a change?

Paul
5  Java Game APIs & Engines / Xith3D Forums / Re: Node Cloning on: 2004-07-28 18:52:59
Quote

Again, mostly trolling here for some feedback from David or someone else who actually worked on this code.  If I'm totally off base here, I'd like to be set straight.  


Rereading my own post, this looks a bit whiney to me.  I thought I'd clarify that I wasn't looking for a work-around (as I've already got a servicable one), but wanted info on what the intentions were, and some expectations on where we'll see the code go in future around this kind of thing.

Paul

6  Java Game APIs & Engines / Xith3D Forums / Re: Node Cloning on: 2004-07-28 11:41:14
Ok, I took a look at the Xith3d source code, and noticed the following in Node.java:

1  
2  
public void duplicateNode(Node originalNode, boolean forceDuplicate) {
}


And not a single child class of Node overrides this method.  So perhaps I was assuming a bit much that this method was indeed fully fleshed out.  However, I also noticed that NodeComponent has implemented the methods cloneNodeComponent(boolean forceDuplicate) and duplicateNodeComponent(NodeComponent originalNodeComponent, boolean forceDuplicate).  So perhaps really all that's missing is NodeComponent's duplicateNode() method, ala:

1  
2  
3  
4  
5  
public void duplicateNode(originalNode, boolean forceDuplicate) {
  if (originalNode instanceof NodeComponent) {
    duplicateNodeComponent((NodeComponent)originalNode, forceDuplicate);
  }
}


Again, mostly trolling here for some feedback from David or someone else who actually worked on this code.  If I'm totally off base here, I'd like to be set straight.

Paul
7  Java Game APIs & Engines / Xith3D Forums / Re: Node Cloning on: 2004-07-28 11:28:58
I suspect that duplicateNode() would not suffice, as per the javadoc:

Quote

A shared copy is one where the geometry and appearance is shared.


What I am duplicating is an animated model, in which the geometry is modified by the child animation nodes thorughout its life.  Therefore, when I duplicate it, I will need a true deep copy, otherwise multiple copies of the model that happen to be at different points in the animation (or worse yet, have different animations set) would cause the geometries of all models to get quite screwed up.

It strikes me that if duplicateNode() was included, the intention was to include the cloning methods as well, as they are mentioned right in the javadoc.  I'd really like to know from one of the developers if this is simply a case of not-yet-implemented, or if something else is going on here.    It seems to me that the hard work (duplicateNode()) is done, and it's just a matter of writing the correct wrappers, ie:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public Node cloneNode(boolean forceDuplicate) {
  Node node = new Node();
  node.duplicateNode(this, forceDuplicate);
  return node;
}

public Node cloneTree(boolean forceDuplicate) {
  Node node = cloneNode(forceDuplicate);
  if ((this instanceof Group) && (node instanceof Group)) {
    Group group = (Group)this;
    for (int i=0;i<group.numChildren();i++) {
       Node child = (Node)group.getChild(i);
       Node childClone = child.cloneNode(forceDuplicate);
       ((Group)node).addChild(childClone);
     }
  }
  return node;
}


Of course, I haven't looked in the Java3D source code of these methods, so maybe there's more that's supposed to be going on here than what I just posted.  But the above looks like a deep copy to me.  Of course, any child class of Node would have to override cloneNode() to return an object of the correct type, but from Java3D's javadocs, this looks to be expected:

Quote

Used to create a new instance of the node. This routine is called by cloneTree to duplicate the current node. cloneNode should be overridden by any user subclassed objects. All subclasses must have their cloneNode  method consist of the following lines:

    public Node cloneNode(boolean forceDuplicate) {
        UserSubClass usc = new UserSubClass();
        usc.duplicateNode(this, forceDuplicate);
        return usc;
    }


Am I missing something here?  I have to suspect that the developers of Xith just overlooked this one, but someone please correct me if I'm wrong.

Paul
8  Java Game APIs & Engines / Xith3D Forums / Why are all Group methods final? on: 2004-07-27 15:41:29
I noticed that most if not all of the methods defined in the Group object are declared final.  Why on earth is that?

I'm working on translating some animation code I wrote in Java3D to Xith3D, and in the Java3D version I relied on overriding the addChild() method of Group.  I created an AnimatedGroup object that was a child of Group, and then also had Animation objects that are children of Node.  When an Animation object is added to an AnimatedGroup object, I want to call some additional methods on that Animation object along with adding it to the group.  

My AnimatedGroup.addChild() method looked like this:

1  
2  
3  
4  
5  
6  
public void addChild(Node node) {
  if (node instanceof Animation) {
    ... do stuff to animation object ...
  }
  super.addChild(node);
}


Obviously this doesn not work when addChild() is declared as final in the Group object.  I suppose I could write a  addAnimation() wrapper method in AnimatedGroup, but it looks sloppy to me.  Is there a good reason that Group has all these methods declared as final?

Paul
9  Java Game APIs & Engines / Xith3D Forums / Node Cloning on: 2004-07-27 15:20:10
I noticed that Node includes duplicateNode(), but not cloneNode() or cloneTree().  Now, the javadocs for Node.duplicateNode read:

Quote

Copies all the node information from the originalNode into the current node. This method is called from the cloneNode method which is called from the cloneTree method.


But clearly the cloneTree and cloneNode methods don't exist in Node.  As I recall from Java3D, the correct behavior was for the user to call cloneTree(), which would in turn call cloneNode() on the current node and cloneTree() on all children nodes.  According to the Java3D API docs, duplicateNode() is called by cloneNode(), cloneNode() is called by cloneTree(), and users should only ever call cloneTree() directly.

Was an intentional diversion from this method made in Xith3D, are these methods simply not yet completed, or was this just overlooked?

Paul
10  Java Game APIs & Engines / JOGL Development / Re: Another pbuffer thread on: 2004-05-18 11:03:01
Has this ever been resolved?  I also tested the code posted above and got a similar exception as others have:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
Initalized GUI
INIT GL IS: net.java.games.jogl.impl.windows.WindowsGLImpl
PBUFFER SUPPORTED
Pbuffer created
net.java.games.jogl.GLException: Shouldn't try to bind a pbuffer to a texture if
 render-to-texture hasn'
t been specified in its GLCapabilities
        at net.java.games.jogl.impl.windows.WindowsPbufferGLContext.bindPbufferT
oTexture(WindowsPbufferGLContext.java:92)
        at net.java.games.jogl.impl.GLPbufferImpl.bindTexture(GLPbufferImpl.java
:152)
        at com.adamant.tuti.JOGLTest.init(Unknown Source)
        at net.java.games.jogl.impl.GLDrawableHelper.init(GLDrawableHelper.java:
68)
        at net.java.games.jogl.GLCanvas$InitAction.run(GLCanvas.java:191)
        at net.java.games.jogl.impl.windows.WindowsGLContext.makeCurrent(Windows
GLContext.java:160)
        at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent
(WindowsOnscreenGLContext.java:110)
        at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:232)
        at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:186)
        at net.java.games.jogl.GLCanvas.display(GLCanvas.java:74)
        at net.java.games.jogl.Animator$1.run(Animator.java:104)
        at java.lang.Thread.run(Unknown Source)


11  Games Center / Java Technology Game Development Contest - 2004 / Re: That competition- what APIs precisely are allo on: 2004-03-23 12:26:46
I didn't mean to start any kind of rumors, but the language there does seem to indicate that anything using JNI is out.  I was hoping to elicit a confirmation or refutal of that from someone official.

Paul
12  Games Center / Java Technology Game Development Contest - 2004 / Re: That competition- what APIs precisely are allo on: 2004-03-23 12:07:59
I noticed this line in section 4 of the terms:

Quote

Any "modified" versions, "scripted" games, or any game that utilizes an external engine not written in Java programming language will be disqualified.


That would seem to disqualify LWJGL, JOGL, and Gage.  That can't be right, can it?

Paul
13  Discussions / General Discussions / Re: Altering that JRE license to my own ends on: 2004-02-23 15:36:14
SWPalmer -

I think you may be confused as to exactly what Thawte's "web of trust" is.  I can tell you it's certainly not a means of getting a valid code-signing cert.  That's available at a cost of $200/year from Thawte.  Wait, you want a cert to secure your website for online purchasing?  That's a different kind of cert, also available for $200/year.  Trust me, I know the field, digital certificates 'aint cheap.

And it's not a matter of being able to swallow the cost, it's a matter of cost/benefit analysis.  There is a perfectly good way to distribute java based applications without incurring this cost.  Simply make it a downloadable installer.  Again, the customer base is already used to this method, and it's free.  I have yet to see any reason that webstart is a "good thing".

Paul
14  Discussions / General Discussions / Re: Altering that JRE license to my own ends on: 2004-02-23 15:29:30
I disagree - an extra $200/year is a significant obstacle to the average indie developer.  Especially when it can be avoided by simply offering a standard downloadable installer, which is more in line with what the customer base expects anyway.

Paul
15  Discussions / General Discussions / Re: Altering that JRE license to my own ends on: 2004-02-23 14:38:06
Yes, I have.  In fact, here's a great listing of a lot of them:

http://joeq.sourceforge.net/other_os_java.htm

The problem I had was the need for fast blitting.  This narrows the choice to VM's that support Java 1.4, to either make use of BufferStrategy objects, or to use LWJGL which requires the nio package.  So far, I have yet to see any VM that supports Java 1.4.

Paul
16  Discussions / General Discussions / Re: Altering that JRE license to my own ends on: 2004-02-23 13:38:32
Well, personally, I don't believe that web-start is really the way to go.  When I investigated it, I was quite horrified to discover that one needs to digitally sign the jars for it to work.  Having a good bit of professional experience in cyrptography and PKI, I know that the requirements to get a real code signing certificate are beyond most indie developers.  Thus we are stuck using a self-signed certificate, which I will point out leaves you with a dialog box that explicitly states:

"It is highly recommended not to install and run this code."

Do you really want your users exposed to that?  Honestly, I think a downloaded, self-executing jar (possibly wrapped with an installer that makes shortcuts that are platform appropriate) is much preferable.

But more to the point, I'm with Cas here.  I'm using Jet now, and will continue to do so in the future.  And while I might try also distributing a self-executable jar for the Linux/Mac users, I will certainly not be creating a web-start version.

Paul
17  Discussions / General Discussions / Re: Altering that JRE license to my own ends on: 2004-02-23 12:39:26
I'm sorry, but an argument was made that I've seen a lot on these boards and I have to refute it.  I'm speaking of this from kul_th_las' most recent post:

Quote

What we need is 500 finished, polished games that are worth all this arguing, which will help breed a reputation for something other than applets.


Yes, it is true that 500 released games that all require the JRE would engender the notion amoung game players that it's good to have the JRE installed.  So, who wants to be first?

And there's the problem.  Nobody wants to be first.  Nobody wants to write a game that requires the JRE to be downloaded and isntalled separately, and for good reason.  The large games aren't worried about an extra 15 MB of bloat, and thus they are encouraged to wrap a distro of the JRE into their installer.  And therefore the end user is blissfully unaware that he's even using java.

And those of us writing smaller games?  Well, we can't handle 15 MB of extra download.  And thus we're either scared away from Java altogether, or we use stuff like Jet that even further obscures the fact that we use Java.  

Sure, in either case the author could shout to the moon that he uses Java, even put the logo on every screen of the game.  But if the end user didn't need to separately download and install the JRE, he's not going to associate the JRE with that thing that makes all these cool games work.  But conversly, nobody wants to be the first game to force someone to separately download the JRE, because as we all know, the more clicks between the user and playing the game, the less likely he is to get to the end.

Paul
18  Java Game APIs & Engines / Java 2D / Re: JSE1.5 BETA1 opengl java2D  pipeline on: 2004-02-22 16:27:10
Well, I'll point out also that using the BufferStrategy without OpenGL support also causes a jump in performance (from 33 fps to around 400 fps).  Though clearly the opengl pipeline is a significantly larger increase.  I don't expect an even more radical improvement by combining the two, I merely would like to be able to code a single implementation that would use a BufferStrategy as the baseline, but also allow for further increased performance by using the OpenGL pipeline.

Paul
19  Java Game APIs & Engines / Java 2D / Re: JSE1.5 BETA1 opengl java2D  pipeline on: 2004-02-21 11:21:06
I did a search through Sun's bug database, and it looks like the issue I encountered has already been reported and fixed:

http://developer.java.sun.com/developer/bugParade/bugs/4968820.html

Looking forward to seeing Beta 2.  In the meantime, the test code I posted can be used without the BufferStrategy and shows a notable increase in render speed.  (On my own machine, at the start of 16 sprites I jump from 33 fps to 2000+ fps).

Paul
20  Java Game APIs & Engines / Java 2D / Re: JSE1.5 BETA1 opengl java2D  pipeline on: 2004-02-20 19:30:03
Ok, I made myself a test case and so far have hit a problem.  Just to start, I'll note that this is running on an Alienware Area 51m with an nVidia GeForce FX5600 Go, Mandrake 9.2, and the latest drivers from nVidia.

I wrote a test that blits progressively more images to the screen, and displays the average framerate for each number of images.  At this point, it's a non-accerated image simply read in through ImageIO.  What I've discovered is that the OpenGL pipeline does not work in conjunction with a BufferedStrategy.  All I see is a gray screen (though the output still claims to be getting quite a good framerate).

One more thing before I post the code.  I noticed Chris kept mentioning beta 2.  When I go to the download site at java.sun.com, I only see beta 1.  Is beta 2 available somewhere else?

Ok, here's the code.  My apologies for the length.
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  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.*;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;


public class OGLTest extends Frame implements KeyListener {
 
  protected boolean               mRunning = true;
  protected Image                 mImage = null;
 
  protected BufferStrategy        mBufferStrategy = null;

  protected Sprite[]              mSprites;
  protected long                  mLastSpriteCreation;
  protected int                   mSamplesTotal;
  protected int                   mNumSamples;
 
  protected int                   mFrameCount     = 0;
  protected long                  mLastFrameCount = 0;
  protected int                   mFPS            = 0;
 
  private static final int        kInitialSprites             = 16;
  private static final int        kSpriteMultiplier           = 2;
  private static final long       kSpriteIncrementInterval    = 15000;  // in ms

  public static void main(String[] args) {
    boolean useBufferStrategy = false;
    if ((args.length > 0) && (args[0].equalsIgnoreCase("--buffered"))) {
      useBufferStrategy = true;
    }
   
    OGLTest test = new OGLTest(useBufferStrategy);
    test.run();
    test.dispose();
  }
 
  public OGLTest(boolean useBufferStrategy) {
    super("OGLTest");
    setSize(640, 480);
    addKeyListener(this);
    setIgnoreRepaint(true);
    setLayout(null);
    setVisible(true);
       
    if (useBufferStrategy) {
      createBufferStrategy(2);
      mBufferStrategy = getBufferStrategy();
    }
   
    setFont(new Font("Arial", Font.BOLD, 14));
   
    try {
      mImage = ImageIO.read(new File("test.png"));
    } catch (IOException ioex) {
      ioex.printStackTrace();
    }
   
    mNumSamples = 0;
    mSamplesTotal = 0;
    createSprites(kInitialSprites);
    mLastSpriteCreation = System.currentTimeMillis();
  }
 
  public void createSprites(int number) {
    mSprites = new Sprite[number];
    for (int i=0;i<number;i++) {
      mSprites[i] = new Sprite();
    }
  }
 
  public void run() {    
    while(mRunning) {
     
      render();
      updateFPS();
      updateSprites();
     
      //  This is to allow keyboard input a chance to be parsed.
     Thread.yield();
    }
  }
 
  public void stop() {
    mRunning = false;
  }
 
  public void render() {
    Graphics g = null;
    if (mBufferStrategy != null) {
      g = mBufferStrategy.getDrawGraphics();
    } else {
      g = getGraphics();
    }
   
    render(g);
    g.dispose();
   
    if (mBufferStrategy != null) {
      mBufferStrategy.show();    
    }
  }
 
  public void render(Graphics g) {      
    //  Clear the background
   g.setColor(Color.BLACK);
    g.fillRect(0, 0, getWidth(), getHeight());
   
    //  Draw the sprites
   for (int i=0;i<mSprites.length;i++) {
      mSprites[i].render(g);
    }
   
    //  Display the framereate
   g.setColor(Color.YELLOW);
    g.drawString("Sprites: "+mSprites.length, 20, 20);
    g.drawString("FPS: "+mFPS, 20, 40);    
  }
 
  public void updateFPS() {
    long now = System.nanoTime();
   
    if ((mLastFrameCount + 1000000000) < now) {
      mFPS = mFrameCount;
      mFrameCount = 0;
      mLastFrameCount = now;
     
      mSamplesTotal += mFPS;
      mNumSamples++;      
    } else {
      mFrameCount++;
    }
  }
 
  public void updateSprites() {
    long now = System.currentTimeMillis();
    if ((now - mLastSpriteCreation) > kSpriteIncrementInterval) {
      if (mNumSamples > 0) {
        int average = mSamplesTotal / mNumSamples;
        System.out.println("Average framerate for "+mSprites.length+" sprites: "+average);
      }
      mSamplesTotal = mNumSamples = 0;
     
      int size = mSprites.length * kSpriteMultiplier;
      if (mFPS < 2) {
        size = kInitialSprites;
      }
      createSprites(size);
     
      mLastSpriteCreation = System.currentTimeMillis();
    }
   
    for (int i=0;i<mSprites.length;i++) {
      mSprites[i].update();
    }
  }
 
  public static int getRandom (int iMin, int iMax) {
    return iMin + (int)Math.round(Math.random() * (iMax - iMin));
  }
 
  public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      stop();
    }
  }

  public void keyReleased(KeyEvent e) {
  }
 
  public void keyTyped(KeyEvent e) {
  }
 
  class Sprite {
    protected int         mX;
    protected int         mY;
    protected int         mDeltaX;
    protected int         mDeltaY;
   
    public Sprite() {
      mX = getRandom(0, getWidth() - mImage.getWidth(null));
      mY = getRandom(0, getHeight() - mImage.getHeight(null));
      mDeltaX = (getRandom(0, 1) == 0) ? 1 : -1;
      mDeltaY = (getRandom(0, 1) == 0) ? 1 : -1;      
    }
   
    public void update() {
      int nextX = mX + mDeltaX;
      int nextY = mY + mDeltaY;

      if ((nextX < 0) || ((nextX + mImage.getWidth(null)) > getWidth())) {
        mDeltaX = -mDeltaX;
      }
      if ((nextY < 0) || ((nextY + mImage.getHeight(null)) > getHeight())) {
        mDeltaY = -mDeltaY;
      }

      mX += mDeltaX;
      mY += mDeltaY;
    }
   
    public void render(Graphics g) {
      g.drawImage(mImage, mX, mY, null);
    }    
  }
}

21  Games Center / Archived Projects / Danger Maze 1.5 on: 2003-11-21 14:43:30
Just wanted to let everyone know there's a new version of Danger Maze available, version 1.5.  This version includes a lot of bug fixes especially concerning the Windows 9x and ME platforms.  Check it out:

http://www.adamantgames.com/dangermaze

Paul
22  Game Development / Networking & Multiplayer / Re: URLConnection and SSL on: 2003-11-06 10:33:30
Tips?  How about, stop using IIS.  Seriously, like half the viruses out there today specifically target IIS servers to propagate themselves.  There is a Windows version of Apache available, so you don't have to go setting up a linux server just to make the switch.

Sorry, that's probably not what you wanted to hear.  Unfortunately I have no experience with IIS.  You'll have to consult your documentation, maybe get a book, or <shudder> contact Microsoft for support.  

To point you in the right direction, what you really want to do is create a self-signed certificate for your web server.  Look for that in your research.  Buying an official cert from Verisign is big bucks.  (Last I checked it was around $400, no doubt it's increased since then).  

Paul
23  Games Center / Archived Projects / Re: Danger Maze on: 2003-11-05 14:00:26
Oh, and cfmdobbie, I replied to your problem on our own forums, just in case you haven't seen it yet.  Didnt' want you to think I was ignoring you.

Paul
24  Game Development / Networking & Multiplayer / Re: URLConnection and SSL on: 2003-11-05 13:55:54
One more point -

All this is assuming you're using a self-signed certificate on your web server.  If you paid the big-bucks for a real cert from Verisign or some such, you probably don't need any of this.  I think you could just create your URL object and go.

Paul
25  Games Center / Archived Projects / Re: Danger Maze on: 2003-11-05 13:54:05
Cas (and anyone else interested) -

Here's a link to the thread I've started on SSL:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Networking;action=display;num=1068051163;start=0#0

Paul
26  Game Development / Networking & Multiplayer / URLConnection and SSL on: 2003-11-05 13:52:43
Cas asked me to give a bit of brain dump on SSL as I use it in Danger Maze, so I thought the Networking topic seemed a more appropriate place for it.  

I'm going to assume you know how to set up a web server using SSL.  Read up on your apache docs if not, or whatever web server you happen to be using.  Personally, I'm using Apache 2 on a RedHat Linux server, and found the book "Official RedHat Linux Administrator's Guide" has an excellent section in the web server chapter about setting up SSL.

Now then, presuiming you want to make a connection from a java client to your SSL web server, here we go.   We're going to use a java.net.URLConnection object, just like you would to make a get/post request over regular http.  But we're going to override the Trust Manager for that connection.  So first thing is, we need a TrustManager class.

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  
import java.io.*;
import java.net.*;
import javax.net.ssl.*;

class MyTrustManager extends X509TrustManager {
 
  protected static X509Certificate     kCert;

  static {
    FileInputStream fis = new FileInputStream("mycert.cer");
    BufferedInputStream bis = new BufferedInputStream(fis);
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    kCert = (X509Certificate)cf.generateCertificate(bis);
  }

  public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException
  {
  }

  public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException
  {
    for (int i=0;i<certs.length;i++) {
      if (!kCert.equals(certs[i])) {
        throw new CertificateException("Certificate does not match!");
      }
    }
  }

  public X509Certificate[] getAcceptedIssuers() {
    return null;
  }
}


You can see I punted on checkClientTrusted and getAcceptedIssuers.  I'm only interested in making a connection to a known server, so these methods aren't really important to me.

Now, to make the request, it should look like this:

1  
2  
3  
4  
5  
6  
7  
8  
  SSLContext sc = SSLContext.getInstance("SSL");
  TrustManager[] trustManagers = new TrustManager[1];
  trustManager[0] = new MyTrustManager();
  sc.init(null, trustManagers, new java.security.SecureRandom());
  HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

  URL url = new URL("https://myserver.com/myservice");
  URLConnection conn = url.openConnection();


From there you just use the normal means of creating a post or get with the URLConnection object.  One other trick I'll mention that I've done is rather than loading the certificate from a file, you can embed it right into your java class.  Simply make a String variable that has the PEM encoded version of your cert, then create an ByteInputStream around the string.getBytes().  Use this instead of the BufferedInputStream above, and you're all set.

Hope this helps.

--Paul
 
27  Games Center / Archived Projects / Re: Danger Maze on: 2003-11-05 12:57:06
Preferences you say?  I wasn't aware of this class - looks like I've got some javadoc reading to do.  Does this class map to the registry in windows?  What does it map to in Linux?

The webstart version is on hold as (a) I know nothing about webstart, and (b) I want to obfuscate our classes before releasing them.  It's just too darn easy to decompile java without protected it at least a little.

As for SSL, I will start a new thread in the Networking topic to discuss it.  I don't want to hijack my own game's thread to discuss SSL!

Paul
28  Games Center / Archived Projects / Re: Danger Maze on: 2003-11-05 12:02:04
Cas -

Yes, the built in GUI sales system was long and painful.  Smiley  I ended up having to write an entire gui library for it, and this after we thought the game was "done".  

The server end also required a bit of hair pulling, as we decided to go with php, a language none of knew.  Though I had done a tiny bit of php hacking when putting up our forums (using phpbb).  The client side of it was easy - just a matter of doing a regular https post.  I was even able to encode our server's certificate directly into the java code in PEM format.  I'm sure I could whip up some code samples of any of this if you want.  Send me a private message if you like.

On the flip side, we don't have a basic web sales system yet, which is something we want very much.  So you have to have a live internet connection when the game is running to make a purchase.  Should be just a matter of writing an html version of our in-game sales screen though.

The idea of making the demo easier is probably something we'll persue.  We were also thinking it might be good to greatly increase the time delay before the flood on the second level.  Going from no flood at all to 4 seconds before the flood hits seems a bit disconcerting to new users.

I like the idea of limiting play based on time, but I'm not sure how one would do this that isn't horribly easy to hack around.  I know two ways to do it, and the easy way can be faked by simply changing your clock, while the hard way requires registry keys, which is something we don't have access to in Java.  (And I wouldn't want access to it, as how on earth would you replicate that in Mac/Linux?)

Paul
29  Games Center / Archived Projects / Re: Danger Maze on: 2003-11-05 11:07:55
Yeah, Jet became a real pain for us.  We had to drop from JDK 1.4.2 to 1.4.1, as the former kept causing OutOfMemoryExceptions when compiled in Jet.  I tried using that usage file creating tool, it did make a huge usage file - about ten times the size of the one we created manually.  And yet, when I compiled with it the game wouldn't run at all!   I'm digging into it now to try and find the problem.

Cas, I'm glad you got to see the game.  I've been meaning to contact you directly about it, as your help was instrumental in getting the thing done.  So let me just say publicly thanks a ton!

There was some concern that perhaps the demo is a bit too hard.  The full version actually ramps the difficulty up at a much slower pace, but we were attempting to give the end user a real feal for what the game is like in the demo.  Perhaps we overdid it though, as level 4 in the demo is something like level 34 in the full version.

Paul
30  Games Center / Archived Projects / Danger Maze on: 2003-11-04 11:28:03
Danger Maze has gone gold!  Check it out here:
http://www.adamantgames.com/dangermaze

You may be wondering why you've never heard of this project until now.  Careful readers may note that I've posted in the past but have always been rather quiet about my own project.  This was due to it being involved in a contest whose rules made it unclear just how much we were allowed to speak of the game.  We decided to err on the side of caution, and thus my announcement of our game going gold may come as a surpise to many on this forum.

Danger Maze was written against LWJGL 0.7, and compiled using Excelsior Jet.  We hope to have java versions available soon, for use on Linux, and possibly the Mac as well.

So go download it and give it a whirl.  Feedback is very welcome.

-- Paul
Pages: [1] 2 3 4
 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

Tekkerue (37 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (28 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (34 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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!