Unit Spawning (RTS)

Started by
3 comments, last by LeeWalker 13 years, 2 months ago
Hi guys,

I'm currently working on an RTS game using DarkGDK (C++) and was wondering how I would create individual objects for units.

I've made a reference object and cloned it, but I don't think that's the best way to do it. Along with that, I'm not entirely sure how I would go about creating a new object per click of the mouse.

I have currently got the following:

if ( mouseclicked )
{
MouseY = dbGetTerrainGroundHeight( 1, dbMouseX(), dbMouseY() ) + 10; // Gets the Y co-ordinate which is just above ground height

dbCloneObject( unit, 10 ); // Clone the reference object and create another one with id of "unit" which is 100 to start

dbPositionObject( unit, dbMouseX(), MouseY, dbMouseY() ); // This is currently spawning it at the 2D co-ordinates of the mouse, I'm sure I'll be able to sort that though

unit++;

}
Follow me on twitter! @lwalkeruk
Watch me on youtube! LeeWalkerGM
Advertisement
Cloning seems just fine.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Ok, that's awesome. So the error lies within my loop?

What happens at the moment is the same Object just moves wherever the mouse is.


Follow me on twitter! @lwalkeruk
Watch me on youtube! LeeWalkerGM
Moved to General Programming. Please be careful about which forum you post in, and take a moment to ensure you're categorizing your topics correctly. Thanks and welcome to GDNet!

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Cheers, sorry about that.
Follow me on twitter! @lwalkeruk
Watch me on youtube! LeeWalkerGM

This topic is closed to new replies.

Advertisement