コード例 #1
0
ファイル: __main__.py プロジェクト: chandlerowen23/cse-tc08
def main(screen):

    # create the cast {key: tag, value: list}
    cast = {}

    # create paddle
    x = int(constants.MAX_X / 2)
    y = int(constants.MAX_Y - 2)
    position = Point(x, y)
    paddle = Actor()
    paddle.set_text("===========")
    paddle.set_position(position)
    cast["paddle"] = [paddle]

    # create bricks
    cast["brick"] = []
    for x in range(5, 75):
        for y in range(2, 6):
            position = Point(x, y)
            brick = Actor()
            brick.set_text("*")
            brick.set_position(position)
            cast["brick"].append(brick)

    #create ball
    x = int(constants.MAX_X / 2)
    y = int(constants.MAX_Y / 2)
    position = Point(x, y)
    velocity = Point(1, -1)
    ball = Actor()
    ball.set_text("@")
    ball.set_position(position)
    ball.set_velocity(velocity)
    cast["ball"] = [ball]

    position = Point(0, 0)
    score = Actor()
    score.set_text(f"Score: ")
    score.set_position(position)
    score.set_velocity(position)
    cast["score"] = [score]

    # create the script {key: tag, value: list}
    script = {}

    input_service = InputService(screen)
    output_service = OutputService(screen)
    control_actors_action = ControlActorsAction(input_service)
    move_actors_action = MoveActorsAction()
    handle_collisions_acition = HandleCollisionsAction()
    draw_actors_action = DrawActorsAction(output_service)

    script["input"] = [control_actors_action]
    script["update"] = [move_actors_action, handle_collisions_acition]
    script["output"] = [draw_actors_action]

    # start the game
    director = Director(cast, script)
    director.start_game()
コード例 #2
0
ファイル: word.py プロジェクト: gublerj/cse210-tc07
 def add_word(self, word, position, velocity):
     """
     This method will add a new word to the array storing all the words
     """
     words = Actor()
     words.set_text(word)
     words.set_position(position)
     words.set_velocity(velocity)
     self._list_of_words.append(words)
コード例 #3
0
ファイル: cycle.py プロジェクト: FinestTurtle/TRON
    def _add_trail_bit(self, position, velocity, image):
        """Adds a new bit to the end of the trail.

        Args:
            self(Cycle): an instance of Cycle.
            position (Point): The bit's position.
            velocity (Point): The bit's velocity."""
        bit = Actor(image)
        bit.set_position(position)
        bit.set_velocity(velocity)
        self._trail_bits.append(bit)
コード例 #4
0
ファイル: speed.py プロジェクト: chandlerowen23/cse210-tc07
    def add_words(self, text, position, velocity):
        """Adds a new segment to the speed using the given text, position and velocity.

        Args:
            self (speed): An instance of speed.
            text (string): The segment's text.
            position (Point): The segment's position.
            velocity (Point): The segment's velocity.
        """
        segment = Actor()
        segment.set_text(str(text))
        segment.set_position(position)
        segment.set_velocity(velocity)
        self._word_list.append(segment)
コード例 #5
0
ファイル: wordActor.py プロジェクト: Dbenjamy/cse210-tc07
    def _add_segment(self, position, velocity):
        """Adds a new segment to the snake using the given text, position and velocity.

        Args:
            self (Snake): An instance of snake.
            text (string): The segment's text.
            position (Point): The segment's position.
            velocity (Point): The segment's velocity.
        """
        segment = Actor()
        segment.set_text(self._choose_word())
        segment.set_position(position)
        segment.set_velocity(velocity)
        self._segments.append(segment)
コード例 #6
0
 def _add_trail(self, image, position, velocity):
     trail = Actor(image)
     trail.set_position(position)
     trail.set_velocity(velocity)
     self._trails.append(trail)
コード例 #7
0
 def _add_segment(self, text, position, velocity):
     segment = Actor()
     segment.set_text(text)
     segment.set_position(position)
     segment.set_velocity(velocity)
     self.word.append(segment)