How To Add Five Rows Of Invaders In Space Invader Game
i currently have 1 row of 11 invaders in my space invader game and wish to add 5 more rows, what code would i need to add on to my current code below? import sys import pygame impo
Solution 1:
From what it seems, you would just need to make a nested loop
for b in range(5):
XPos =#insert original starting valuefor i in range(11):
invader = Invader.Invader()
invader.setPosX(xPos)
invader.setPosY(20 * b) #adjust y values to your preference
self.invaders.append(invader)
xPos += 32
This will create five rows of 11. Make sure you change the values to your preference and set the starting x Position where i commented.
Post a Comment for "How To Add Five Rows Of Invaders In Space Invader Game"