Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (865)
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  Game Development / Newbie & Debugging Questions / Re: Problem with colours when writing BufferedImage to file on: 2006-01-10 05:08:20
Ah, that was it. Thanks. Oddly enough, though, I manage to run out of heap space when drawing to the Graphics object. Never seen that in a program without bugs. I had to scale my image by 0.5 before it would fit in memory.  Undecided
2  Game Development / Newbie & Debugging Questions / Re: Problem with colours when writing BufferedImage to file on: 2006-01-09 00:48:47
More information : I tried making a png (which indeed works) for comparison. Then I uploaded the png and jpg versions to Photobucket so people could see what the problem was. However, my browser refuses to display the jpeg version; I just get the little red cross. I find this exceedingly weird, since my windows Picture Viewer does display it, even if it is in weird colours.
3  Game Development / Newbie & Debugging Questions / Problem with colours when writing BufferedImage to file on: 2006-01-08 00:53:44
I have made a little Java snippet to load some image files, combine them together into a single image, and write them to file. Now, when I display the BufferedImage that is internal to my application, it looks fine, very nice primary colours. But when I write to file and inspect the resulting jpg, I get a fairly weird set of colours. Does anyone know what the problem might be? Perhaps I need to specify what colour model I am using, to the ImageWriter object? I'm using the ImageIO.write(BufferedImage, String, OutputStream) method.

(Incidentally, has anyone else noticed how easy it is to miss the 'f' key and write BuggeredImage instead?)
4  Java Game APIs & Engines / JOGL Development / Re: Intermittent black screen on: 2005-05-09 20:14:39
Quote
It sounds to me like you should probably initialize your renderable objects in your GLEventListener's init() method.


Ah, of course. The original problem was that I was doing just this, but the RenderManager class relied on the GUI class instance being constructed, and the init method got called in that GUI class constructor; hence I couldn't guarantee the Renderables being registered by the time the init got called. The obvious solution is to separate rendering management from GUI, which is better design anyway; I guess I was to close to the problem. Also I will explicitly initialise the GUI class instance, instead of relying on a static instance.
5  Java Game APIs & Engines / JOGL Development / Re: Intermittent black screen on: 2005-05-09 00:24:42
Hmm. While I found the problem, it wasn't so easy to fix. I eventually kludged my way around it by checking in the render method of my renderables whether or not it is initialised. Clearly this is not on for the long term!

What I'd like to do is create my GUI object, and then wait until the GL context is ready to add and intialise my renderables. Unfortunately I can't find a way to interrogate a GLDrawable as to whether it is ready or not. Does anyone have a good idea on this?

I have tried code of the form

1  
2  
 
while (theGLDrawable.getGL() != null) {}


but I still could not initialise my objects properly after this was complete. Specifically, when I ask for glGenLists, it returns 0.
6  Java Game APIs & Engines / JOGL Development / Re: Intermittent black screen on: 2005-05-07 17:40:45
Ah, I found the problem! Thanks, people, you put me on the right track. I'll describe the problem in case any other newbie can learn from it :

I have some initialisation code for my renderable objects; this code is called by the initialisation method of my RenderManager class, which in turn is called by my GLEventListener's init method. But the latter is called somewhere in the constructor of my main GUI class, which sometimes occurs (threads, right enough) before my renderable objects have been registered with the RenderManager. Hence they never get initialised, with predictable results.
7  Java Game APIs & Engines / JOGL Development / Intermittent black screen on: 2005-05-06 01:29:34
I've got my application to the point where it is drawing two red triangles to my screen. So far, so good. Except that, about one in four times, it doesn't draw - I get a black screen instead. This is without changing any code or anything - I start the program once, it draws fine; next time, black screen.

Now, it's a rather large application, so I'm reluctant to make you all wade through the whole code. Can anyone think of some common newbie error that might cause this? If not, I'll post the rendering code for you all to pick through. I am myself totally baffled; computers should be deterministic, curse it!  Huh
8  Game Development / Newbie & Debugging Questions / Problem with AWT listener class on: 2005-04-14 00:15:59
I am trying to write some internal button classes; since they are going to share a lot of functionality, I derive them from a single superclass. Unhappily, this seems to cause me problems with the MouseClicked method. Here is 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  
class MyButton extends Container implements MouseListener {
      private Label nameLabel;

      public MyButton (String tex) {
       nameLabel = new Label(tex, Label.CENTER);
       setLayout(null);
       addMouseListener(this);
      }

      public void mouseClicked  (MouseEvent e) {
        System.out.println("mouseClicked!");
      }

      public void mouseEntered  (MouseEvent e) {
        System.out.println("mouseEntered!");
      }

      public void mouseExited   (MouseEvent e) {}
      public void mousePressed  (MouseEvent e) {}
      public void mouseReleased (MouseEvent e) {}
}

final class DamageViewButton extends MyButton {

      public DamageViewButton () {
       super("D");
      }

      public void mouseClicked  (MouseEvent e) {
       System.out.println("I hear ya!");
       currModuleViewType = VIEWDAMAGE;
       updateModuleView();
      }
}


When the mouse enters the button, I get the message "mouseEntered" just as I should. But on clicking, I get neither "mouseClicked" nor "I hear ya!" Does anyone know what the problem might be? Should I not overwrite listener-interface methods?
9  Game Development / Newbie & Debugging Questions / Re: Problem with Comparator interface on: 2005-03-29 17:12:35
Comparable, right you are. I found the thing that was confusing me : My testing algorithm was a bit flawed, so it looked like it was working before I introduced the subclasses. In fact it wasn't.  Smiley

Thanks for the replies. I'm not happy with the casting, though; I like to avoid that when I can.  Sad
10  Game Development / Newbie & Debugging Questions / Problem with Comparator interface on: 2005-03-28 23:58:41
I have a class called Module, which often needs to be sorted by priority. I therefore make it implement the Comparator interface, thus :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public int compareTo (Module d) {
      System.out.println("Comparing better");
      if (priority > d.priority) return -1;
      if (priority < d.priority) return 1;
      return 0;
}


public int compareTo (Object d) {
      System.out.println("Comparing boring");
      return 0;
}


Unhappily, the prints indicate that it is the second, default method that is being called when I ask for sorting of an array of subclasses of Module. I didn't have this problem before I created the subclasses, so I'm reasonably sure this is the cause.

I tried making a compareTo method for each subclass, but it is still the generic method that is called. Does anyone have a good solution?
11  Java Game APIs & Engines / Java 3D / Java3D and frame updates on: 2005-02-27 16:02:00
I'm just starting to learn Java3D, so please be patient if I ask stupid questions.

I have a bunch of objects to be drawn to a Canvas3D, but first their positions and rotations need to be updated. As I understand it, if I call a method in the object that changes its associated Transform3D, the Java3D renderer will immediately render the change. What I would like to do, however, is to first update each object, and then render all the objects together.

I have looked at the documentation for immediate mode, but I must admit I find it rather confusing. It also seems that the Behaviour class could do what I want; but that means giving the graphics engine, rather than my game engine, control over when my objects are updated, and I'm not happy with that idea.

Do I need to extend the Canvas3D class and explicitly call its rendering methods, and if so, in what order? Can I use stopRenderer() and startRenderer() methods to stop the graphics engine while I do my updates, or would that involve fantastic amounts of overhead? Is there a good tutorial out there? Should I be using an offscreen buffer, perhaps? (I found the documentation for that rather difficult to follow also. Perhaps someone could simplify it for me?)
12  Java Game APIs & Engines / Java 3D / Re: Rotating around an arbitrary point on: 2005-02-27 16:00:48
Oh, so that's what quaternions are for! Thanks mnjacobs. Just looking at the documentation, I got the impression they were just a complicated way to rotate something about the origin.  Smiley
13  Java Game APIs & Engines / Java 3D / Rotating around an arbitrary point on: 2005-02-22 22:53:57
I've just started learning both Java3D, and 3d graphics in general. Consider an object displaced by a fair amount from the origin. Is there a good way to rotate it about its cetner of mass, or an arbitrary point, rather than the origin? Preferably without having to overwrite any methods in the standard Java3D classes.

Now, I realise it's possible to do this using Transform3D objects, by rotating first, then translating back to the position. But I'd like to make these two operations independent of each other. Does anyone have any ideas?
14  Game Development / Newbie & Debugging Questions / Problem with loading image on: 2005-01-29 20:55:12
I am attempting to load in a .gif file to serve as a sprite for one of my game objects. To do this I use the line :

myImage = Toolkit.getDefaultToolkit().getImage("razz.gif");

However, this appears to introduce some Weird Stuff (tm). This is a basic top-down shooter, with a map of tiles. A tile that does not contain any other game object just draws a green square. But when I call my initialising method, it just draws the tiles to the first one containing a sprite, then stops drawing. Some considerable time later, it will start drawing the .gif for the sprites.

This seems to be a problem with the loading time for the gif file, but I'm not entirely sure how to deal with it. Is there a way to say 'stop executing until the image is fully ready'?

