python 3.x - Pygame Shooting Bullets -


recently ive been trying create small game using pygame, ive managed display image can move side side, trouble ive been having enabling fire bullets using space bar.

heres code far: http://pastebin.com/24xdywy7

ive got bullet display doesnt come out "turret.png", , sits in top left of screen.

is able me this? extremely new python , appreciate help

it looks you're using technique employing in pygame - using different sprite groups separating guys, bad guys, bullets, blocks, etc… single unified 'all things' group.

what don't see all_sprites.update() call makes whole thing work, though see player.update(). pygame groups designed let call group.update() in place of for x in y call such as:

for sprite in my_sprites:     sprite.update() 

edit: not seeing images in right place? if they're being set upper-left corner, because nothing setting surface of drawn image appear want to.

one thing i've found handy pygame's get_rect() call allows pass arguments set attributes of rect back. example, sprite.draw(self) methods tend this:

def draw(self):     """sets image's rect middle of sprite,      blits screen.     """     draw_rect = self.drawn_image.get_rect(center=self.rect.center)     screen.blit(self.drawn_image, draw_rect) 

this assumes sprite object's self.x , self.y being updated correctly well, it's right thing do; rect object you're drawing, set right coordinates actual sprite, pass image , rect screen.blit().


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -