Jump to content

  • Log In with Google      Sign In   
  • Create Account


Python/Pygame Bullet


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 K1NNY   Members   -  Reputation: 163

Like
0Likes
Like

Posted 08 September 2011 - 12:05 PM

How would i go about getting a "bullet" picture to "shoot" out of my characters gun when hitting spacebar? I think i need to make a class for it because it would be a sprite but i dont know how to go about it. please help.

Sponsor:

#2 HNikolas   Members   -  Reputation: 192

Like
1Likes
Like

Posted 08 September 2011 - 12:20 PM

You have not given a lot of information for this, but basically, you will create a class, yes.
When you get a spacebar event, you will instantiate the bullet class with all the relevand information, like the bullets cordinates(based on the character cordinates), moving direction, speed and so on.
You will have an array of these bullet objects and the game loop checks all the relevant things about them, like drawing cordinates, collision etc.

This is a very basic example and there are lots of ways where you can imrove it, but it will hopefully give you some ideas on implementing it.
In addition I would like to note that I have not done anything similar in Python or Pygame so there can very well be an easier way.
Ruby on Rails, ASP.NET MVC, jQuery and everything else web.. now also trying my hand on games.

#3 K1NNY   Members   -  Reputation: 163

Like
0Likes
Like

Posted 08 September 2011 - 04:17 PM

Thanks for the help. i typed this up in class real quick before i had to leave so i had to make it short.

Basically i need it to shoot from the players image and go in the direction the player is facing and come from his Rect. this will help quite a bit thank you.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS