Drone Invaders kinda works, can't tell because of slow school computer.

This commit is contained in:
ben 2022-07-28 16:18:07 -05:00
parent d5f2439dfe
commit 321ba3c9b9
2 changed files with 7 additions and 5 deletions

View file

@ -28,14 +28,15 @@ class Bomb(BoundedTurtle):
self.scoreboard = scoreboard self.scoreboard = scoreboard
def move(self): 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(): for drone in Drone.get_drones():
if self.distance(drone) < self.get_speed() and self.isvisible(): if self.distance(drone) < self.get_speed() and self.isvisible():
drone.remove() drone.remove()
self.remove() self.remove()
Audio.play_explosion_sound() Audio.play_explosion_sound()
self.scoreboard.increment(4) self.scoreboard.increment(4)
else:
self.getscreen().ontimer(self.move, 100) self.getscreen().ontimer(self.move, 100)
def distance(self, other): def distance(self, other):
@ -44,5 +45,6 @@ class Bomb(BoundedTurtle):
return math.dist(p1, p2) return math.dist(p1, p2)
def remove(self): def remove(self):
self.clear()
self.hideturtle() self.hideturtle()
self.penup()
self.clear()

View file

@ -24,7 +24,7 @@ class Drone(BoundedTurtle):
self.shape('images/Drone64.gif') self.shape('images/Drone64.gif')
self.resizemode('user') self.resizemode('user')
self.turtlesize(10, 10, 1) 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.goto(x, y_max * 1.1)
self.setheading(270) self.setheading(270)
self.getscreen().tracer(True) self.getscreen().tracer(True)