Player shooting

Started by
0 comments, last by dashurc 16 years, 2 months ago
Hey guys, Just a simple question, I've added the ability to shoot in my game, but I just slapped it in lazily inside the PlayState class, rather then the player class, when the left mouse button was held down. Just curious if I should be doing this work inside the Attack() method of the player class, or if the Rayqueries should be done else where (perhaps inside their own class). Just looking for some ideas ^.^ Thanks.
Dexter BrockDead Cold - http://deadcold.smallchangestudios.net
Advertisement
When the shoot button is pressed call the Attack method for the player tied to that input device. This could have the current weapon generate the bullet, and when the bullet is created it can set up it's own trajectory, or the weapon could define its trajectory for it. The bullet itself could do collision tests on other players and the environment when it updates.

That's what I tend to do anyways. You may also want to have some bullet manager class that you can ask to create bullets for you (i.e. you could provide an initial position and velocity) and then when the bullet manager updates it can update all the bullets in play.

This topic is closed to new replies.

Advertisement