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] 2 3 ... 41
1  Game Development / Newbie & Debugging Questions / Re: Updating JFrame components.. on: 2014-09-01 23:34:01
This is precisely the use case of a SwingWorker
Even has update-JLabel-background-thread example. I'd assume you'd put the "start the game" code in done().

EDIT: Though I still don't see why you actually need it to be asynchronous.
2  Game Development / Newbie & Debugging Questions / Re: Updating JFrame components.. on: 2014-09-01 23:15:05
Are you asking that because you want the main thread to wait for the JLabel to appear? If so, then just do the sleeping in the main thread, no extra thread needed.
3  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac: Ive been practicing for 2 weeks and... on: 2014-09-01 17:36:05
Personally I think there just comes a time when suddenly everything just "clicks", now I don't mean that you suddenly know everything but you suddenly get everything. It gets to the point that you just understand what code is doing, even if you didn't know it could be done like that.

I can agree with this. Until you look at other languages in other paradigms, then you need clicked again.
4  Game Development / Newbie & Debugging Questions / Re: Updating JFrame components.. on: 2014-09-01 17:15:58
You just want the label to show up after a delay?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
...

frame.setVisible(true);

new Thread(new Runnable() {
    try {
        Thread.sleep(delay);
    } catch (Exception e) {}
    frame.add(label);
}).start();
5  Games Center / WIP games, tools & toy projects / Re: Airships: Conquer the Skies on: 2014-09-01 14:53:04
Air-to-air paratroopers sounds awesome. Also adds to the mechanic that you have to get above the enemy to be able to board them, unless you get jet pack upgrades or something.
6  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Nightmod - Rapid development live-coding game specific IDE on: 2014-09-01 05:05:14
Well, they do say lisp is an acquired taste.
7  Game Development / Newbie & Debugging Questions / Re: Subclass Questions on: 2014-09-01 04:09:41
Not sure why your panel isn't displaying, but here's a more idiomatic and stripped down version that uses your inheritance model to play with:

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  
import java.awt.*;

import javax.swing.*;


class TestFrame extends JFrame {
   
   TestFrame() {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setVisible(true);
   }
}
class RunFrame extends TestFrame {
   
   RunFrame() {
      super();
       
      JPanel loadingPanel = new JPanel();
      loadingPanel.setLayout(new GridBagLayout()); // protip: non-constrained GBL to center stuff
     loadingPanel.setOpaque(false);
      loadingPanel.setSize(400, 400);
      // preferredSize needed for pack()
     loadingPanel.setPreferredSize(loadingPanel.getSize());
           
      JLabel loadingLabel = new JLabel("Testing");
      loadingPanel.add(loadingLabel);
     
      add(loadingPanel);
      // similar to setSize(loadingPanel.getSize());
     pack();
     
      // reliable way to center frame on screen, must be done after frame has been sized
     Dimension ss = Toolkit.getDefaultToolkit().getScreenSize();
      setLocation(ss.width/2 - getWidth()/2, ss.height/2-getHeight()/2);
   }
   
   public static void main(String[]a) {
      new RunFrame();
   }
}
8  Game Development / Newbie & Debugging Questions / Re: Subclass Questions on: 2014-09-01 03:47:19
What exactly is the problem? Does the loading panel not display? What happens if you remove the dispose()?
9  Game Development / Newbie & Debugging Questions / Re: Subclass Questions on: 2014-09-01 02:47:59
Always just put in code if you have it. I couldn't really tell what you meant.
10  Games Center / WIP games, tools & toy projects / Re: Project X [RPG] on: 2014-09-01 00:47:30
Precisely. I've been posting this often as of late, but here's some ideas on how to automate tile map joining in the manner than you describe: http://www.angryfishstudios.com/2011/04/adventures-in-bitmasking/
11  Java Game APIs & Engines / Engines, Libraries and Tools / Nightmod - Rapid development live-coding game specific IDE on: 2014-09-01 00:06:20
https://nightmod.net/

Ok, ok. So it's not Java, but it is libGDX (actually play-clj) and I figured some here might be interested. A bit late, but it looks promising for ludlum dare.

Some quick excerpts to pique your interest:
Quote
Nightmod is a tool for making live-moddable games. You can view a game's code while it's running and inject changes by simply hitting "Save".
Quote
Nightmod is a marriage between Nightcode, a Clojure IDE, and play-clj, a Clojure game library based on libGDX. Think of it as a Clojure game IDE.
Quote
When you run Nightmod, you'll see a list of game templates: Arcade, Platformer, Orthogonal RPG, Isometric RPG, Barebones 2D, or Barebones 3D. Each will start you off with a simple game that you can begin modifying. Check out the tutorial to learn the basics.

The cool thing about it is the combination of live-coding, premade templates, and the fact that there is quite little code. For instance, the 2D Physics demo is 113 lines in it's entirety.
Seems like it should be good for whipping up a game real fast in LD or another jam. Plus distribution is a cinch with libGDX being the back end.

For a taste, here's defining a Screen with an FPS counter label:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
(defscreen text-screen
  :on-show
  (fn [screen entities]
    (update! screen :camera (orthographic) :renderer (stage))
    (assoc (label "0" (color :white))
           :id :fps
           :x 5))

  :on-render
  (fn [screen entities]
    (->> (for [entity entities]
           (case (:id entity)
             :fps (doto entity (label! :set-text (str (game :fps))))
             entity))
         (render! screen)))

  :on-resize
  (fn [screen entities]
    (height! screen 300)))


You can see bits of the underlying libGDX in there, it's all quite interesting what has been done.
12  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac: Ive been practicing for 2 weeks and... on: 2014-08-31 23:22:23
5 years here and I consider myself decent. It's a skill that takes a long time to become good at.
You should keep looking through the newbie threads, because you can learn from their problems and our solutions.
13  Game Development / Newbie & Debugging Questions / Re: Noob questions: Bitwise operators in screen movement on: 2014-08-31 23:03:47
I'm guessing it's use for whatever that was for was that they wanted division by 16 (tile size perhaps?) but rounding towards negative infinity instead of zero.
Either that or it's superfluous.
14  Game Development / Newbie & Debugging Questions / Re: Noob questions: Bitwise operators in screen movement on: 2014-08-31 22:58:16
Your going to have to give an example of a use of bitwise operators to get an explanation.
15  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-31 21:32:20
Just restored my standing on Hackerrank in code golf, some chump thought he could beat my previous record (9.0) Tongue
https://www.hackerrank.com/challenges/leibniz/leaderboard/filter/language=java
16  Game Development / Newbie & Debugging Questions / Re: 2d Game design - render loop on: 2014-08-31 16:28:51
Concrete code examples would be easier to analyze.
However, the general rule is that if a variable is out of scope, then it is candidate for garbage collection. Note that it may not be collected as soon as it falls out of scope, but whenever the garbage collector deems fit.

Local variables fall out of scope as soon as the method returns:

1  
2  
3  
4  
5  
6  
7  
public void stuff() {
    // allocated (on the heap*) when stuff() is called, but after stuff() returns
   // it can be collected as it could no longer be referenced
   String s = "Hello World";

    System.out.println(s);
}


* Any non-primitive locals are allocated on the heap unless the JVM can perform escape analysis and determine that the variable could be validly allocated on the stack and thus "garbage collected" automatically when the method's stack frame is dropped. EA is fickle however and it's usually just safe to assume that any Object is heap allocated.

An instance field of a class is considered garbage when the instance it belongs to is considered garbage:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
class Thing {
    List<Object> things = new ArrayList<>();
}

public void stuff() {
    // allocates a Thing (and thus the ArrayList within) on the heap*
   Thing t = new Thing();

    // method returns; t (and thus it's field) is no longer referenced and can both be collected
}


The garbage collector is pretty smart, and you very rarely have to worry about it. That's the whole point of having it.
There are some corner cases where it's possible to create a legit memory leak in Java:
http://stackoverflow.com/questions/6470651/creating-a-memory-leak-with-java

However the real thing you should worry about if you're going to worry is either maintaining references to (esp. large) objects you no longer need, or creating far to many objects unnecessarily and putting stress on the garbage collector to try to keep up and collect fast enough to maintain enough available memory. The first could happen is you make every variable a static field or something dumb that you probably wouldn't do anyway, but the second is easy if you create lots of (esp. large, like BufferedImages or something) in a loop. See my project here where I the only real precaution I had to take was re-using BufferedImages via a pool. The code had massive problems with memory consumption and slowness due to the crushing amount of pressure on the GC before, but using the pool it now runs smoothly. The GC can easily handle even fairly large numbers of objects as long as they're small and short-lived (i.e. local variables).
17  Game Development / Newbie & Debugging Questions / Re: LWJGL 3D I want to create a 3d game on: 2014-08-31 16:01:12
I'd recommend starting out with something that is built on LWJGL, such as Slick2D or LibGDX, for starters. Once you're familiar with that, then move on to LWJGL.

Unless libGDX is doing it's job and being all that you need, why make life difficult by leaving it?
18  Game Development / Newbie & Debugging Questions / Re: 2d Game design - render loop on: 2014-08-31 15:47:46
You both could do well looking up the difference between the stack and heap and how they behave and play their roles in the execution of your programs. Always useful to know what's going on under the covers.

http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap
http://en.wikipedia.org/wiki/Java_Memory_Model

Also note the potentially confusing terminology: the stack is roughly a stack (the data structure), but the heap is not a heap (the data structure).
19  Game Development / Newbie & Debugging Questions / Re: Data structures for large arrays on: 2014-08-31 15:39:44
It's all possible and easy to experiment with if it's abstracted to a TerrainManager.getTileAt() or whatever.
Could even do something like a B-tree/hashed array tree if straight hashmap loss of locality is a problem.
20  Games Center / WIP games, tools & toy projects / Re: Project X [RPG] on: 2014-08-31 15:11:08
Many dozens of tile classes sounds like the perfect place to use a component model.
21  Game Development / Newbie & Debugging Questions / Re: Data structures for large arrays on: 2014-08-31 14:54:14
Instead of having a file per chunk, why not many (even all) chunks per file? This could be done easily in (at least) two ways:
Beginning of the file has an index table of byte offsets into the file where the data each chunk is stored, or you simply have chunks serialized in a way that they are all the same size.

I recommend the use of an actual StringBuilder for something like that, that's exactly the kind of use case for it.
Are those strings the way your data is represented in the file? I would recommend using a DataOutputStream or ByteBuffer + FileChannel and using a binary format.

As far as array flattening:

1  
2  
3  
4  
5  
6  
7  
public static final int index(int x, int y, int width) {
    return x + y * width;
}

// equivalent code
tiles[y][x] = ...;
tiles[index(x, y, MAP_WIDTH)] = ...;



However I agree with Cas, wait until you have a problem to try and fix it. I'd say try to build the system in such a way that your game code doesn't have to know how the tiles are stored/represented on disk/etc, so that it is back-end agnostic and thus you can swap in a faster optimized system later with no changes to the rest of your code.
22  Discussions / Miscellaneous Topics / Re: What other programming languages do you use & why? on: 2014-08-31 04:06:18
Waiting on Rust 1.0, the more I read the more I like it.

Occasionally some Clojure because of stuff like http://gorilla-repl.org/ and because I need some lisp mind-blowery in my day.

I'm also looking at Forth because it's just strange and very intriguing.
23  Discussions / Chitchat Monster / Re: [solved] Finally figured out how to add green -solved- to topic :D on: 2014-08-31 03:21:48
I'm willing to argue the monster is a collective entity.
As for it's keepers, you forget Jimmt, I believe can control it as well.

That said, I'm not sure who actually appreciates the circlejerk.
24  Discussions / Chitchat Monster / Re: [solved] Finally figured out how to add green -solved- to topic :D on: 2014-08-31 03:07:45
On this forum the chitchat monster will be the judge of that.
25  Discussions / Chitchat Monster / Re: [solved] Finally figured out how to add green -solved- to topic :D on: 2014-08-31 02:43:58
Enthusiasm is nice, however etiquette is required in using it.
26  Game Development / Newbie & Debugging Questions / Re: Toggling Swing Anti-Aliasing on the fly on: 2014-08-31 02:38:00
This thread left the tracks a while ago, but:

Most of this whole "UI Theme/Toolkit/etc" is pointless in the context of games anyway since you aren't making a word processor or an email client. Most of what the game is (at least should be) is not GUI components, unless of course it's some kind of "design a GUI" game...  persecutioncomplex
27  Game Development / Newbie & Debugging Questions / Re: Toggling Swing Anti-Aliasing on the fly on: 2014-08-31 02:21:53
The graphics context that renders the text is the same one that renders everything else.
Honestly JButton and most Swing components out-of-the-box aren't suitable for games. Usually just a JLabel/custom component with an image that has the text on it + any mouseover/pressed effects pre-rendered is best.
WebLAF is similar, not for games, but unbeatable (in the Swing arena, JavaFX does seem to be better) for apps though. Check the demo.
28  Game Development / Newbie & Debugging Questions / Re: Toggling Swing Anti-Aliasing on the fly on: 2014-08-31 02:15:57
What do you mean by "override"? The font? That's easy. Google it.
Also, if the theme isn't WebLAF it's not the sexiest. Jus' saying.
29  Game Development / Newbie & Debugging Questions / Re: Toggling Swing Anti-Aliasing on the fly on: 2014-08-31 02:06:32
OS themes have no effect on how your code displays.

By "draw them yourself" I meant create extensions of JComponent, then you can still use LayoutManagers and etc. with no "complications" or hard-coded layouts.

Putting your gameThread on the EDT doesn't sound like a good idea.
30  Game Development / Newbie & Debugging Questions / Re: Toggling Swing Anti-Aliasing on the fly on: 2014-08-31 02:03:11
The EDT is not the "main" thread.

Easy way to run something on the EDT is
SwingUtilities.invokeLater(new Runnable() {/* stuff */});


Pages: [1] 2 3 ... 41
 

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 (32 views)
2014-08-22 19:31:30

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

Tekkerue (40 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 (37 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!