Jump to content

  • Log In with Google      Sign In   
  • Create Account

Naked Shooter

Member Since 05 Sep 2007
Offline Last Active Oct 23 2012 09:50 PM

Posts I've Made

In Topic: Need to obtain frustum corners coordinates

22 October 2012 - 04:46 AM

Yes, that works! I knew it had something to do with w.. Thank you Ohforf!!

In Topic: Problem initializing object

16 September 2012 - 02:53 AM

When you call memset(ret,0,sizeof(WindowsOS)); you might be trashing the vtable. If initialize is not a virtual function, then ret->initialize() doesn't need the vtable to be called, so it doesn't crash. I am curious as to why you used memset to clear that object.

The memset was basically there for no reason, I thought it might help but it didn't..

The solution was to use a 'placement new' like this:

WindowsOS* ret = (WindowsOS*)subsystemStack.allocateAligned(sizeof(WindowsOS), __alignof(WindowsOS));
ret = new (ret) WindowsOS;

This way, we can properly construct an object wile using a pre-allocated chunk of memory to store it.

In Topic: Can't have function prototype with 4 __m128 parameters?

22 July 2012 - 04:39 PM

Thanks phantom!

In Topic: is learning c++ as first and only language a bad way to go?

14 February 2012 - 02:09 PM

I would agree that C++ is a more treacherous language than modern languages like C#, but don't let that discourage you from trying. You can do a lot of things in C++ that C# would try to limit, which is why it's dangerous.

Also, once you have an understanding of C++, you can easily switch to Java or C#. You'll have to learn some new concepts maybe, but you'll have a pretty good idea how everything works on the low level. I started with C, then went on to C++, and then Java. My first game was in C++, and I can say that going from C++ to C# (which I've never touched before this semester) was a breeze.

In Topic: Quadtrees for Tower Defense - Target Acquisition

14 February 2012 - 12:41 PM

I'm working on a 2D game on the same vein as Tower Defense games but with a large world, seemless world.

The player(s) will have to react to attacks from different areas of the world and sometimes defend multiple fronts at once.

The problem I have is the idea of hundreds (potentially thousands) of "towers" trying to acquire targets. Also to avoid unnecessary checks when there are no targets within the maximum range. Line-of-Sight is NOT an issue, only whether the target fits within it's range. (some shoot directly forward, some can aim in a cone, etc)

I have been told that Quadtrees might allow me to optimize this system of target acquisition.

Is this true? Are there any articles I should read? Any pitfalls or alternatives?

Additionally, to prevent unnecessary checks, I had the idea that when a hostile unit enters the world, it "activates" all the defenses within a certain radius. And when there are no enemy units around, the defenses shut-down and go into a kind of "sleep" mode. Any thoughts on this?

You can combine both of your above ideas. In a quad tree, you'd often implement a function that takes a volume (usually a rectangle, but you could concievably have a circle or some swept shape), and returns all of the objects that are around that volume by returning the contents of all the nodes with which the circle intersects. So, an enemy can have its own volume (probably a circle with some detection radius), and it might query the tree with that circle to get the list of nearby towers. Then, you can tell those towers to do their thing (is the enemy within range? can we shoot it?...). This would probably give you the efficiency you need.

If you have a dynamic, node-based implementation of the tree, the recursive query function is very simple.

Check this out: http://www.kyleschou...ource-included/