This should be a very common problem.


If I shot 100 bullets,at a time.

But you know, I have only a piece of code.
I can't write 100 code.Let 100 bullets go to use:-/.

How do I do it?
:)Can you help me?
Maybe I can't describe it correctly. I'm sorry.

My problem is:
There are 100 people, shooting at the instantaneous.
Each bullet is an independent data.

Array? It can only be like while.
It is impossible to do parallel computing


Pick up a basic programming book. You'll learn about methods to repeat code dynamically (ie. loops).


Do yourself a favor, enroll to harvard's CS50 (it's free), than come back ;)


100 objects use the same code at one time.
This inevitably leads to data confusion.
It's not a simple while.

I don't think time difference can make logical synchronization.
This is a thread problem.


1 you stuff the bullets into a datastructure ( array, list, vector, whatever)
2 you MOVE every bullet one frame/gameloop..
3 you check for collisions
4 goto 2 until your bullets go out of range

or .. you want to use a single thread for every bullet ? wtf ???


Thank you. It's a good way to do it.

I didn't know where the problem was before.:-[Up to now.
I found the key.It is: how to use "frame" decision.timer?

The problem is always so one by one.
For students, teachers are always changing.

Chris Katko

I already told you in the collision detection thread you posted. ???

I agree with the others, you should definitely pick up some basic programming books or lectures on YouTube / Harvard. If you don't know the fundamentals, you're going to have trouble learning every other part of game programming.

At least spend a couple days learning how to use data structures, arrays, and functions before trying any more game programming.

I'm normally eager to help anyone with a question, but you've got to do your part of the work too and meet us half-way.


First, a free book to lean C with:

Then, to answer your question. In programming we normally don't need to have a separate thread of execution per (game) object. The CPU is fast enough to handle updates to thousands of objects in a few milliseconds. So we can do everything in a single thread. The bullets are kept together in a single (dynamic) array, and then we go over them with a loop to update them. This we do in-between drawing the graphics of the game.

Thread #617236. Printed from