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 Instead of having a missile, create a missile list. Therefore, instead of: Create a new missile and add it to the list: Add the loops to draw all the missiles and transferred: M missiles For
if ourevent.key == K_SPACE: if the timer & lt; 400: Timer = 0 ourmissile.x = herromed ourmissile.y = hero.y
If the timer & Lt; 400: Timer = 0 missiles. Append (Sprite (Heromid, Hiro.a., data / Hemosiilkbimpi ')
: If my & lt; 640 and my & gt; 0: m.render () my + = -5
Comments
Post a Comment