Trash Cans!

Published June 08, 2008
Advertisement
In order to draw the sprites in order, so the ones in front would overlap the ones in back, I implemented a routine that would sort all of the game objects by order of their y position. This was done by putting the sprites into a binary search tree, and doing an in-order traversal to draw them with the correct overlap. I added a trash can object to test it, so here is the game running with 20 trash cans:


Here it is running with 2000 trash cans:


That seems to work fine, so I'm going to move on to getting grabbing and throwing working. Once I do that, I can get some enemies in to fight. I sense there might be a demo in the near future, one with fighting and trash can throwing.
0 likes 12 comments

Comments

MarijnStevens
Looks great! Is this game story based or action based :D. You got to have a good reason to punch everyone you see on the street right :)
June 09, 2008 08:53 AM
deathtrap
Quote:Original post by MarijnStevens
Looks great! Is this game story based or action based :D. You got to have a good reason to punch everyone you see on the street right :)


Umm, you need a reason for that? NOBODY TOLD ME!
June 09, 2008 09:02 AM
Stompy9999
Quote:Looks great! Is this game story based or action based :D. You got to have a good reason to punch everyone you see on the street right :)


I'm planning on having a "Choose your own Adventure" type of story. I'm basing the story on Way of the Samurai, a game where you're a ronin who wanders into town and can take sides in a fight between rival factions. Of course, you don't have to take sides, you could just beat the crap out of everybody. However, I'm planning that if you take a side and help out one of the various street gangs, they'll help you out when you get into fights.

But, I would agree with deathtrap in that I probably wouldn't need a reason to punch everyone on the street[grin]
June 09, 2008 09:17 AM
DecipherOne
What a waste [lol]


Seriously though, looking good. What does that many objects on the screen do to your frame rate? Also, I don't remember, are you using XNA?
June 09, 2008 03:43 PM
Todo
Awesome, and probably only getting better from here on :-). Cheers!
June 09, 2008 04:41 PM
Stompy9999
Quote:Seriously though, looking good. What does that many objects on the screen do to your frame rate? Also, I don't remember, are you using XNA?


I was suprised to find that the frame rate didn't drop even with 2000 objects, at least, I couldn't tell if it did. I guess that makes sense since the trash cans don't do anything aside from sitting there, but since a Binary Search Tree is created out of the objects each frame, I expected at least some slowdown.

I'm using XNA 2.0 to write this game.

Quote:Original post by Todo
Awesome, and probably only getting better from here on :-). Cheers!


Thanks!

June 09, 2008 06:23 PM
coderx75
Quote:Original post by Stompy9999
I guess that makes sense since the trash cans don't do anything aside from sitting there, but since a Binary Search Tree is created out of the objects each frame, I expected at least some slowdown.

2000 elements on a binary tree on today's hardware would even put a dent. Drawing 2000 objects to the screen should hardly slow you down either. You should throw together a quick fps counter or you could just do some quick profiling.

Looking forward to the demo. I wanna throw some trash cans at somebody! =D ...and no, I don't need a reason. ;-)
June 10, 2008 12:42 PM
Stompy9999
Quote:Original post by coderx75
Quote:Original post by Stompy9999
I guess that makes sense since the trash cans don't do anything aside from sitting there, but since a Binary Search Tree is created out of the objects each frame, I expected at least some slowdown.

2000 elements on a binary tree on today's hardware would even put a dent. Drawing 2000 objects to the screen should hardly slow you down either. You should throw together a quick fps counter or you could just do some quick profiling.

Looking forward to the demo. I wanna throw some trash cans at somebody! =D ...and no, I don't need a reason. ;-)


That's the reason why I used a binary tree, because my original plan was to put all of the elements in a collection and do a selection sort each frame, which probably would have been slower.
June 10, 2008 04:19 PM
Drilian
Hahahahahahahahaha


That 2000 trash can image made me laugh. Great work :)
June 14, 2008 04:25 AM
Stompy9999
Thanks!

My next task is to get 2000 enemies running on screen at once[grin]
June 15, 2008 08:44 PM
Rompa
Neat. Have you tried a PSX style ordering table instead of a binary tree?
Essentially you hash by depth into an array (simply quantize depth) and then perform a mini insertion sort. You could even have your binary trees at the hash entry level if you like. It'd probably save a heap of tree traversal...
June 16, 2008 04:53 PM
Stompy9999
I'll look into it. I figure that I want to have a good and efficient method for ordering the sprites, especially when I have alot of enemies on screen.
June 17, 2008 11:30 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement