Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (602)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
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: [Question] Organizing Code on: 2013-02-27 01:28:48
Thanks for the insight. It's pretty useful to see how other people setup their code.
2  Game Development / Newbie & Debugging Questions / Re: [Question] Organizing Code on: 2013-02-26 16:18:18
Tip: dont create complexity for the sake of it. (An unnecessarily complex Class-Hierarchy / including
huge Logging libraries if you just need a "Log" class that can print lines to a textfile)

Else you create lots of boilerplate code, and loos oversight of the important parts of the program.

As for how I've set up the AssetLoader and the SoundManager, this isn't over complicating it, is it?
3  Game Development / Newbie & Debugging Questions / Re: [Question] Organizing Code on: 2013-02-26 16:03:37
If you have multiple screens, like game start, options, the running game itself, etc., you better also have dedicated screen handlers instead of one almighty UserInterface.
For debugging, you might as well use an existing logging library.

I didn't even think to check for a logging library. Thank you, for the information.
4  Game Development / Newbie & Debugging Questions / [Solved] Organizing Code on: 2013-02-26 07:55:08
I am currently working on a simple game, using Slick2D, as a means of practice and I was wondering if someone can give me some advice on how I've set up my code. This is how I have it thus far:

AssetLoader - This basically loads the sounds and sprites. It also has a set of getters for these assets.
SoundManager - This basically handles all the sound playing and music playing.
UserInterface - This handles all the userinterface nonsense.
Debug - This is a simple class of booleans with getters & setters that are used to check for when certain debug functions are enabled.

Now, in the GameState class, the SoundManager object is created and is updated in the update method. The SoundManager gets it's sounds from the AssetManager and handles when a sound is playing. The UserInterface object is also created and has a render and update method. The UserInterface gets all of it's Images from the AssetManager; it also checks the Debug if any of the options are enabled so it can draw them.

Now I have a debug option for displaying the current track. The UserInterface will check the Debug to see if this is turned on. If it is, it will then check the SoundManager for what song is playing and display it.

So, does this make sense? Am I going about it all wrong? Should I break it down more? Any advice will be appreciated! Smiley

5  Game Development / Newbie & Debugging Questions / Re: [Solved] Array returning null. on: 2013-01-25 11:16:27
Do the following:

for (int i = 0; i < chunks.length; i++) {
         for (int j = 0; j < chunks[i].length; j++) {
            if (Math.random() > 0.5) {
               chunks[i][j] = new Chunk(true);
            } else {
               chunks[i][j] = new Chunk(false);

I am so stupid. Thank you for pointing that out!
6  Game Development / Newbie & Debugging Questions / [Solved] Array returning null. on: 2013-01-25 10:23:17
I have a simple enum called Tile that merely keeps track of the images an individual tile uses. I then have a Chunk class that contains a Tile array which stores individual tiles. The Chunk makes a call to a ChunkBuilder class which generates a Tile array in an island formation. Next, I have a World class which has a Chunk array so that I can render the chunks and create the world. To test and make sure this all worked I added a Chunk array requirement to the constructor for the world class; I then created a simple for-loop in my GameState class to create a Chunk array which is then supplied to the World object. Now, this all works perfectly fine and everything renders well.

Now, to the problem; I have created a WorldBuilder class with the task of generating a Chunk array to make the Chunks much more random and allow water Chunks to space out the islands for a much nicer look. This is just a quick example of how it looks:
public WorldBuilder() {
      chunks = new Chunk[8][8];

   public Chunk[][] generateWorld() {

      for (int i = 0; i > chunks.length; i++) {
         for (int j = 0; j > chunks[0].length; j++) {
            if (Math.random() > 0.5) {
               chunks[j][i] = new Chunk(true);
            } else {
               chunks[j][i] = new Chunk(false);
      return chunks;

My World constructor then looks something like this:
public World() {
      chunks = new WorldBuilder().generateWorld();

When I run my game, it crashes with a null pointer exception. So, I decided to write a simple for-loop to go through the World object and print out in the console what exactly is stored in the World's Chunk array. When I run my game null is printed to the console for each index.

Would anyone happen to have any ideas as to why? Thanks!
7  Game Development / Newbie & Debugging Questions / Re: [Solved] Rendering Tiles from an Array of Chunks on: 2013-01-17 00:15:45
Ah, okay, I'll just make that change. Thanks!
8  Game Development / Newbie & Debugging Questions / Re: [Question] Rendering Tiles from an Array of Chunks on: 2013-01-16 06:54:38
Ask more questions if that does not help or if I misunderstood the question.


Thanks, worked out well. Now it's just a matter of me only rendering the chunks within view, but I'm sure I'll figure that out. Thanks again!
9  Game Development / Newbie & Debugging Questions / Re: [Question] Rendering Tiles from an Array of Chunks on: 2013-01-10 00:11:01
Thanks for the reply! I'm going to try what you said and I'll post my results.
10  Game Development / Newbie & Debugging Questions / [Solved] Rendering Tiles from an Array of Chunks on: 2013-01-08 02:06:12
I have a project I'm working on using Slick2D. Now, I have a enum for my Tiles, nothing too fancy, it simply has what image the tiles should use and the scale. I then have another class to generate chunks. This class will store the data in a 2D Tile array which I had no problem rendering and moving about. Now to the tricky part, I have a world class that I am using to store entities in an ArrayList and then a 2D Chunk array. Now, in my game state I initialize the world and fill it with chunks, my question is how would I go about rendering the tiles?

When rendering a chunk by itself without the world, I have a getTileImage method that grabs the tile image based on the pixel on the screen, my problem is now I have to figure out what chunk the pixel is in and then also figure out the tile within that chunk. I'm not exactly sure if this is the best way to go about this so if you have a recommendation I will gladly listen. Also, if you need any of my code let me know, I am still relatively new to Java so it might not be pretty.

Pages: [1]
Jesse (14 views)
2015-07-29 04:35:27

Riven (36 views)
2015-07-27 16:38:00

Riven (18 views)
2015-07-27 15:35:20

Riven (21 views)
2015-07-27 12:26:13

Riven (12 views)
2015-07-27 12:23:39

BurntPizza (30 views)
2015-07-25 00:14:37

BurntPizza (41 views)
2015-07-24 22:06:39

BurntPizza (24 views)
2015-07-24 06:06:53

NoxInc (29 views)
2015-07-22 22:16:53

NoxInc (18 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!