MCPcopy Create free account
hub / github.com/ActiveState/code / ShotMove

Function ShotMove

recipes/Python/580636_Space_Assault/recipe-580636.py:1057–1284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1055 cycle += 1
1056
1057 def ShotMove():
1058 global direction
1059 global en2Xpos
1060 global en2Ypos
1061 global destroy
1062 global gameover
1063 if gameover != 1:
1064 self.after(10,ShotMove)
1065 #Move Shots
1066 cycle = 0
1067 for self.shot in Shots:
1068 destroy = -1
1069 if ShotDir[cycle] == "N":
1070 ShotsYpos[cycle] -= 10
1071 elif ShotDir[cycle] == "E":
1072 ShotsXpos[cycle] += 10
1073 elif ShotDir[cycle] == "S":
1074 ShotsYpos[cycle] += 10
1075 elif ShotDir[cycle] == "W":
1076 ShotsXpos[cycle] -= 10
1077 self.shot.place(x=ShotsXpos[cycle],y=ShotsYpos[cycle])
1078 #Damage Enemy1
1079 enCycle = 0
1080 for self.enemy in Enemies:
1081 if destroy == -1:
1082 if EnemiesXpos[enCycle] + 30 >= ShotsXpos[cycle] >= EnemiesXpos[enCycle] - 10 and EnemiesYpos[enCycle] + 30 >= ShotsYpos[cycle] >= EnemiesYpos[enCycle] - 10:
1083 destroy = 0
1084 if EnemiesDmg[enCycle] == 1:
1085 self.explode = Canvas(bg="black",highlightthickness=0,width=30,height=30)
1086 self.explode.place(x=EnemiesXpos[enCycle],y=EnemiesYpos[enCycle])
1087 self.explode.create_polygon(0,15,13,13,15,0,17,13,30,15,17,17,15,30,13,17,fill="orange")
1088 Explosions.append(self.explode)
1089 self.enemy.destroy()
1090 del Enemies[enCycle]
1091 del EnemiesDmg[enCycle]
1092 del EnemiesXpos[enCycle]
1093 del EnemiesYpos[enCycle]
1094 self.after(10,destroyEnemy)
1095 self.shot.destroy()
1096 del Shots[cycle]
1097 del ShotsXpos[cycle]
1098 del ShotsYpos[cycle]
1099 del ShotDir[cycle]
1100 else:
1101 self.shot.destroy()
1102 del Shots[cycle]
1103 del ShotsXpos[cycle]
1104 del ShotsYpos[cycle]
1105 del ShotDir[cycle]
1106 EnemiesDmg[enCycle] += 1
1107 if EnemiesDmg[enCycle] == 0:
1108 EnemyColor = "darkviolet"
1109 else:
1110 EnemyColor = "violet"
1111 self.enemy.itemconfig(self.enemy.polygon,fill=EnemyColor)
1112 enCycle += 1
1113 #Damage Enemy2
1114 enCycle = 0

Callers 5

PauseFunction · 0.85
SinglePlayerFunction · 0.85
MultiPlayerFunction · 0.85

Calls 4

afterMethod · 0.45
placeMethod · 0.45
appendMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected