Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

lolliver0342

Member Since 17 Dec 2008
Offline Last Active Dec 02 2011 09:45 AM
-----

Topics I've Started

global config file access for a game?

06 October 2011 - 06:20 AM

Afternoon!

I've been writing a first person platformer recently using LWJGL (OpenGL) and Java, and I've hit a slight snag.

My current approach to all configurable game aspects is to have a static class with a load of variables inside, which can be accessed anywhere in the game using this syntax "constants.MAP_DEPTH" (or whatever).

This is fine, as it can be accessed globally with no speed loss or the jiggery pokery of having to pass a "config" object around all the time. But I've recently come to the conclusion that it'd be nice to have all of the configuration in an external file to promote modding/make life easier when I'm making small changes to the game (rather than recompiling>running constantly..)

How are config files usually approached in game development?

I considered having a static class with a static method which can read the config file and return the contents, but this would mean lots and lots of file reading in the game loop and it's just not really appropriate.

I'm sorry if this is a simple question, but I'm up to about 17 classes now and I'm a wee bit stumped!

Hope you can help.
Ollie.

P.S let me know if I've not worded something too well and I'll try and elaborate somewhat!

Rotate object to "follow" another object?

28 April 2011 - 04:50 PM

Hey guys,

I'm still working on my tower defense game at the minute, and I've hit another brick wall.

For testing I'd like to find a way of making the towers rotate around their origin on the Y axis to follow an enemy if it's within range of them.

So for example if an enemy is walking down the path towards them I'd like them to rotate slowly to ensure that they're always facing in the right direction.
if(e.getWorldPos().getX() < (-t.getPosition().getX()) + t.getRadius() && e.getWorldPos().getX() > (-t.getPosition().getX()) - t.getRadius())
            	{
                    	double xRot = Math.sin(t.getPosition().getX() - e.getWorldPos().getX());
                    	System.out.println(xRot);
                    	t.setCurrentRot((float)xRot);
            	}

Obviously I'll do the same for the Y axis checking as well, but am I anywhere near the right track for this? I have no idea if Sin's the correct mathematical function to use here, sorry.

Any assistance will be helpful here.

BTW: e is the very first enemy in the wave and t is a tower.

Cheers,

Ollie.

Pathfinding in a tower defense game.

14 April 2011 - 07:23 AM

Hey guys,

I've been making a 3D tower defense game with OpenGL and LWJGL (Java) and I'm at the point where I'd like to start thinking about enemies etc.

Now, I've been following this tutorial so far to learn A* pathfinding, and I'm understanding the theory well. However I'm now at a stage where I need to somehow get my 2D integer array of tile types into a load nodes with connected neighbouring nodes and I have no idea at all how to progress.

So GD.net gurus, any ideas on how I should progress?

For those that are interested, the game is currently at this stage: Lolliver Defense
Cheers!

Ollie.

PARTNERS