Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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]
1  Java Game APIs & Engines / Java 2D / Slow MouseEvents on: 2008-02-05 19:47:16
I hate asking this question because I'm sure it must be obvious if I couldn't find it while searching...

Why is it that when I move my cursor slowly (or slower) MouseEvents appear to trigger but if I move it around too quickly it's as if only some of those events are triggered/caught? Is there a way to increase how often MouseEvents are checked? I'm specifically trying to get the mouseMoved method of MouseMotionListener to be caught more often than it currently is.
2  Java Game APIs & Engines / JOGL Development / JOGL full screen mode? on: 2007-10-15 20:04:44
I've been told that JOGL is a bit buggy when dealing with fullscreen mode, specifically I was told the following:

"The main problem is that Jogl relies on the fullscreen exclusive mode in the J2SE standard library. Unfortunately this is very, very buggy and unreliable (particularly on non-nVidia cards). Worse, when it crashes it tends to trip access violations and kill the whole app, so you can't even wrap it in a try...catch block and revert back to windowed mode."

I noticed that new binaries were released last week but couldn't find any documentation on what the actual updates were. Can anyone tell me if the above problem has been fixed in that or any previous release?
3  Java Game APIs & Engines / JOGL Development / Re: Blog: Easy 2D/3D Mixing in Swing on: 2007-10-10 17:18:52
I think import com.sun.opengl.util.j2d.* has been renamed in newer versions. Has anyone posted an updated version of this demo anywhere?

While it may be a trivial change once you know what you're doing, I'm a big believer of having a demo that works first for those of us that are slow learners  Smiley
4  Java Game APIs & Engines / Java 3D / Re: Weird rendering order on: 2007-10-04 00:26:11
All very useful things to know. Thank you for your help Tom, I really appreciate it.
5  Java Game APIs & Engines / Java 3D / Re: Weird rendering order on: 2007-10-02 23:58:03
That appears to have been it, thanks. I had the following method call in my constructor. So does that mean there isn't any way to currently use any type of transparency and still maintain the front to back rendering? In this instance all of the objects were set to opaque anyway.

setVisibility(IBoardConstants.VISIBLE);

   public void setVisibility(int visibility)
     {
       // let transparency value change at run time
       transAtt = new TransparencyAttributes();
       transAtt.setTransparencyMode(TransparencyAttributes.BLENDED);
       transAtt.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);

       if (visibility == IBoardConstants.VISIBLE)
       {
         visualState = visibility;
         transAtt.setTransparency(0.0f);     // opaque
       }
       if (visibility == IBoardConstants.INVISIBLE)
       {
          visualState = visibility;
          transAtt.setTransparency(1.0f);
       }
       cellApp.setTransparencyAttributes(transAtt);
     }  // end of setVisibility()
6  Java Game APIs & Engines / Java 3D / Re: Weird rendering order on: 2007-10-01 23:38:21
That is odd. I tried googling with two different computers and got a different result than that both times (they were both the same).

Appearance app = new Appearance();
RenderingAttributes ra = new RenderingAttributes();
ra.setDepthBufferEnable(true);
app.setRenderingAttributes(ra);

Since both Appearance and RenderingAttributes are NodeComponent subclasses I would think that I could just use the following:

RenderingAttributes ra = new RenderingAttributes();
ra.setDepthBufferEnable(true);

Although this is the point where I get lost. Where do I set the ra in the scenegraph? BranchGroup is a subclass of Node and I haven't found any methods that allow me to set RenderingAttributes like I can in Appearance. I tried using this with each object  that I added to the scene, but that didn't work either.
7  Java Game APIs & Engines / Java 3D / Re: Weird rendering order on: 2007-09-30 22:15:20
My first hit came up as <a href="http://www.starfireresearch.com/services/java3d/supplementalDocumentation.html">this</a> Not sure if that's where you were pointing me but I'm not seeing anything helpful.

