python 2.7 - Movement Of Multiple Images in Pygame -


i'm trying build small game using pygame user move helicopter , down , press space bar shoot bullets. have bullet image installed program , set starting x , y using pygame.key.get_pressed, i'm trying make multiple bullets can shot across screen @ same time. here's 2 parts of code deal bullets have made, have capacity 1 bullet , when press space again, bullet reappears , restarts it's motion.

pygame.key.get_pressed ... if keys[pygame.k_space]:     bullet = pygame.image.load("images/bullet.png")     bulletx = helicopterx     bullety = helicoptery + 15     bulletshoot = true ... if bulletshoot == true:     bulletx += 5     surf.blit(bullet, (bulletx, bullety))     if bulletx >= 800: #800 width of screen         bulletshoot = false 

rather storing each bullet attribute in separate variable, need create list of bullet objects. when bullet's x coordinate goes above 800, remove bullet list.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -