Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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 ... 11
1  Game Development / Newbie & Debugging Questions / Re: Does using a library still expand one's abilities in general game-development? on: 2014-03-16 22:07:29
Like pitbuller says, in software development (not just game development), knowledge of industry-standard libraries is a *good thing*, not something to be avoided.  Someone with experience using the tools of the trade will get more job offers than someone who doesn't, simply because they have a broader skill set.

You're right that you could arguably learn more about certain "low-level" things when re-inventing the wheel, but you'll be a way more productive, and desirable, developer if you make smart decisions about tools and libraries.
2  Discussions / General Discussions / Re: new Youtube? on: 2014-02-22 19:22:49
I write web apps with Dojo in my day job ( => many, many JS files), and one very small but very important feature that the Chrome developer tools has that othes don't have is Ctrl+O to quickly open downloaded JS files by name.

With Firebug AFAIK I have to physically click, or tab to, the filename drop down to start typing a file name.  And I avoid debugging in IE whenever possible since its dev. tools are markedly inferior than either Chrome or FF (though perhaps IE11 is better?), but having a shortcut to type a file name to view is worth its weight in gold.  It's such a small thing, I don't know why don't other browsers' developer tools have this?  Or am I just missing something?
3  Game Development / Newbie & Debugging Questions / Re: JFrame dimensions? on: 2014-01-01 06:51:47
Abuse's second suggestion is the better approach.  You're rendering to some component you shove into a JFrame, such as a Canvas or JPanel.  Use setPreferredSize(new Dimension(640, 480) to set the size of that component.  Then your drawing surface is 640x480, and you don't have to care about the window's frame size.

On resize events, just grab the new size of the Canvas or JPanel you're rendering on.  Then you can decide whether to stretch your screens to fit, center them, etc.
4  Discussions / General Discussions / Re: Java "Mods" on: 2013-12-04 04:28:33
Isn't that one of the kickass features of Lisp?
5  Game Development / Newbie & Debugging Questions / Re: Xmx ignored when used in Runtime.exec on: 2013-11-26 21:01:27
Note that any parameters after the jar name will be command line arguments to your program, not to the JVM.  Move the -Xms/-Xmx to be before the "-jar jarName" parameters.

java -Xms1024m -Xmx1200m -jar "data.jar"

6  Discussions / Miscellaneous Topics / Re: What would you like to see in Java? on: 2013-10-09 14:57:34
Often though, doing that is a terrible idea and universally considered bad practice. A lot of bugs have been created by using non-literal format strings (bugs, and software exploits)

Objective(ly)-C(rap) compilers usually do a check for that and throw a warning on compile time if you are doing that. Like-wise, so do a lot of modern C++\C compilers.

Really?  But all of my user-facing text is externalized.  No idea how that's typically done with C++, but how it's done is irrelevant - format strings can vary in the location of their parameters from one language to the next.  Of course the format strings aren't going to be freeform, they're known at build time, as they were given to you by localizers.

Good to see Boost and/or newer standards support this kind of thing though.
7  Discussions / Miscellaneous Topics / Re: What would you like to see in Java? on: 2013-10-08 23:39:09
Getting really off topic here, and maybe this is simple, as I haven't really touched C++ in ages, but...

One advantage printf() seems to have over e.g. std::cout is localization, particularly positional parameter substitution.  For example, if I have a message template like so:

English: "Hello, {0}!"
Other-Language: "{0} xcvlxcvj!"

It's easy enough to handle this with a printf call:

printf(template, param);

But how is this sort of thing handled with C++ streams?
8  Discussions / General Discussions / Re: Java games on PC's with no Java? on: 2013-08-25 23:17:20
I'd definitely also recommend launch4j for Windows packages.  A single fat jar isn't a requirement, your project can have any structure, and your process can be launched with custom names, not java.exe.

I've also used NSIS for installers, which was also very nice.

I've also heard rumors that the JavaFX native packaging works for all Java apps, not just JavaFX ones (another linky).  If so, that's a nice option because it creates native bundles for Windows, OS X and Linux.

In short, you have lots of options!
9  Discussions / General Discussions / Re: What would you modify in Swing if you had to rewrite it? on: 2013-08-17 05:26:31
(and not being "native" when bindings for native toolkits, like SWT, were the cool thing).
It depends on your customers, some people don't expect a native "look and feel".

Aye, to a degree, that's what I was alluding to.  A few years ago, native looking (desktop) apps was what everybody wanted to build.  Nowadays, we've done a 180 and everybody wants unique looking apps.  Or maybe it just seems that way because so much stuff is being built as webapps these days, and it's so much easier for designers to get creative with CSS than it is with a programmatic styling API like Swing LookAndFeels.
10  Discussions / General Discussions / Re: What would you modify in Swing if you had to rewrite it? on: 2013-08-15 00:24:42
I'm yet another idiot who loves Swing.  Once you get past the steep learning curve, it's both very powerful and configurable.  I think it just got a bad rap for looking like crap for so long (and not being "native" when bindings for native toolkits, like SWT, were the cool thing).

I never touch GridBagLayout.  You can do everything you need with the other built-in layouts, and a fair amount of nesting.  It is often easier to use a 3rd-party LayoutManager though.

Besides what's already mentioned here, maybe that application framework JSR that never got off the ground, based on NetBeans RCP I believe.  It would help remove a lot of boilerplate from Swing applications of any appreciable size.

  • The amount of sizes you have to set to make stuff work. Setting size doesn't work, setting defaultSize doesn't work, setting preferred size doesn't work, then you have to create a random dimension object to set another size. Seems like I'm always setting everything to get it to work.

Typically, if you find yourself calling set*Size() on any components, "you're doing it wrong."  Properly-used LayoutManagers size everything properly for you 99.9% of the time.

  • Some children are possible only from a JFrame, but not in nested objects. So you want a filedialog window to appear when you click a button in your panel? Well, you can't.

I'm not sure I follow?  You can create and show FileDialog (or JFileChooser?) from any JButton anywhere in your UI...

  • Is swing JFrame the one where you cant convert easily to an Applet?

Either one would just be a container for your UI.  If you want to write an application that can run in both a window and an applet, typically you'd add all your components to a JRootPane.  JRootPane is basically all the content in your GUI application.  Then you can shove your JRootPane containing your application content into either a JFrame or a JApplet.
11  Game Development / Newbie & Debugging Questions / Re: File Not Found Exception on: 2013-04-17 20:55:39 doesn't take URLs, or string representations of URLs, as parameters to its constructor; it expects a (local) file path.  When you pass a string with "%20" embedded in it to represent a space, the class will assume you mean literally "%20", and not a space character.  Hence the file isn't found, because what you passed to it literally does not exist.

You need to pass the file name "normally," not URL-encoded.  Or use some other construct, such as

new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream("/path/to/resource")));

