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()
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()
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()
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()
# Size of cubes used to create wall segments. cubesize = 2 # Space around cubes to extend hitbox (prevents peeking through walls). collision_padding = 0.5 # Initial camera position after map is drawn. camerapos = [-8.0, 0.0, -38.0] # Initial camera rotation. camerarot = 0.0 # The angle in degrees the camera rotates each turn. rotate_angle = 1 first_run = False collision = Collision() input = Input() movement = Movement() map = [] # Loaded textures. ceilingtexture = None floortexture = None walltexture = None def initGL(Width, Height): glClearColor(0.0, 0.0, 0.0, 0.0) glClearDepth(1.0) glDepthFunc(GL_LESS) glEnable(GL_DEPTH_TEST)
def get_movement(): from src.movement import Movement return Movement()