Bullets as independent class or structure within parent class?

Started by
5 comments, last by DuncanBojangles 19 years, 12 months ago
Hey y''all, got kinda bored with my pogo stick game, since my computer''s so darn slow. Anyway, I wanted to make a little first person shooter just to play with my friends. I was wondering, is it better to implement bullets as a class or just a structure within the player''s class? Also, should I organize all the bullets of one player in the structure/class as an array, or a new structure/class for each bullet? Which way would be best implemented in a networked game? I just learned Unix and TCP/IP sockets, so I want to use them in something fun. Hopefully when I get my new computer I''ll enjoy working on my pogo stick game again, maybe even adding a unicycle! "Donkey, if it were me, you''d be dead." I cna ytpe 300 wrods pre mniute.
"Donkey, if it were me, you'd be dead."I cna ytpe 300 wrods pre mniute.
Advertisement
Hello, I myself am making a FPS well I''m more of making a 3d engine, that specializes in FPS. Not that it matters or you care.

Anyways, it’s really up to you. I personally would make it a structure within the player''s class. (Just because I like everything bunched up as much as I can. Again, it really doesn''t matter just what ever you are more comfortable with.

For your 2nd question:
Umm, I don''t think you would want to create a new class for each bullet. Especially if you have a machine gun that fires 10 rounds per second.

So, I would probably do it as a array.

I guess this would depend also on what kind of FPS you plan on making.

Hope this helps!
-BLades

BTW: You don''t play Wolfenstein Enemy Territory by any chance do you? Mr. Bojangles?

Sorry, no Wolfenstein for me, though I am trying to claim my nick from everyone.

I ask because I want to make a simple networked game that I can play with friends that would actually run on my extremely slow computer. I need to know how to pass information about players'' movements, status of the game, and bullets. I''m thinking that for the bullets, I would just send them the initial position and vector of the bullet, along with an individual bullet identifier and a player identifier, then let the other players'' computers do the rendering math. Basically, each player''s game is responsible for sending data about its player and bullets to the other players. Maybe I''ll set up a dedicated server for it, but for now I''ll leave it two player, just to be simple.

I''m not trying to make anything complicated. Maybe a particle engine, some lighting stuff, but for the most part it will be MD2 models and ColDet collision detection, with a little homemade BSP and model format thrown in for good measure.



"Donkey, if it were me, you''d be dead."
I cna ytpe 300 wrods pre mniute.
"Donkey, if it were me, you'd be dead."I cna ytpe 300 wrods pre mniute.
well, i wouldn''t treat a bullet either as a separate class or an array of some sort''s, unless you have really slow bullets.
Now if that where the case it might be good to treat them as a particle system.

But normal bullets(in fps games) actuarly use raytracing and travel from A to B instantly.

---------------------------------
For an overdose of l33tness, flashbang.nu
Well, that''s the way my engine is running.
And it seems to work better as a particle, that keeps on going until it hits another player or walls.(collision detection)

It seems to be doing fine.
Running at a steady FPS of 60.

-BLades
Personally, I''m against putting them in the player objects.
For non-instant bullets, I think it''s much better to have them as standalone entities.
For istant bullets, similar considerations applies.
Tracing back to bullet''s originator is not an easy task if haven''t got a parent pointer somewhere (this is not really a pointer, just like an ''ID'').

Previously "Krohm"

Thaks for all the tips. I think I''m going to go with the ray method, since I''m not really worried about the graphics or realistic-ness of the game.

"Donkey, if it were me, you''d be dead."
I cna ytpe 300 wrods pre mniute.
"Donkey, if it were me, you'd be dead."I cna ytpe 300 wrods pre mniute.

This topic is closed to new replies.

Advertisement