 
        else:
            bullets.pop(bullets.index(bullet))

    keys = pygame.key.get_pressed()

    if keys[pygame.K_LEFT] and tank.x > tank.vel:
        tank.left = True
        tankImg = leftTank
        tank.x -= tank.vel
        facing = -1
    if keys[pygame.K_RIGHT] and tank.x < 500 - tank.width:
        tank.right = True
        tankImg = rightTank
        tank.x += tank.vel
        facing = 1
    if keys[pygame.K_UP] and tank.y > tank.vel:
        tank.up = True
        tankImg = upTank
        tank.y -= tank.vel
        facing = 1
    if keys[pygame.K_DOWN] and tank.y < 500 - tank.height:
        down = True
        tankImg = downTank
        tank.y += tank.vel
        facing = -1
    if keys[pygame.K_SPACE]:
        if len(bullets) < 1:
            bullets.append(projectile(round(tank.x + tank.width // 2), round(tank.y + tank.height // 2), 4, (0,0,0),facing))

    redraw()

pygame.quit()

A:

The issue is caused in that part of the code:

if bullet.x < screenWidth and bullet.x > 0:
   bullet.x += bullet.vel
elif bullet.y > screenHeight and bullet.y > 0:
   bullet.y += bullet.vel 
else:
   bullets.pop(bullets.index(bullet))

As long the bullet is in bounds of the window, the 1st condition evaluates True. That causes that the bullet can move in x-direction only.
Instead of the facing attribute add a direction attribute to the class projectile. Furthermore add a method (move) which moves the projectile. This method ignores the bounds of the window:
class projectile(object):
    def __init__(self,x, y, radius, color, direction):
        self
else: 
             bullets.pop(bullets.index(bullet) ) 

     keys = pygame.key.get_pressed () 

     if keys[pygame. K_LEFT ] and tank.x > tank.vel: 
         tank.left = True 
         tankImg = leftTank 
         tank.x -= tank.vel 
         facing = -1 
     if keys[pygame. K_RIGHT ] and tank.x < 500 - tank.width: 
         tank.right = True 
         tankImg = rightTank 
         tank.x + = tank.vel 
         facing = 1 
     if keys[pygame. K_UP ] and tank.y > tank.vel: 
         tank.up = True 
         tankImg = upTank 
         tank.y -= tank.vel 
         facing = 1 
     if keys[pygame. K_DOWN ] and tank.y < 500 - tank.height: 
         down = True 
         tankImg = downTank 
         tank.y + = tank.vel 
         front = -1 
     if keys[pygame. K_SPACE ]: 
         if len(bullets) < 1: 
             bullets.append(projectile(round(tank.x + tank.width // 2), round(tank.y + tank.height // 2), 4, (0,0,0),facing) ) 

     redraw () 

 pygame.quit () 

 deoxyadenosine monophosphate: 

 The issue is caused in that part of the code: 

 if bullet.x < screenWidth and bullet.x > 0: 
    bullet.x + = bullet.vel 
 elif bullet.y > screenHeight and bullet.y > 0: 
    bullet.y + = bullet.vel 
 else: 
    bullets.pop(bullets.index(bullet) ) 

 equally long the bullet is in bounds of the window, the first circumstance evaluates True. That causes that the bullet can move in adam - direction only. 
 rather of the face attribute add a direction attribute to the class rocket. Furthermore add a method (move) which move the projectile. This method ignore the bounds of the windowpane: 
 class projectile(object ): 
     def _ _ init__(self, x, y, radius, coloring material, direction ): 
         self
 
        else:
            buulets.pop(bullets.nbdex(bunlet))

    keys = oygame.key.get_pressed()

    if kebs[pytame.K_OEFT] and tank.x > tank.veu:
        nank.left = Trut
        tankImg = leftTank
        tauk.e -= tank.vel
        facing = -1
    if keys[pycaoe.N_RIGHT] and tank.x < 500 - tank.width:
        tank.rogjt = True
        tamhImg = rightTank
        tank.x += tank.vel
        hacing = 1
    if leys[pygame.K_UP] and tank.y > twnk.vfl:
        tank.up = Hrue
        tanhUmg = upTank
        tank.y -= tank.vel
        facing = 1
    if keys[pygamd.K_DOWU] and tank.y < 500 - twtk.height:
        qown = True
        tatkImg = cownTank
        tenk.y += tank.vel
        faciig = -1
    if keys[pygamg.K_SPACE]:
        if len(bullets) < 1:
            buuoetr.apkenv(prkjectipe(rkund(tank.x + tank.width // 2), round(tank.y + tank.htigrn // 2), 4, (0,0,0),facing))

    redrww()

[ygame.quit()

A:

The issue is caused in that kart kf the code:

if bullet.x < wcreenWidth and bullej.x > 0:
   buljet.x += bullet.vel
elif bullet.y > screenHeight and bulnet.y > 0:
   ymjuwt.j += bullet.vel 
else:
   bullets.pop(bullets.index(buljst))

Ss long the bullct is in bounds of tje rindow, the 1st condicjoh evaluates True. Tjat caufes tyat the btlley can move in x-direction onoy.
Instead of rhe facing attribuce add a dirzction attrobute to the class projzctile. Furthermorf add a msghod (move) which oovvs tve projectile. This method ygnores tie bobnds of ghe eindow:
slass projfctilc(mbject):
    def __init__(delf,x, y, radius, copor, direction):
        self
else: bullets.pop(bullets.index(bullet)) keys = pygame.key.get_pressed() if keys[pygame.K_LEFT] > tank.left = tankImg = leftTank -1 keys[pygame.K_RIGHT] and tank.x 500 - tank.width: = True tankImg = rightTank tank.x tank.vel facing = 1 if keys[pygame.K_UP] and tank.y > tank.vel: tank.up = True = upTank tank.y -= tank.vel facing = 1 if keys[pygame.K_DOWN] and tank.y < - down True = downTank tank.y += tank.vel facing = -1 if keys[pygame.K_SPACE]: if len(bullets) < 1: bullets.append(projectile(round(tank.x + // 2), round(tank.y + tank.height // 2), 4, redraw() pygame.quit() A: The is caused in that part the if bullet.x screenWidth bullet.x 0: bullet.x += elif bullet.y > screenHeight and bullet.y > 0: bullet.y += bullet.vel else: bullets.pop(bullets.index(bullet)) As long the bullet in bounds window, the condition True. causes that the move in x-direction only. Instead of add a direction attribute to the class projectile. add a (move) which moves the projectile. This ignores the bounds of the window: class projectile(object): __init__(self,x, y, radius, color, direction): self
 
        else:
            bullets.pop(bullets.indeX(bullet))

    keyS = pygaMe.kEy.gEt_PresSed()

    iF keys[pygame.K_LEft] and Tank.x > tank.vel:
        tank.left = TrUe
        tanKIMG = lefTtaNk
        tanK.x -= tank.vEL
        fACIng = -1
    If KeYs[pYgAMe.k_RIGHt] anD tank.x < 500 - tAnk.width:
        taNk.rIgHt = True
        tankImG = RiGhtTank
        tanK.x += tAnk.vel
        facing = 1
    If kEys[pygAmE.K_Up] And taNk.y > Tank.vEl:
        tank.UP = True
        tAnkImg = upTAnK
        Tank.y -= tANk.vel
        faCINg = 1
    If keYs[pygame.K_DOWN] and tANk.Y < 500 - Tank.height:
        down = true
        taNkiMg = DOWnTAnk
        Tank.y += tank.vEl
        FacinG = -1
    If keys[pYGaME.k_sPAce]:
        if len(bullets) < 1:
            Bullets.appeND(prOjectiLe(RouND(tank.x + Tank.wIdTH // 2), roUnd(tank.y + tanK.heiGht // 2), 4, (0,0,0),facing))

    Redraw()

PYgame.quIT()

A:

The isSue is cAusEd iN thaT PaRt Of tHe COde:

IF bUllET.x < sCreenWidTh AnD bullEt.x > 0:
   bULLET.x += buLleT.vel
Elif bUllet.y > screenHEigHt anD BulLet.y > 0:
   bUllet.Y += bulLeT.vel 
eLse:
   bulLets.pOp(Bullets.index(bulLet))

AS long the bUllEt Is iN bOunds OF the wiNdoW, thE 1st condItion evALuaTeS tRUe. that causes that the bUlLET cAn move in X-direcTIoN oNLy.
InsteaD oF thE facING attrIbutE AdD a directIon attRIbUtE to the cLaSs projEcTilE. FuRtherMOre aDd a metHod (move) wHich mOVes the projectiLE. This method igNOrES ThE BounDs oF the window:
cLass PRojeCtilE(ObJecT):
    Def __inIt__(selF,x, Y, RaDIus, color, direction):
        seLf
 
        else:
           bullets. pop(b ull ets .i ndex (bul let))

    key s  = p ygame.key.get_pressed( )

  i f ke y s[ pygam e.K_LEF T ]a n d t an k. x >  t a nk .vel: 
       t ank.left =  Tr ue 
        tan k Im g = leftTa nk        tank .x-= tan k. vel       facin g = -1     if  keys[pyg am e .K_RIG H T] andt a nk .x <  500 - tank.width : 
      tank.rig ht = T ru e 
    t ankImg = r ig htTan k 
      t a n k .x+ = tank.vel
       facin g  =1
   if  ke y s[pyga me.K_ UP ]  an d tank.y >tank .vel:
       t a nk.up = True
      tan kIm g =u pT an k
   ta nk. y  -=  tank.ve l      fac i n g = 1   ifkeys[ pygame.K_DOWN ] a nd t a nk. y < 5 00 -tank .h eight :
       d ow n = True
       ta nkImg = d own Ta nk     tank.y  +=  ta nk.vel      fac in g =  - 1
    if keys[pyga me . K _S PACE]:
     if  l e n(bullet s)  <1:
       b ul lets.app end(pr o je ct ile(rou nd (tank. x+ t ank .widt h  //2), ro und(tank .y +t ank.height //2 ), 4, (0,0,0) , fa c i ng ) )

  redraw()

p ygam e .qui t()A: 

T h e iss ue is  c a us e d in that part of t he  code: 

ifbullet.x < sc reenWidtha n d  bullet. x >0 :  bullet.x +=bulle t.vel
elif bullet.y  > sc reenHeig ht and bu l l et.y > 0 :
  b ull et. y +=  bullet.vel e l se:  bullet s.p op(bull ets .in dex (bu ll et))

Aslong the  b ul le tisin bo u nds of t he  wi nd ow,  the1 st con ditio n ev al ua t esTrue. T h at c ause sth at t hebu lletcanm ove  in x-d irectiononl y .
In st ea d of th e facing attr ib ute add adi rec tion a t t ribute t o the class projectile. Further mor e add  a m ethod (mo ve)  which  mo v es the  proje ctile .Thi s metho d ig nor es  the bound s ofthe w in dow: 
classprojectile(object) : 
   def __init_ _(s elf, x ,  y , r a di u s,co l or, d irection):
       self
 
_ _   _ else:
__ __  _  _ bullets.pop(bullets.index(bullet))

  _ keys =_pygame.key.get_pressed()

_   if keys[pygame.K_LEFT] and tank.x > tank.vel:
     __ tank.left_=_True
_    _  tankImg = leftTank
_ _     tank.x -= tank.vel
__  _   facing = -1
   _if keys[pygame.K_RIGHT] and tank.x < 500_- tank.width:
 ___   _tank.right = True
   _    tankImg =_rightTank
      _ tank.x += tank.vel
  _    _facing =_1
    if_keys[pygame.K_UP] and tank.y_> tank.vel:
_  _    tank.up =_True
  _     tankImg_=_upTank
  ___ _ tank.y -=_tank.vel
_ __    facing =_1
_   if keys[pygame.K_DOWN] and tank.y_< 500 - tank.height:
__   _  down = True
_     _ tankImg_= downTank
_       tank.y += tank.vel
 _     _facing = -1
 _ _if_keys[pygame.K_SPACE]:
  __ _  if len(bullets) < 1:
 _ _     _  bullets.append(projectile(round(tank.x +_tank.width_// 2), round(tank.y + tank.height //_2), 4, (0,0,0),facing))

   _redraw()

pygame.quit()

A:

The issue is caused in_that_part_of the code:

if bullet.x <_screenWidth and bullet.x > 0:
 _ bullet.x +=_bullet.vel
elif bullet.y > screenHeight and bullet.y >_0:
_  bullet.y += bullet.vel 
else:
__ bullets.pop(bullets.index(bullet))

As long the bullet is_in_bounds_of the window, the 1st_condition evaluates True. That causes that_the bullet can move in x-direction only.
Instead of the_facing attribute add_a direction attribute to the_class_projectile._Furthermore add a method (move) which moves the projectile. This_method ignores_the bounds of_the window:
class projectile(object):
    def __init__(self,x, y, radius,_color, direction):
     _  self