Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
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

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
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:
1  
2  
3  
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.

Chris

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.

Thanks!
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.

TehJavaDev (32 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (58 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!