示例#1
0
    def start(self):
        self.image = pygame.image.load("assets/images/space.jpg")
        test_go = GameObject()
        test_go.name = "Ship"
        test_go.get_behaviour("Transform").position.x = 512
        test_go.get_behaviour("Transform").position.y = 388
        test_go.add_behaviour(BoxCollider())
        test_go.get_behaviour("BoxCollider").is_debug = False
        test_go.get_behaviour("BoxCollider").extent = pygame.math.Vector2(150)
        test_go.add_behaviour(ShipRenderer())
        test_go.add_behaviour(ShieldRenderer())
        test_go.add_behaviour(Movement())
        test_go.add_behaviour(ShipCommands())
        self.add_game_object(test_go)

        another_go = GameObject()
        another_go.name = "Obstacle"
        another_go.get_behaviour("Transform").position.x = 200
        another_go.get_behaviour("Transform").position.y = 200
        another_go.add_behaviour(BoxCollider())
        another_go.get_behaviour("BoxCollider").is_debug = True
        another_go.get_behaviour("BoxCollider").extent = Vector2(350)
        self.add_game_object(another_go)

        overlap_go = GameObject()
        overlap_go.name = "Overlap"
        overlap_go.add_behaviour(RectRenderer())
        overlap_go.get_behaviour("RectRenderer").colour = (255, 0, 0)
        overlap_go.get_behaviour("RectRenderer").rect = Rect(0, 0, 0, 0)
        self.add_game_object(overlap_go)
        super().start()
示例#2
0
 def start(self):
     self.image = pygame.image.load("assets/Images/Space.jpg")
     test_go = GameObject()
     test_go.name = "Ship"
     test_go.get_behaviour("Transform").position.x = 512
     test_go.get_behaviour("Transform").position.y = 388
     test_go.add_behaviour(ShipRenderer())
     test_go.add_behaviour(ShieldRenderer())
     test_go.add_behaviour(Movement())
     test_go.add_behaviour(ShipCommands())
     self.add_game_object(test_go)
     super().start()
示例#3
0
    def start(self):
        #Background setting functionality
        self.image = pygame.image.load("assets/Images/Space.jpg")

        #player character setting:
        #-> Sets the Transform so that the ship begins the game
        #   in the middle of the screen
        #-> Adds a box collider and sets its size
        #-> Also adds Movement, ShipCommands and ShipRenderer
        #   functionality
        #-> Adds the Game Object to the game_objects list
        test_go = GameObject()
        test_go.name = "Ship"
        test_go.get_behaviour("Transform").position = Vector2(512, 388)
        test_go.add_behaviour(BoxCollider())
        test_go.get_behaviour("BoxCollider").extent = Vector2(150)
        test_go.add_behaviour(ShipRenderer())
        test_go.add_behaviour(ShieldRenderer())
        test_go.add_behaviour(Movement())
        test_go.add_behaviour(ShipCommands())
        self.add_game_object(test_go)

        #insert obstacle below:
        #-> Name it "Obstacle"
        #-> Position its Transform at 200, 200
        #-> Add a BoxCollider behaviour
        #-> Set the BoxCollider's is_debug flag to True
        #-> Set the BoxCollider's extent to 350, 350
        #->Add it to the screen's game_objects list
        another_go = GameObject()
        another_go.name = "Obstacle"
        another_go.get_behaviour("Transform").position = Vector2(200, 200)
        another_go.add_behaviour(BoxCollider())
        another_go.get_behaviour("BoxCollider").is_debug = True
        another_go.get_behaviour("BoxCollider").extent = pygame.math.Vector2(
            350)
        self.add_game_object(another_go)

        #insert the overlap game object here:
        #-> Name it "Overlap"
        #-> Add a RectRenderer behaviour
        #-> Set the RectRenderer's colour
        #-> Add the Game Object to the screen's game_objects list
        overlap_go = GameObject()
        overlap_go.name = "Overlap"
        overlap_go.add_behaviour(RectRenderer())
        overlap_go.get_behaviour("RectRenderer").colour = (255, 0, 0)
        self.add_game_object(overlap_go)

        #base class start() call
        super().start()
