Drone Invaders kinda works, can't tell because of slow school computer.
This commit is contained in:
parent
d5f2439dfe
commit
321ba3c9b9
2 changed files with 7 additions and 5 deletions
|
@ -28,15 +28,16 @@ class Bomb(BoundedTurtle):
|
|||
self.scoreboard = scoreboard
|
||||
|
||||
def move(self):
|
||||
self.forward(self.get_speed())
|
||||
self.forward(0.1)
|
||||
if self.out_of_bounds():
|
||||
self.remove()
|
||||
for drone in Drone.get_drones():
|
||||
if self.distance(drone) < self.get_speed() and self.isvisible():
|
||||
drone.remove()
|
||||
self.remove()
|
||||
Audio.play_explosion_sound()
|
||||
self.scoreboard.increment(4)
|
||||
else:
|
||||
self.getscreen().ontimer(self.move, 100)
|
||||
self.getscreen().ontimer(self.move, 100)
|
||||
|
||||
def distance(self, other):
|
||||
p1 = self.position()
|
||||
|
@ -44,5 +45,6 @@ class Bomb(BoundedTurtle):
|
|||
return math.dist(p1, p2)
|
||||
|
||||
def remove(self):
|
||||
self.clear()
|
||||
self.hideturtle()
|
||||
self.penup()
|
||||
self.clear()
|
||||
|
|
|
@ -24,7 +24,7 @@ class Drone(BoundedTurtle):
|
|||
self.shape('images/Drone64.gif')
|
||||
self.resizemode('user')
|
||||
self.turtlesize(10, 10, 1)
|
||||
x = random.uniform(x_min * 0.1, x_max * 0.1)
|
||||
x = random.uniform(x_min * 0.9, x_max * 0.9)
|
||||
self.goto(x, y_max * 1.1)
|
||||
self.setheading(270)
|
||||
self.getscreen().tracer(True)
|
||||
|
|
Loading…
Reference in a new issue