While I know you are trying to help and can appreciate the "teach a man to fish" thing, I know this can't be more than a few lines of code setting some int or boolean somewhere. Sometimes just seeing the two lines of code sparks more than the hours of googling, thumbing through books, reading the java3d tutorial pdfs, and searching the forum archives.

I was originally told to enable depth-sorting but it wouid seem what I should really be looking at is the depth buffer instead. If so, I thought that it was already defaulted to LESS_OR_EQUAL. If it just needs to be turned on, then that's where I'm not sure how it should be done. With the Appearance object I can use RenderingAttributes so I guess I was expecting something similiar for a BranchGroup.
8  Java Game APIs & Engines / Java 3D / Re: Weird rendering order on: 2007-09-30 20:54:51
I kind of figured there should be a flag like that somewhere that could be set. This may be a stupid question, but where? I went through every book I have and the API and couldn't find a place to set depth sorting as either a method or a flag in SimpleUniverse, BranchGroup, Canvas3D, GraphicsConfiguration, or the ViewPort classes.
9  Java Game APIs & Engines / Java 3D / Re: How can I use loader on: 2007-09-30 20:34:47
You'll have to download a JAR file and put it in your classpath. I don't remember exactly where I got mine from but if you do a search for "java 3ds loader" you should find plenty of resources to get that particular format (I don't think you specified exactly which format you were using). If you're using a standard OBJ class you can use the built in loaders.

Here is all of the code I needed to just load an object and add it to the scene. The commented code can be uncommented to load an OBJ file with the standard Java calls.
// Deleted some imports for brevity
import com.microcrowd.loader.java3d.max3ds.Loader3DS;
import com.sun.j3d.loaders.Scene;
import com.sun.j3d.loaders.objectfile.ObjectFile;
import com.sun.j3d.utils.universe.SimpleUniverse;

public class LoaderExample {

public LoaderExample()

{
   SimpleUniverse universe = new SimpleUniverse();
   BranchGroup group = constructContentBranch();
   universe.getViewingPlatform().setNominalViewingTransform();
   universe.addBranchGraph(group);
}

public static void main( String[] args ) {
   new LoaderExample();
}

   private BranchGroup constructContentBranch() {
        //ObjectFile myOBJ = new ObjectFile();
        Loader3DS myOBJ = new Loader3DS();
        Scene myOBJScene = null;
   
        //Attempt to load in the OBJ content using ObjectFile.
        try {
           myOBJScene = myOBJ.load("C:\\workspace\\Java3D\\troll.3ds");
           //myOBJScene = myOBJ.load("C:\\workspace\\Java3D\\troll.obj");
        } catch (FileNotFoundException e) {
          System.out.println("Could not open OBJ file...exiting");
          System.exit(1);
        }
        
        //Construct and return branch group containing our OBJ scene.
        BranchGroup contentBranchGroup = new BranchGroup();
        contentBranchGroup.addChild(transform(myOBJScene.getSceneGroup()));
        return(contentBranchGroup);
      }
}


                     

 


10  Java Game APIs & Engines / Java 3D / Weird rendering order on: 2007-09-30 19:31:19
Since I can't answer my own question (today) this will probably sit here forever, but let's try anyway...

I've just started in Java3D and I'm noticing some odd behavior in the following. As you can see, I have a 2D grid of objects that rotates around the x axis. However, as it does so, it sometimes appears that objects that should be behind are overlapping the objects in front of them.

My best guess is that the objects in the back are being rendered after the ones in front of them. If that's the case, anyway to force the rendering order? Any help would be appreciated.

Some images of what it looks like as it rotates:
<img src="http://i65.photobucket.com/albums/h233/darkpegasus5/Ea/front-view.jpg" />

<img src="http://i65.photobucket.com/albums/h233/darkpegasus5/Ea/distorted-view.jpg" />

<img src="http://i65.photobucket.com/albums/h233/darkpegasus5/Ea/side-view.jpg" />
11  Java Game APIs & Engines / Java 3D / Re: How can I use loader on: 2007-09-30 19:28:30
It looks like you are trying to load your file as "test".

To test it I would give the full filepath ("C:\images\test..3ds") and specify the file type to start with.

You may need to download a loader specific to your file type since Java only supports a few of the major ones. Here is an example of how I used a 3DS Loader I found on the web somewhere (start a googlin' for one).

Loader3DS myOBJ = new Loader3DS();
Scene myOBJScene = null;
   
//Attempt to load in the OBJ content using ObjectFile.
try {
   myOBJScene = myOBJ.load("C:\\workspace\\Java3D\\troll.3ds");
} catch (FileNotFoundException e) {
       System.out.println("Could not open OBJ file...exiting");
       System.exit(1);
}
12  Game Development / Newbie & Debugging Questions / Re: Game engines? on: 2007-09-29 18:51:54
This is a decent article on why not to write game engines. Until you write a few games on your own I agree that it would be a mistake to attempt to write an engine first.

<a href="http://scientificninja.com/advice/write-games-not-engines">Write Games, Not Engines</a>
13  Java Game APIs & Engines / Java 3D / Re: Texture:illegal image size on: 2007-09-29 18:12:47
Thanks for the help. The setDetailedImage() worked in the meantime for me to figure some stuff out. I upgraded to Java 6 and the method below magically started workiing. It also supports images that aren't a power of 2 if your graphics card does too.

public static Texture2D getTexture(String path)
   {
          TextureLoader texLoader = new TextureLoader(path, null);
          Texture2D texture = (Texture2D) texLoader.getTexture();
          if (texture == null)
            System.out.println("Cannot load texture from " + path);
          else {
            System.out.println("Loaded texture from " + path);
            texture.setEnable(true);
          }
          return texture;
   } // end getTexture
14  Java Game APIs & Engines / Java 3D / Re: Moving in the universe on: 2007-09-29 18:02:47
There's actually an easier way built right into the API called OrbitBehavior. An example of how to use it is listed below.

private void orbitControls(Canvas3D c)
   {
      OrbitBehavior orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ALL);
      orbit.setSchedulingBounds(bounds);
      ViewingPlatform vp = simpleUniverse.getViewingPlatform();
      vp.setViewPlatformBehavior(orbit);
   }
15  Java Game APIs & Engines / Java 3D / Re: Texture:illegal image size on: 2007-09-17 16:37:27
I'm using the built-in TextureLoader for this but I'm fairly certain that it is handling the MediaTracker implementation.

I'm also getting 256x256 printed to the console. Normally I would have seen 0x0 if the image had not been loaded which leads me to believe the tracking is in place.
16  Java Game APIs & Engines / Java 3D / Texture:illegal image size on: 2007-09-16 06:11:24
I know the image has to be a power of 2 for both dimensions. My image is 256x256 but the following still throws the illegal image size exception. Is there some bug I should be aware of?

TextureLoader loader = new TextureLoader(path, this);
ImageComponent2D image = loader.getImage();
System.out.println(image.getWidth() + "x" + image.getHeight());
// this prints out 256x256
Texture2D texture = new Texture2D();
texture.setImage(0, image);
// and here I get:
//Exception in thread "main" java.lang.IllegalArgumentException: Texture:illegal image size
   at javax.media.j3d.TextureRetained.checkImageSize(TextureRetained.java:400)
   at javax.media.j3d.TextureRetained.initImage(TextureRetained.java:345)
   at javax.media.j3d.Texture.setImage(Texture.java:940)
   at RotationTesterWithTexture.<init>(RotationTesterWithTexture.java:52)
   at RotationTesterWithTexture.main(RotationTesterWithTexture.java:65)
17  Java Game APIs & Engines / Java 2D / Re: transparent png image loaded as opaque on: 2005-12-14 18:33:17
Try using Transparency.TRANSLUCENT, I've seen some weird behavior between using this and the BITMASK.
      
18  Games Center / 4K Game Competition - 2006 / Re: HexWar4K on: 2005-12-06 15:53:17
Do you have any code for this that you can zip up? I had a boardgame that I was working on that had a hexagonal grid, but I couldn't ever get anything to work as well as yours does.
19  Java Game APIs & Engines / Java 2D / Re: Partially filling an arc with a proportional gradient on: 2005-12-06 01:41:02
Sorry guys, the above actually works. It was somewhere else in my code that I had a problem.

One thing that isn't quite right is the anti-aliasing. Using the draw code in a paint method of a component looks much better than this one does. For some reason this was only corrected after changing the transparency to:

transparency = Transparency.TRANSLUCENT;

and adding...

Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
20  Java Game APIs & Engines / Java 2D / Re: Partially filling an arc with a proportional gradient on: 2005-12-06 01:30:20
Okay, so what is wrong with this then, it doesn't appear to be doing anything...

   public void setCompositeImage()
   {
      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        int  transparency = Transparency.BITMASK;
      GraphicsDevice gs = ge.getDefaultScreenDevice();
        GraphicsConfiguration gc = gs.getDefaultConfiguration();
      if (gc != null)
      {
         BufferedImage healthMeter = gc.createCompatibleImage(100,100, transparency);
         Graphics g=healthMeter.getGraphics();
         
         UtilityFunctions.fillGradientArc(g, 0,0,100,90,180,Color.green, Color.red);
         UtilityFunctions.fillGradientArc(g, 0,0,100,270,180,Color.blue, new Color(149, 0, 51));
         g.setColor(Color.black);
         g.drawOval(0,0,100,100);
         g.fillOval(13,13,75,75);
         if (healthMeter != null)
         {
            mediaTracker = new MediaTracker(this);
            mediaTracker.addImage(healthMeter, 1);
            // Wait until all images have loaded
            try {mediaTracker.waitForAll();} catch (Exception e) {e.printStackTrace();}
            this.setOriginalImage(healthMeter);
            repaint();
         }
      }
   }
21  Game Development / Game Play & Game Design / Re: Gameboard Mechanics? on: 2005-12-05 19:08:40
If you scroll down to the bottom there is a picture of a hexagonal board. Part of the complexity has been that you have cards that can become pieces on the board.

The way I have started to implement is to have a base gameboard class that is comprised of game pieces. The game pieces fire game events that are picked up by the gameboard and sent off to seperate rulesmanager and movemanager classes. Looking at the code this seems kind of sloppy, but I wasn't sure if there was a better way to implement?

22  Java Game APIs & Engines / Java 2D / Re: Partially filling an arc with a proportional gradient on: 2005-12-04 04:13:10
I think a shortcut to this would be just to draw the entire arc with the gradient and save it as an image, I could then only draw whatever percentage of the image that I needed with the function listed above. So how would you get the following code into an image to be manipulated this way?
 
     Graphics2D g2 = (Graphics2D) g;
     GradientPaint gp = new GradientPaint(x, y, c1, x, y+(r*scale), c2, false);
     g2.setPaint(gp);
     g.fillArc(x, y, (int)(r*scale),(int)(r*scale),angle1,angle2);

oh, and I'm trying to do this dynamically since the scale changes frequently which is why I didn't just save the image off once and load it again later.
23  Java Game APIs & Engines / Java 2D / Re: Partially filling an arc with a proportional gradient on: 2005-12-03 22:27:55
That's a good idea, I completely forgot about clipping as an alternative. However, how would you clip an arc like that (my geometry is terrible)?

Basically you have a semicirlce that has a gradient in it. The gradient  represents the player's life. So as their life goes down, less of the gradient is visible (cut off as a straight horizontal line somewhere on the meter).
24  Java Game APIs & Engines / Java 2D / Partially filling an arc with a proportional gradient on: 2005-12-03 18:51:19
public static void fillScaledArc(Graphics g, int x, int y, int r, float scale, int angle1, int angle2, Color c1, Color c2)
{
     Graphics2D g2 = (Graphics2D) g;
     GradientPaint gp = new GradientPaint(x, y, c1, x, y+(r*scale), c2, false);
     g2.setPaint(gp);
     g.fillArc(x, y, (int)(r*scale),(int)(r*scale),angle1,angle2);
}

The above code will draw an arc and then fill it with a gradient from top to bottom. Let's say that I pass Color.green and Color.red as my c1 and c2 arguments. Now, let's say that I want to only fill 50% of this arc. However, I want the color to range from half-way to green (in this case kind of greenish-orange) to red . How would I rewrite this function to do this by passing it a percentage (i.e. .5 or .75)?

I'm using this to dynamically draw a health meter on one half of a circle.
25  Java Game APIs & Engines / Java 2D / Re: Finding a point along an oval on: 2005-12-03 18:44:40
Thanks guys. Here is the code I've been using, I think this only gets the first 180 degrees, but it should be enough to get someone started if they are having the same problem I was:

   private Point getPointOnEllipse(int i,int n,int x,int y,int radiusX,int radiusY)
   {
      x = (int) (x + (radiusX * Math.cos(Math.PI * i / n - Math.PI/2)));
      y = (int) (y + (radiusY * Math.sin(Math.PI * i / n - Math.PI/2)));
      return new Point(x, y);
   }

Where radiusX and radiusY are the width and height of the bounding box, respectively. i is part of a for loop and n is the total number of points to check for.
26  Games Center / Archived Projects / Re: Kumari Kandum (was Pacifica) - Version 0.3.1 (Updated Nov 28th) on: 2005-12-03 01:20:38
This was a great game, I only wish it had more levels  Smiley. The only problem I had was that the power-up with the laser sight was not always on. It's tough to tell exactly how far away the balls are at the beginning and I don't feel it has a lot to do with strategy at that point.
27  Java Game APIs & Engines / Java 2D / Re: Finding a point along an oval on: 2005-11-30 04:41:10
I'm not sure I understand what you mean. Anyway you could give me a snippet of code to help explain?
28  Java Game APIs & Engines / Java 2D / Finding a point along an oval on: 2005-11-30 01:09:03
This is probably trivial for many of you, but I'm a bit stuck as to how to proceed. My ultimate goal with this is to have a collection of 2-6 round buttons that all appear equal distance apart on an oval path. When the user clicks on one button, it rotates to the front (while scaling larger) as the other buttons rotate with it along the orbital looking path.

The following code will find equidistant points along a circle, but how do you do this if you have an oval like this?:

ellipse = new Ellipse2D.Float(0, 0, 400, 50);

/******************************************************************/

import java.awt.Point;
import java.util.ArrayList;
import java.util.List;

public class Main {     
   
    private static List findPoints(int x, int y, int r, int n)    {
       List listOfPoints = new ArrayList();
       for (int i=0; i<n; i++) {
           listOfPoints.add(
                   new Point(
                           (int)(x+r*Math.cos(Math.PI*i/n-Math.PI/2)),
                           (int)(y+r*Math.sin(Math.PI*i/n-Math.PI/2))));
       }
       return listOfPoints;
    }
   
   
    public static void main(String[] args){
        System.out.println(findPoints(0, 0, 1, 4));
    }
}
29  Game Development / Game Play & Game Design / Gameboard Mechanics? on: 2005-11-17 21:56:05
Hello all,
  I have a board game and was wondering if anyone either had some code I could use for piece movement, etc., or any suggestions about how my classes should be structured. I currently only have a gameboard that has a list of gamepiece objects.

Might help to have a pic:  http://www.projectnexxus.com/forum/viewtopic.php?t=19
30  Discussions / Community & Volunteer Projects / Re: Individual Looking for Indie Team on: 2005-11-17 20:17:03
If you just want some experience coding some Java in a game, feel free to stop by our website at www.projectnexxus.com.
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

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

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

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

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

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

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

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

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

BurntPizza (49 views)
2014-08-09 21:09:32
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!