12  Game Development / Newbie & Debugging Questions / Re: Use LUA for ingame computers on: 2013-04-09 22:56:53
Aye, FWIW, you can "script" in JavaScript in Java 6 and 7 also, just ask for the "javascript" engine instead of "nashorn".  I believe it uses some older Rhino version.
13  Game Development / Newbie & Debugging Questions / Re: Resizing JPanels on: 2013-03-15 05:03:03
I'm not 100% clear on what you're doing, but if you're adding and removing components at runtime, and want to do things the "right" way (e.g. have components laid out according to the installed LayoutManager), you typically just call revalidate().
14  Discussions / General Discussions / Re: I Switched to IDEA! on: 2013-03-11 14:21:45
Personally I have to flex my entire hand to be able to "ctrl+y", but I can do "ctrl+d" with ease.

Not that I use IDEA, but can't you just use both  hands for that shortcut?  If you're shortcut-driven then both hands will be on the keyboard most of the time, then shortcuts like those aren't a problem.  Not to mention you get to be one of those geeky people who brag about never using a mouse!
15  Java Game APIs & Engines / Java 2D / Re: Manipulating BufferedImages with IndexColorModels on: 2013-02-25 00:40:32
Thanks guys.  Sorry about the super-small sample image; I was using the simplest test case possible, a single 16x16 tile, all one color, while trying to figure things out.

I had tried all those RenderingHints in the hope they would make a difference (as well as perhaps ward off issues when creating new images with scales > 1) but they seem to make no difference - the result is still the same, apparent dithering.

