python - multiple bullets pygame space invaders -


I am quite new to Python and I'm trying to create a little space attacking game. My problem is that I do not have another shot on the screen. I would like to set fire to at least 3 in the original game. What would be the best way to do this?

Here is my code:

file name): self.x = xpos self.y = ypos self.bitmap = image.load (filename) self.bitmap.set_colorkey ((0,0,0)) def set_position (self, Xpos, Ypos): Selfkx = Xpos self = Ypos Def render (Self): Screen. Blit (Selfkbitmap, (Selfkx, Selfky)) Dianf differential (S L_aks, S 1_, 2_ S, S 2_a): if (S 1_x> S 2_ x - 30) and (s1_x & lt; S2_x + 30) and (s1_y & gt; s2_y - 30) and (s1_y & lt; s2_y + 30): return 1 and: return 0 init () screen = display.set_mode ((640,480)) key.set_repeat (1, 1) display.set_caption ('PyInvaders') backdrop = image.load ('data / backdrop.bmp') enemy = [] x = 0 count = 0 for count range (10): if calculation and lieutenant; 10: Enemy.Append (Sprite (50 * x + 50, 50, 'data / badi.bmp')) x + = 1 count + = 1 and: x = 0 enemy Append (Sprite (100 * x + 100, 50, 'data / Baddikbimpi')) x + = 1 hero = Sprite (20, 400, "data / Naikkbimpi ') Ourmissile = Sprite (0, 480, Data / heromissile.bmp ') Animimilil = Sprite (0, 480,' data / baddiemissile.bmp ') gameover = image.load (' data / gameover.bmp ') left = 0 anniispid = 4 timer = 0 while quit = = 0: Hiromd = Hero.aks + 16 Kbit screen (backdrop, (0, 0)) to count limit (LAN (enemy)): enemy [count] .x + = repetitive enemies [count] Kreder () If the enemy [lane (enemy) -1] X> 590: Anoispeed for counting in range (lane (enemy)) = -3: enemy [count] .i = = 5 if enemy [0] .x 0: enemymissile.x = Enemy [random.randint (0, Lane (enemy) - 1)]. X + 16 enemymissile.y = enemy [0] .If If the difference is (Naik.aks, Naik.a., Simisil.aks, Annimiisilky): Exit = 1 count in range (0, len (Enemy)): If infraction (ourmissile.x, ourmissile.y, enemy [calculation]. X, enemy [count].): Dell enemy [count] break if break (enemy) == 0: event.get () In ourevent for exit = 1: if ouvent.type == QUIT: quit = 1 if ourevent.type == KEYDOWN: if ourevent.key == K_RIGHT and Hero.x < 590: hero.x + = 5 if ourevent.key == K_LEFT and Hero. X & gt; 10: hero.x - = 5 if ourevent.key == K_SPACE: if timer & lt; 400: Timer = 0 ourmissile.x = herromid ourmissile.y = hero.immilcillal.reader () animationemi + = 5 hero.reader () display.update () time.delay (10) while leaving == 1: screen .blit (gameover, (0,0)) display.update () if ourevent.type == KEYDOWN: if ourevent.key == K_SPACE: quit == 0

Instead of having a missile, create a missile list. Therefore, instead of:

  if ourevent.key == K_SPACE: if the timer & lt; 400: Timer = 0 ourmissile.x = herromed ourmissile.y = hero.y   

Create a new missile and add it to the list:

  If the timer & Lt; 400: Timer = 0 missiles. Append (Sprite (Heromid, Hiro.a., data / Hemosiilkbimpi ')   

Add the loops to draw all the missiles and transferred: M missiles For

 : If my & lt; 640 and my & gt; 0: m.render () my + = -5    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -