|
This should be a very common problem. |
keprast
Member #16,794
January 2018
|
Hello. If I shot 100 bullets,at a time. But you know, I have only a piece of code. How do I do it? My problem is: Array? It can only be like while. |
raynebc
Member #11,908
May 2010
|
Pick up a basic programming book. You'll learn about methods to repeat code dynamically (ie. loops). |
Ariesnl
Member #2,902
November 2002
|
Do yourself a favor, enroll to harvard's CS50 (it's free), than come back Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
keprast
Member #16,794
January 2018
|
100 objects use the same code at one time. I don't think time difference can make logical synchronization. |
Ariesnl
Member #2,902
November 2002
|
1 you stuff the bullets into a datastructure ( array, list, vector, whatever) or .. you want to use a single thread for every bullet ? wtf Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
keprast
Member #16,794
January 2018
|
@Ariesnl I didn't know where the problem was before.:-[Up to now. The problem is always so one by one. |
Chris Katko
Member #1,881
January 2002
|
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. -----sig: |
beoran
Member #12,636
March 2011
|
First, a free book to lean C with: http://publications.gbdirect.co.uk/c_book/ 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. |
|