Exemple #1
0
 def generate_obstacle(self):
     direction = rand(0, 1) < 0.5
     rect = Rectangle(Vector2(direction * 0.5 * Constants.screen_width + 12, - 0.06 * Constants.screen_height),
                      Vector2(0.45 * Constants.screen_width,0.06 * Constants.screen_height),
                      Material((255, 255, 255)))
     rect.animation = ObstaclePulsingAnimation(rect)
     rect.animator = Animator(rect, [rect.animation])
     rect.animator.play()
     self.game_object_list.append(rect)
Exemple #2
0
 def generate_obstacle(self):
     self.obstacle_width = 0.3 * Constants.screen_width
     self.obstacle_height = 0.06 * Constants.screen_height
     rect = Rectangle(Vector2(0.5 * Constants.screen_width - 0.5 * self.obstacle_width, - 3*self.obstacle_height),
                      Vector2(self.obstacle_width, self.obstacle_height),
                      Material((255, 255, 255)))
     rect.animation = ObstaclePulsingAnimation(rect)
     rect.animator = Animator(rect, [rect.animation])
     rect.animator.play()
     self.game_object_list.append(rect)
Exemple #3
0
    def generate_obstacle(self):
        direction = rand(0, 1) < 0.5
        obstacle_width = 0.45 * Constants.screen_width
        obstacle_height = 0.06 * Constants.screen_height

        rect1 = Rectangle(
            Vector2(direction * 0.5 * Constants.screen_width + 12,
                    -obstacle_height), Vector2(obstacle_width,
                                               obstacle_height),
            Material((255, 255, 255)))

        rect2_x = rect1.transform.position.x - 12

        if rect2_x == 0:
            rect2_x = 0.5 * Constants.screen_width + 12
        else:
            rect2_x = 0.0 + 12

        rect2 = Rectangle(Vector2(rect2_x, rect1.transform.position.y),
                          Vector2(obstacle_width, obstacle_height),
                          Material((255, 255, 255)))

        rect1.animation = ObstaclePulsingAnimation(rect1)
        rect1.animator = Animator(rect1, [rect1.animation])
        rect1.animator.play()

        rect2.animation = ObstaclePulsingAnimation(rect2)
        rect2.animator = Animator(rect2, [rect2.animation])
        rect2.animator.play()

        self.game_object_list.append([rect1, rect2])
    def generate_obstacle(self):
        random_pos = int(randfloat(self.size / 2 + Constants.circCenter_x - Constants.circRadius,
                                   Constants.screen_width -
                                   (self.size / 2 + Constants.circCenter_x - Constants.circRadius)))

        rect = Rectangle(Vector2(random_pos, -self.size),
                         Vector2(self.size, self.size),
                         Material((255, 255, 255)))
        rect.animation = ObstaclePulsingAnimation(rect)
        rect.animator = Animator(rect, [rect.animation])
        rect.animator.play()

        direction = randint(0, 1)
        if direction == 0:
            direction = -1
        rect.vel = direction  # Checks if going left or right. Can be 1 for right or -1 for left
        self.game_object_list.append(rect)
 def generate_obstacle(self):
     self.obstacle_width = 0.45 * Constants.screen_width
     self.obstacle_height = 0.06 * Constants.screen_height
     rect = Rectangle(
         Vector2(0.5 * Constants.screen_width - 0.5 * self.obstacle_width,
                 -self.obstacle_height),
         Vector2(self.obstacle_width, self.obstacle_height),
         Material((255, 255, 255)))
     direction = rand(0, 1) < 0.5
     if direction == 0:
         direction = -1
     rect.direction = direction
     rect.transform.rotate(0)
     rect.animation = ObstaclePulsingAnimation(rect)
     rect.animator = Animator(rect, [rect.animation])
     rect.animator.play()
     self.game_object_list.append(rect)
    def generate_obstacle(self):
        side = randint(0, 1)

        rect = Rectangle(Vector2(-self.obstacle_width/2 + Constants.screen_width*side,
                                 - self.obstacle_height),
                         Vector2(self.obstacle_width, self.obstacle_height),
                         Material((255, 255, 255)))
        rect.animation = ObstaclePulsingAnimation(rect)
        rect.animator = Animator(rect, [rect.animation])
        rect.animator.play()

        if side == 1:
            rect.side = -1
        else:
            rect.side = 1

        self.game_object_list.append(rect)