示例#4
0
    def start(self):
        print("(?) src.game_screen: start() called")
        self.image = pygame.image.load("assets/images/background.jpg")

        def player_death():
            from engine.game_env import Game
            from src.intro_screen import IntroScreen
            print("You died")
            Game.instance.set_screen(IntroScreen())

        lvl_go = GameObject()
        lvl_go.name = "LevelText"
        h = pygame.display.get_surface().get_height()
        lvl_go.get_behaviour("Transform").position = Vector2(10, h - 70)
        lvl_go.add_behaviour(TextRenderer())
        lvl_go.get_behaviour("TextRenderer").text = "Level " + str(self.level)
        lvl_go.get_behaviour("TextRenderer").set_size(90)
        self.add_game_object(lvl_go)

        play_go = GameObject()
        play_go.name = "Player"
        play_go.get_behaviour("Transform").position = Vector2(512, 700)
        play_go.add_behaviour(BoxCollider())
        play_go.get_behaviour("BoxCollider").is_debug = False
        play_go.get_behaviour("BoxCollider").extent = Vector2(150)
        play_go.add_behaviour(ImageRenderer())
        play_go.add_behaviour(PlayerCommands())
        play_go.add_behaviour(LinearMovement())
        play_go.add_behaviour(PlayerData())
        play_go.get_behaviour("PlayerData").death_func = player_death
        play_go.add_behaviour(Boundaries())
        play_go.get_behaviour("Boundaries").set_offset(Vector2(60, 0))
        play_go.add_behaviour(ScreenshotTaker())
        self.add_game_object(play_go)

        for i in range(3):
            sr_go = GameObject()
            sr_go.name = "Shield" + str(i)
            sr_go.get_behaviour("Transform").position.x = 200 + i * 250
            sr_go.get_behaviour("Transform").position.y = 500
            sr_go.add_behaviour(ShieldRenderer())
            self.add_game_object(sr_go)

        el_go = GameObject()
        el_go.name = "EnemyLine"
        el_go.add_behaviour(EnemyLine())
        self.add_game_object(el_go)

        print("(?) src.game_screen: start() done")

        super().start()
示例#5
0
    def start(self):
        self.image = pygame.image.load("assets/images/space.jpg")
        test_go = GameObject()
        test_go.name = "Ship"
        test_go.get_behaviour("Transform").position.x = 512
        test_go.get_behaviour("Transform").position.y = 388
        test_go.add_behaviour(BoxCollider())
        test_go.get_behaviour("BoxCollider").is_debug = False
        test_go.get_behaviour("BoxCollider").extent = pygame.math.Vector2(150)
        test_go.add_behaviour(ShipRenderer())
        test_go.add_behaviour(ShieldRenderer())
        test_go.add_behaviour(Movement())
        test_go.add_behaviour(ShipCommands())
        self.add_game_object(test_go)

        another_go = GameObject()
        another_go.name = "Obstacle"
        another_go.get_behaviour("Transform").position.x = 200
        another_go.get_behaviour("Transform").position.y = 200
        another_go.add_behaviour(BoxCollider())
        another_go.get_behaviour("BoxCollider").is_debug = True
        another_go.get_behaviour("BoxCollider").extent = Vector2(350)
        self.add_game_object(another_go)

        overlap_go = GameObject()
        overlap_go.name = "Overlap"
        overlap_go.add_behaviour(RectRenderer())
        overlap_go.get_behaviour("RectRenderer").colour = (255, 0, 0)
        overlap_go.get_behaviour("RectRenderer").rect = Rect(0, 0, 0, 0)
        self.add_game_object(overlap_go)

        #Create Text Game Object, name it "Text",
        #Set Game Object position
        #Add TextRenderer behaviour
        #Set Message
        #Set Size
        #Add Game Object to screen
        text_go = GameObject()
        text_go.name = "Text"
        text_go.get_behaviour("Transform").position = Vector2(500, 350)
        text_go.add_behaviour(TextRenderer())
        text_go.get_behaviour("TextRenderer").text = "Welcome, Earthlings"
        text_go.get_behaviour("TextRenderer").set_size(30)
        self.add_game_object(text_go)

        super().start()