Now, the gif is an animated one (in point of fact it's a smiley  Smiley ) and that works well. But every so often the animation will cease and a blank red square will be drawn. This does not seem to occur at the end of every animation cycle, so I'm really not sure what might cause it. Ideas?
15  Game Development / Newbie & Debugging Questions / Eclipse on: 2004-10-11 01:00:17
So I looked into their homepage, but I'm not quite sure what this package does. Will it compile to machine code, or just bytecode? Has anyone had any particularly good or bad experiences with it? Would you recommend it? They seem completely unable to write good documentation or FAQs, which is a point against.

For comparison, at the moment I write code in emacs and compile with the javac that comes with the Java SDK.
16  Java Game APIs & Engines / Java 2D / Overlap checking for Polygons on: 2004-06-29 01:27:11
I've got some extremely general (user-defined) Polygons, and I want to test that they do not overlap. Is there a clever way to do this? I could crawl along each segment between polygon vertices, checking pixel by pixel whether the line is contained in another polygon, but it seems a bit inelegant. Can anyone point me to a smarter method?

Performance, incidentally, is not an issue here, since I'll only be doing this at startup - my polygons are map sectors defined in a text file.
17  Game Development / Newbie & Debugging Questions / Re: Using an editable JComboBox on: 2004-06-14 20:52:35
It doesn't seem to be the layeredPane, I get the same result just using the contentPane. Nix on the TAB, though I didn't see what would happen if I wrote a keyboard listener to move the focus around. I did try calling requestFocus in actionPerformed (when a button was clicked), but no dice.

However, I've decided that a TextField, with buttons on either side to traverse the names, is a cooler solution anyway. So it's not a huge priority. Would be nice to know what's going on, though. Let's hope I can give focus to a TextField.  Smiley
18  Game Development / Newbie & Debugging Questions / Using an editable JComboBox on: 2004-06-14 01:20:09
I am trying to permit the player to choose from predefined factions, but allow him to rename his own if it suits him. For this, I'm trying to use an editable JComboBox. However, the box refuses to be edited. That is, it comes up on the screen as it should, and I can select my hardcoded strings; but when I click on it to try editing, it doesn't seem to gain the keyboard focus. Do I need to do anything special, other than call setEditable(true), to make it do so? Here's my code so far :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
   constructor {
      (...)
      familyChoice = Family.getFamilyChoice();
      familyChoice.setBounds(250, 50, 175, 30);
      familyChoice.setVisible(false);
      familyChoice.setEditable(true);
      getLayeredPane().add(familyChoice, JLayeredPane.PALETTE_LAYER);
   }

  // In class Family :
  public static JComboBox getFamilyChoice () {

      String[] temp = new String[allFamilies.length];
      for (int i = 0; i < temp.length; i++)
         temp[i] = allFamilies[i].name;

      return new JComboBox(temp);
   }


I call setVisible(true) in actionPerformed, and it pops up just as it should. I am not overwriting any of the painting methods. Suggestions?
19  Game Development / Newbie & Debugging Questions / Re: Displaying buttons at startup on: 2004-06-11 23:34:14
Ah, that works and is so much more elegant. Thanks.
20  Game Development / Newbie & Debugging Questions / Re: Displaying buttons at startup on: 2004-06-11 22:18:01
Aggh! That is, the code works if I put it in the constructor of my game-initialiser object. However, I would like for the list to pop up when the player presses the "New Game" button, which means I would like to have the list waiting in the wings, then update in the actionPerformed method. As far as I understand the thread issues, this is safe, right?

However, if I do things this way, I get that grey rectangle again, instead of the list within a viewer that I get if the code is in the constructor. I've tried putting the initialisation code in the constructor and just adding it in actionPerformed, like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
  constructor () {
      (...)
      scenList   = new JList(scenarionames);
      scenViewer = new JScrollPane(scenList);
      scenList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      scenList.setVisibleRowCount(-1);
      scenViewer.setBounds(new Rectangle(-1000, -1000, 200, 500));
   }

   actionPerformed {
      getContentPane().add(scenViewer);
      repaint();
   }

with the same result. Next I tried initialising scenViewer with width and height both zero, like so :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
  constructor () {
      (...)
      scenList   = new JList(scenarionames);
      scenViewer = new JScrollPane(scenList);
      scenList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      scenList.setVisibleRowCount(-1);
      scenViewer.setBounds(new Rectangle(100, 100, 0, 0));
      getContentPane().add(scenViewer);      
   }
    actionPerformed {
      scenViewer.setBounds(new Rectangle(100, 100, 200, 500));
      repaint();
   }

again with the same result. Finally - success at last! - I initialised it to be off screen, then moved it back in when actionPerformed was called, thus :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
  constructor () {
      (...)
      scenList   = new JList(scenarionames);
      scenViewer = new JScrollPane(scenList);
      scenList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      scenList.setVisibleRowCount(-1);
      scenViewer.setBounds(new Rectangle(-1000, -1000, 200, 500));
      getContentPane().add(scenViewer);      
   }

    actionPerformed {
      scenViewer.setBounds(new Rectangle(100, 100, 200, 500));
      repaint();
   }

This did have the side effect of suddenly blanking (making white) half my screen, but I was able to fix that in paint(). Could you explain to me why these apparently similar procedures give such different results? You've been very helpful so far.
21  Game Development / Newbie & Debugging Questions / Re: recursion and static methods on: 2004-06-11 21:38:27
You might be getting overflows even with correct logic, if your problem is big enough. Recursion is very easy to program, but fantastically inefficient.
22  Game Development / Newbie & Debugging Questions / Re: Displaying buttons at startup on: 2004-06-11 19:39:58
Ah, doesn't that look lovely, now?  Cheesy  Thank you. I'm not sure whether to feel stupid for not seeing that, or pleased because it works at last.  :-/ About the one-step, I used that too at first, then changed it do see if it made a difference.
23  Game Development / Newbie & Debugging Questions / Re: Displaying buttons at startup on: 2004-06-11 01:00:48
OK, I think I understand that. It is only moderately un-obvious after being pointed out  Wink. Maybe you can understand why this doesn't work?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
      scenarionames = new String[]{"blah", "bleh"};

      scenList   = new JList(scenarionames);
      scenViewer = new JScrollPane();
      scenViewer.setViewportView(scenList);
      scenList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      scenList.setVisibleRowCount(-1);
      scenViewer.setAlignmentX(LEFT_ALIGNMENT);

      getContentPane().setLayout(null);
      getContentPane().add(scenViewer);
      getContentPane().add(scenList);

      scenViewer.setBounds(new Rectangle(400, 100, 200, 100));
      scenList.setBounds(new Rectangle(100, 100, 200, 500));
      show();


The way it doesn't work is that scenViewer is displayed, a nice gray rectangle, but with no list inside it. I display the raw list beside it as a test; that comes out fine - one blah, one bleh, both selectable. I've looked through the examples, and I cannot figure out what I am doing differently from what they do. I have no painting code this time, I leave everything to the builtin paint method, which evidently calls paintComponents just as it is supposed to. Why isn't the JScrollPane painting its contents?
24  Game Development / Newbie & Debugging Questions / Re: Displaying buttons at startup on: 2004-06-10 23:09:51
Yes, that's where I got the idea of using repaint. But as far as I could see, it doesn't explain why this is what works. OTOH, maybe I just missed it skimming through and trying things one after another.  Smiley
25  Game Development / Newbie & Debugging Questions / Re: Displaying buttons at startup on: 2004-06-10 20:17:42
Well, something similar. The code works if I call quitButton's repaint() method instead of paint(Graphics). Why this should be, I have no idea. If anyone cares to enlighten me, I would be most grateful.
26  Game Development / Newbie & Debugging Questions / Displaying buttons at startup on: 2004-06-10 02:14:25
I am trying to make a startup screen for my game, with a background picture and some buttons. However, when I call my Buttons' paint(Graphics) method, they do not appear on the screen. This code :

1  
2  
3  
4  
   public void paint(Graphics g) {
      g.drawImage(frontpic, 0, 0, Color.white, null);
      quitButton.paint(g);
   }

produces only my background image called frontpic. Why is this? Here is the initialisation I did for my Buttons :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
      quitButton = new JButton(QUITGAME);
      quitButton.setActionCommand(QUITGAME);
      quitButton.addActionListener(this);

      getContentPane().setLayout(null);
      getContentPane().add(quitButton);

      getContentPane().setBackground(Color.white);

      // TODO : Set according to resolution.

      quitButton.setBounds(new Rectangle(850, 30, 120, 20));

      show();
Pages: [1]
 
Riven (197 views)
2019-09-04 15:33:17

hadezbladez (4897 views)
2018-11-16 13:46:03

hadezbladez (1800 views)
2018-11-16 13:41:33

hadezbladez (5171 views)
2018-11-16 13:35:35

hadezbladez (1021 views)
2018-11-16 13:32:03

EgonOlsen (4384 views)
2018-06-10 19:43:48

EgonOlsen (5226 views)
2018-06-10 19:43:44

EgonOlsen (2969 views)
2018-06-10 19:43:20

DesertCoockie (3872 views)
2018-05-13 18:23:11

nelsongames (4303 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
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!