示例#1
0
 def deccelerate(self):
     if self.speed > self.maxSpeed * -1:
         self.speed -= self.decellerationRate
     acceleationVelocity = Vect2()
     acceleationVelocity.x = math.cos(math.radians(
         self.rotation)) * self.decellerationRate
     acceleationVelocity.y = math.sin(math.radians(
         self.rotation)) * self.decellerationRate
     acceleationVelocity.magnitude = self.decellerationRate
     self.velocity -= acceleationVelocity
     self.speed = self.velocity.magnitude if self.velocity.magnitude < self.maxSpeed else self.maxSpeed
示例#2
0
 def accelerate(self):
     if self.speed < self.maxSpeed:
         self.speed += self.acellerationRate
     acceleationVelocity = Vect2()
     acceleationVelocity.x = math.cos(math.radians(
         self.rotation)) * self.acellerationRate
     acceleationVelocity.y = math.sin(math.radians(
         self.rotation)) * self.acellerationRate
     acceleationVelocity.magnitude = self.acellerationRate
     self.velocity += acceleationVelocity
     self.speed = self.velocity.magnitude if self.velocity.magnitude < self.maxSpeed else self.maxSpeed
示例#3
0
 def __init__(self, velocity=Vect2()):
     super().__init__()
     self.rotationRate = 5
     self.radius = 10
     self.speed = 20
     self.hitBox.radius = 10
     self.hitBox.clip = True
     angle = math.radians(random.randint(0, 359))
     self.velocity.magnitude = self.speed
     self.velocity.x = math.cos(angle) * self.speed
     self.velocity.y = math.sin(angle) * self.speed
     self.image = arcade.load_texture("images/meteorGrey_small1.png")
示例#4
0
    def hit(self, target, asteroids):
        if self.hitBox.clip:
            if (DEBUG):
                print("asteroid hit")
            self.alive = False
            self.hitBox.clip = False

            asteroids.remove(self)
            asteroid = MediumAsteroid()
            asteroidVelocity = Vect2()
            asteroidVelocity.x = 3
            asteroidVelocity.y = 3
            asteroidVelocity.magnitude = 3
            asteroid.center.x = self.center.x
            asteroid.center.y = self.center.y
            asteroid.velocity = asteroidVelocity
            asteroids.append(asteroid)

            asteroid = MediumAsteroid()
            asteroid.center.x = self.center.x
            asteroid.center.y = self.center.y
            asteroidVelocity = Vect2()
            asteroidVelocity.x = -3
            asteroidVelocity.y = 3
            asteroidVelocity.magnitude = 3
            asteroid.velocity = asteroidVelocity
            asteroids.append(asteroid)

            asteroid = MediumAsteroid()
            asteroid.center.x = self.center.x
            asteroid.center.y = self.center.y
            asteroidVelocity = Vect2()
            asteroidVelocity.x = 0
            asteroidVelocity.y = 6
            asteroidVelocity.magnitude = 3
            asteroid.velocity = asteroidVelocity
            asteroids.append(asteroid)
示例#5
0
 def hit(self, target, asteroids):
     if (type(target) is Ship or type(target) is Bullet):
         if self.hitBox.clip:
             self.alive = False
             self.hitBox.clip = False
             asteroids.remove(self)
             asteroid = SmallAsteroid()
             asteroid.center.x = self.center.x
             asteroid.center.y = self.center.y
             asteroidVelocity = Vect2()
             asteroidVelocity.x = 0
             asteroidVelocity.y = 2
             asteroidVelocity.magnitude = 5
             asteroid.velocity = asteroidVelocity
             asteroids.append(asteroid)
示例#6
0
 def __init__(self, ship):
     super().__init__()
     self.radius = 1
     self.life = Timer(60)
     self.life.paused = False
     self.hitBox.clip = False
     self.speed = Vect2()
     self.speed = ship.speed / 50 + 5
     self.activateTimer = Timer(10)
     self.activateTimer.paused = False
     self.rotation = ship.rotation
     self.center = Point(ship.center.x, ship.center.y)
     self.velocity.magnitude = self.speed
     self.velocity.x = math.cos(math.radians(ship.rotation)) * self.speed
     self.velocity.y = math.sin(math.radians(ship.rotation)) * self.speed
     self.texture = arcade.load_texture("images/laserBlue01.png")
示例#7
0
 def __init__(self):
     self.hitBox = CircleHitBox()
     self.velocity = Vect2()
     self.center = Point()
     self.alive = True
     self.speed = 0