Jump to content
  • Advertisement
ritzmax72

DX12 How to efficiently implemented ball shooting?

Recommended Posts

So I have been trying to implement a ball shooting character in directx 12. I am having trouble figuring out how many balls should I generate when player wants to shoot and how do I manage those balls? 

Should each ball have separate world matrix? 

How do I reuse balls that have hit the target enemy or went past the viewing dimension? 

Here are ingredients I need to manage. 

1) Vertex and Index buffer entry for a geometry named “Ball”. This can be same for all balls. Need not be repeated.

2) Constant buffer entry for storing world matrix of “a” ball. For multiple ball I will have to have separate constant buffer entry.  

3) Since I am simulating physics for each item that can be rendered, I will have to have a separate physics object entry for physics engine.

For #2 Do I have to pre allocate a pre-defined maximum number of constant buffer for all balls ? Like say I can only render 20 balls on screen at max. This is possible if none of the ball hit any enemy and none of them went past the viewing screen? For other situation I can assume every balls not on screen can be reused again when player hit shooting key again. 

Is there a standard game design pattern for ball shooting? Am I looking at right direction for my attempt at designing myself? Any optimisation?

Does cuphead implemented proven pattern ?? Picture attached.

 

BFAFD6B0-DD74-44CB-9093-A8D08E08CD5A.jpeg

Share this post


Link to post
Share on other sites
Advertisement

I would give all their own constant buffers. You create bullets as needed and when you are done with an object you return it to an object pool. The next time you create a bullet you check in the object pool if there are any unused bullets. If so, you use it, if not you create a new one. Each bullet will have its own transformation matrix associated with the constant buffer. The bullets can share the same index and vertex buffers.

Share this post


Link to post
Share on other sites

Since there's a DirectX Tool Kit for DX12, too, just use its SpriteBatch (batching is usually the answer here). It covers the administrative part and you can mostly "fire and forget" by using handy functions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!