Game Development Community

dev|Pro Game Development Curriculum

Plan for justin` dujardin

by Justin DuJardin · 04/25/2005 (9:45 am) · 9 comments

Well, it's been a while since my last PLAN posting and to be honest I've been quite busy with Midterms and upcoming Finals that need to be dealt with, so I've had very little time to work on my side projects. However, I did find some time this weekend to work on my T2D project which is my hobbyist attempt at creating a T2D scorched earth clone.

Issues

In creating deformable terrain for this game I had a few obstacles to overcome.

First there is the issue of detecting collisions on terrain images which are surrounded by quad collision polygons.

Initially I attempted to create custom collision poly's for the terrain but because of it's form, it needed a concave polygon to correctly detect collisions on the curves of the terrain. This was not possible because T2D only currently supports collision polygons that are convex.

So from there I had to rethink the collision code, so what I ended up doing was hijacking the collision code and generating a Y axis point line that listed where on the image the terrain began. In the end this worked out rather well because I can simply check the y axis point value against the listed point for the current x position in my point array. So collision becomes a simple

Point2F testHit = mLinePoints[ (U32)lookup ]; 
    if ( contact.mY  > testHit.y )

However, with this there was a problem. Since the terrain image is stretched to fit the screen, it's collision quad callback was being called for every point, the entire time the projectile was in the air. This would not have been a terribly large problem had it not been for the fact that it invoked a script callback each time, which can be a bit processor intensive.

So at this point I had to go into scene object and hijack the collision script callbacks a bit, by adding a mScriptCollisionSupress and checking for that. When a terrain object is loaded, it suppresses all script callbacks on it's object. Then I simply updated my collision code to reflect this and handle the script callbacks on it's own.

Point2F testHit = mLinePoints[ (U32)lookup ];
    
    if ( contact.mY  > ( testHit.y ) && getCollisionCallback() )
      onScriptCollision( pCollisionStatus );

Now our collision callbacks only occur when our terrain is hit, success!

Deforming the terrain

After all the hassle of figuring out when we've collided with the terrain it was now time to make the necessary deformations to the terrain and then recalculate our collision points and we should be good to go!

Of course, what fun would it be if there were no snags. Unfortunately my dgl experience is a bit limited, and the only way I could find of brushing one texture ontop of another and then saving that texture for rendering was to use a pBuffer. It appears that T2D does not support pBuffers so I had to get tricky.

I have a brush image that I use which is simple a circle of alpha 0 so I needed to take it and apply it to the terrain, so I had to do some nasty GBitmap pixel by pixel computations, which is given to be a bit slow but hey let's take a look at what results!

www.team5150.com/~av0n/terraindeformer.jpg
After all this hairpulling and cursing it appears that my terrain deformation now works just fine and I feel no worse off than I did when I started it!

Now that I have this done, perhaps I'll get a demo game completed in the next few weeks, provided I have time between finals and getting ready to leave for GG on the 25th of may, who knows?

Hope you enjoyed seeing this as much as I did writing it, happy T2D hacking!

#1
04/25/2005 (10:06 am)
Wow nice work. What's GG on 25th of May btw??
#2
04/25/2005 (12:15 pm)
Thanks Randy,
I'm going to be interning at GG this summer, and I leave for GG on the 25th of may :)
#3
04/25/2005 (12:42 pm)
I emailed you a few weeks ago about this project and haven't heard back. Please email me at joshuadallman@mailblocks.com if you didn't get the email. Thanks!
#4
04/25/2005 (5:10 pm)
Ah yea I was like uh some kinda of convention for a second. GRATS!
Yea I saw Joshw mention the good news.
#5
04/25/2005 (8:00 pm)
Great work justin! Have fun at GG and I hope you get a demo out before then lol ;)
#6
04/25/2005 (11:25 pm)
Good stuff.

Good Luck with the GG interning; looks like you'll do well. :)

- Melv.
#7
01/11/2006 (8:12 pm)
Was this demo ever released? I couldn't find it. It looks really nice, even close to a year and a few T2D releases later.
#8
02/01/2006 (5:24 pm)
Dave,

Sorry mate, I never did get around to releasing this as I've been so busy with work over here. I'll try my best to get some time in the next year to get this out for everyone to mess with, keeping in mind it's not that great a hack :)

-J
#9
04/23/2009 (3:56 pm)
This might be a bit late but do you still have the source so I can use it as a reference?