I found this old thread, in which Abuse gives an approach that does work.  If you start with one IndexColorModel'd Image, and create a new BufferedImage with a new ColorModel but the same Raster, things are much happier.  I'm still not sure why you get differing results when using a "grayscale" IndexColorModel vs. another IndexColorModel, when using a source image that has all pixels the same color, but whatever.
16  Java Game APIs & Engines / Java 2D / Manipulating BufferedImages with IndexColorModels on: 2013-02-24 07:41:18
Hopefully it's just because it's so late, but for the life of me I can't figure this out.  I start with an 8-bit PNG image.  I can create a grayscale version of this image with Java2D like so:

   private static final IndexColorModel createGreyscaleModel() {
      int SIZE = 256;
      byte[] r = new byte[SIZE];
      byte[] g = new byte[SIZE];
      byte[] b = new byte[SIZE];
      for (int i=0; i<SIZE; i++) {
         r[i] = g[i] = b[i] = (byte)i;
      return new IndexColorModel(8, SIZE, r, g, b);

   private static final BufferedImage createIndexedCopy(Image orig, IndexColorModel cm, int scale) {
      int w = orig.getWidth(null);
      int h = orig.getHeight(null);
      BufferedImage out = new BufferedImage(w*scale, h*scale, BufferedImage.TYPE_BYTE_INDEXED, cm);
      Graphics2D g2d = out.createGraphics();
//      g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
//      g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
//      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
//      g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
     g2d.drawImage(orig, 0, 0, w*scale, h*scale, null);
      return out;

   // ...

   BufferedImage grayscaleImage = createIndexedCopy(otherImage, createGreyscaleModel(), 1);

The end result looks like what I'd expect.  So next, I thought I'd try to create a "greenscale" version of the image by creating the color model like so:

   private static final IndexColorModel createGreenModel() {
      int SIZE = 256;
      byte[] r = new byte[SIZE];
      byte[] g = new byte[SIZE];
      byte[] b = new byte[SIZE];
      for (int i=0; i<SIZE; i++) {
         g[i] = (byte)i;
      IndexColorModel model = new IndexColorModel(8, SIZE, r, g, b);
      return model;

But the end result isn't what I want.  It looks as if some kind of interpolation was done, even though the image was never scaled.  This happens even when the original image is just a single color.  See the example below.  The original (blue) image has all pixels a single color, the grayscale version looks good, but the green version doesn't...

What am I missing?
17  Java Game APIs & Engines / Java 2D / Re: Event handling on: 2013-02-22 01:38:49
If you need custom events, and not built-in events as xsvenson speaks of, there are two available options.  You can choose which one is more appropriate for your situation.

1. Use java.beans.PropertyChangeEvents.  JComponents can fire such events by any of their many firePropertyChange() overloads.  Then the other component interested in these events would call customComponent.addPropertyChangeListener("propName", this);  This technique is common if you have say boolean, int or String properties that other components might be interested in receiving change notifications for.

2. The second option is more legwork, but allows you to notify listeners with an entire event object containing arbitrary data, instead of just an old/new value pair.  Roll your own Event class (subclassing java.util.EventObject), Listener interface (extending java.util.EventListener), and make your custom component accept Listeners of that type.  It follows the same pattern as the "built-in" event types like ActionListener, so it's pretty straightforward.  A simple example can be found here.  Note that JComponents already have a protected EventListenerList field named "listenerList", so you don't have to add such a field in your custom component yourself.
18  Game Development / Newbie & Debugging Questions / Re: JFrame/Frame and the Event Dispatch Thread on: 2013-02-18 20:50:30
You're right that there's no effective "real-world" difference.  The main reason I think people suggest to use AWT over Swing for games is that there's simply less overhead.  As soon as you create a JFrame, a JPanel, etc., Swing's LookAndFeel-related classes all get loaded, but if you're not using any JComponents other than say a custom-painted JPanel, you don't actually use them.  Why load classes you don't need or use?  etc.

Again, this is a negligible "benefit", and certainly isn't noticed by users.
19  Discussions / Miscellaneous Topics / Re: Legend of Zelda: Look into item dropping algorithms on: 2013-02-17 02:05:25
I'm surprised nobody's analyzed the ROM and figured out the exact algorithm for item drops, including the bits and pieces the video says are still unknown.

Those speedrunner guys though, they always figure out *everything*.
20  Discussions / Miscellaneous Topics / Re: Java blocked on Macs? on: 2013-02-02 20:53:46
According to the article the Department of Homeland Security also recommends against Java...isn't their time better spent catching intentionally malicious things or, say, terrorist attacks? Roll Eyes

This reminds me of people who get a speeding ticket and complain, "Shouldn't the cops be out catching murderers and bank robbers?"
21  Discussions / General Discussions / Re: Why java over other languages? on: 2013-01-31 17:30:09
- the lambda introduces a new operator "->" which must be learned
- Also the "e -> " part of the expression is alien to Java. It seems to be sort of argument passing to a parameter which has the same name as the argument ... it's also somethign new, other parts of java don't work this way.

But if Java 1.0 were shipped supporting lambdas and this syntax you'd think differently, as you'd be used to it.  Just because you have to learn new syntax doesn't mean Java suddenly becomes bloated or confusing.

If you were learning Java post-Java 8, and your education included lambdas, would you think "this one feature is just too confusing," or would you simply accept it and happily move on?
22  Game Development / Newbie & Debugging Questions / Re: Quick Swing Question on: 2013-01-29 23:41:44
You set the layout of the JFrame to null, when you probably meant to set the content pane's layout to null.  This works:

public Window() {
      JFrame mainFrame = new JFrame();
      mainFrame.setSize(1024, 786);
      mainFrame.setLocationRelativeTo(null); //Centers the window on the users screen.
     mainFrame.setTitle("Temp Name");
      insets = mainFrame.getInsets();
      JTextArea gameTextArea = new JTextArea();
      gameTextArea.setBounds(50, 30, 100, 20); //X position, Y Position, Length in pixels, Height in pixels.

Standard Swing-fanatic disclaimer:  It's really preferable to use a LayoutManager rather than null layout, as then your UI could be designed to allow the window to be resizable and still look nice, not to mention handling different LookAndFeels having different widget sizes, the user's desktop settings, etc.
23  Game Development / Newbie & Debugging Questions / Re: [FPS Camera: Robot.mouseMove() persistency] on: 2013-01-27 06:28:06
Quote from: GabrielBailey74 link=topic=28565.msg260180#msg260180
If someone thinks the reason I'm not getting the persistency I'd prefer is due to the reason of my implementation of compensating for the window's borders, I've executed the program without compensation and it made no difference.

I see what you're trying to do, but note that hard-coding the size of the window's title bar and borders is a bad idea.  Different OSes will have different values, let alone if the user has different themes, font sizes, display settings, etc.  You will need to handle such information dynamically.

As for the mouse events, you'll never get one for each pixel the mouse moves.  Your best bet might be to also listen for mouseExited() events and move the mouse back on them as well.  You'll most likely need to handle mouseDragged() events the same way too, since they won't get handled by your mouseMoved() handler.
24  Discussions / General Discussions / Re: how to make a soccer game in 2D with java? on: 2013-01-18 04:10:22
I had a software manager once that didn't know anything about coding and determined your performance based on lines of was hell.

You had a manager that read through your code?  That in and of itself is strange to me.  Unless you're saying he gauged your performance based on `wc -l`, like the old joke, in which case I don't see the problem - that's easily abusable in your favor...
25  Game Development / Newbie & Debugging Questions / Re: [Loading A 'small movie' in .PNG frames (Memory DEBO)] on: 2013-01-17 23:39:57
Yes, but you saved 20MB because the ImageIcons were simply wrapping the BufferedImages, so naturally there was more stuff in memory with a list of ImageIcons.  The actual RAM used by BufferedImages was the same.  If you cannot cut down your image size or resolution, you'll probably have to find an Image implementation that is more space efficient than BufferedImage (which I believe typically is just uncompressed RGB data).  See this StackOverflow post for a discussion about this very problem and possibly some ideas for minimizing your memory requirements.
26  Game Development / Newbie & Debugging Questions / Re: [Loading A 'small movie' in .PNG frames (Memory DEBO)] on: 2013-01-17 05:16:50
Are you getting OutOfMemoryErrors?  Or just performance problems but the program runs?  If the former, just increase the maximum heap size:
java -Xmx1024m ...
27  Discussions / Suggestions / Re: Bugs on: 2013-01-09 22:48:46
I have the opposite problem.  I get angry when sites require fewer than X characters. (And unbelievably, it's a financial institution I use that does this - where I want a long password the most!).
28  Discussions / Business and Project Discussions / Re: Looking for a part-time (or preferably full) coder for Project Zomboid on: 2013-01-08 19:54:24
The former won't do anything, the compiler will be better than you at optimizing stuff like that in 99.9% of cases. In fact, all you will accomplish is obfuscating your code and wasting time on premature optimization. And it's micro optimization, which is even worse because it's usually wrong.

The JVM Specification actually states that the two approaches are equivalent, IIRC.  Space for all local variables of a method is pre-allocated at method invocation.  It doesn't matter whether a variable is declared inside of a loop or outside of it.  Variable scope should be based on what makes the most sense.
29  Game Development / Newbie & Debugging Questions / Re: Specify What To Paint On? (Java2D) on: 2013-01-07 23:39:02
Not sure if this is what you're asking for, but if you want to display different panels as the "main" content pane, depending on certain criteria, then CardLayout is what you're after.

As for whether it's worth it to create them up front vs. creating new ones on the fly, the answer is: do whatever you want, as long as it performs well enough.  If you can create your panels fast enough that lazily creating them shows no perceivable performance issue to the user, then why not?
30  Java Game APIs & Engines / Java 2D / Re: OpenGL VM flag degrade performance on Java2D??? on: 2013-01-07 22:08:06
Setting flags like that always screams to me "I can determine what Java2D pipeline will run faster on this machine better than Java2D itself can."  Do you think the JVM is picking the wrong pipeline for some reason?
Pages: [1] 2 3 ... 11

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (30 views)
2014-04-15 18:08:23

BurntPizza (27 views)
2014-04-15 03:46:01

UprightPath (42 views)
2014-04-14 17:39:50

UprightPath (24 views)
2014-04-14 17:35:47

Porlus (41 views)
2014-04-14 15:48:38

tom_mai78101 (63 views)
2014-04-10 04:04:31

BurntPizza (123 views)
2014-04-08 23:06:04

tom_mai78101 (222 views)
2014-04-05 13:34:39

trollwarrior1 (189 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30 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‑
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!