Jump to content

  • Log In with Google      Sign In   
  • Create Account

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.

A lil' help with my Pacman AI?

10 August 2010 - 05:04 AM

Hey guys, I've been working on a little pacman game (turning out quite nicely!) but I'm a bit stumped on the Ghost's AI at the minute, I'll post what I currently have and maybe one of the resident gurus could perhaps help me make it a bit more robust:


public void decideDirection()
{
if (pacmanPosition.X < position.X &&
!currMap.checkEnemyWallCollision(LEFT, position))
{
currentDir = LEFT;
return;
}
if (pacmanPosition.X > position.X &&
!currMap.checkEnemyWallCollision(RIGHT, position))
{
currentDir = RIGHT;
return;
}
if (pacmanPosition.Y > position.Y &&
!currMap.checkEnemyWallCollision(DOWN, position))
{
currentDir = DOWN;
return;

}
if (pacmanPosition.Y < position.Y &&
!currMap.checkEnemyWallCollision(UP, position))
{
currentDir = UP;
return;
}

}



checkEnemyWallCollision takes a direction integer and a Rectangle position and returns true if there's a collision.

This little function works fine mostly.. but it fails when the ghost and pacman have equal x positions, but there's something blocking the y direction or vice versa.. I can't for the life of me think of an easy fix/better way of doing this!

Thanks for reading,

Ollie.

FPS collision detection in a 3D town

13 July 2010 - 12:02 PM

Hey guys,

I'll begin by explaining my intentions. I'm going to model a little 3D town that the user can navigate using an FPS style camera. the model will be exported in .x format.

My only experience with collision detection so far has been a little bit of AABB, and I don't think that this'll be sufficient for a "town" full of houses that have both interiors and exteriors that I'd like the camera to collide with.

Soooo basically what I'm asking is: What's the best approach to writing collision detection for a lot of intricate meshes?

My API is DX9 and my language is C++.

Another note (not directly related to DirectX I know, but still pertinent.) should I be programming each house in a seperate .X file and then putting it all together in code, or is it perfectly normal to model the ground plane and the houses all in one big .x file?

Thanks in advance for any help.

Ollie.

PARTNERS