def Start(): if xbmc.Player().isPlaying(): xbmc.Player().stop() import Overlay as Overlay MyOverlayWindow = Overlay.TVOverlay("script.pseudotv.TVOverlay.xml", CWD, "default") del MyOverlayWindow xbmcgui.Window(10000).setProperty("PseudoTVRunning", '')
if controls == False and options == False:#not on controls men.buttonHovers((mx,my),clicked)#checks for hovers men.draw()#draws menu elif controls == True: controlMen.buttonHovers((mx,my),clicked)#checks for hovers controlMen.draw()#draws controls elif options == True: optionMen.buttonHovers((mx,my),clicked)#checks for hovers optionMen.draw()#draws controls pygame.display.flip()#refresh clock.tick(60)#set framerate if play == True: background.fill((173, 216, 230))#sets background to sky color mainCamera = Camera.camera(screen,0,0,screenSize)#creates camera over = Overlay.overlay(screen,font,ItemList.itemList(loadPictures('data/images/Items/')))#creates overlay focussed on player worldBack = World.world((10000, 5000),mainCamera,loadPictures('data/images/tiles/'),itemList,tileCracks,weaponPics,armorPics,over,lighting=activeLighting)#creates a world worldBack.worldGen('Grassland')#generates the world AIOn = worldBack.AIOn#global variable controlling whether the AI is active charList = CharacterList.characterList(armorPics) player = worldBack.addCharacter(0,True)#creates the player on team player player.changeXY(500)#move him/her right 500px bottomRow = worldBack.size[1]//32#finds bottom row def displayFPS(font):#displays the frames per second fps = int(clock.get_fps())#gets fps fpsFont = font.render(str(fps), 1, (250, 250, 250))#font renders it fpsPos = fpsFont.get_rect() fpsPos.centerx = 50
def on_init(self): # (from: on_execute) # Puts pygame window in the middle os.environ['SDL_VIDEO_CENTERED'] = '1' # Check that Mixer was initiated. on_execute will fail/stop the program otherwise. if self.initpygame() is False: return False # Initialize Game Window # (Not Used Yet!) Video Display Object: If called before pygame.display.set_mode() can provide user's screen resolution # initialize window self._infoObject = pygame.display.Info() # Map Image in Background (Needs to be rendered) # Window Size resolutionx = 1000 resolutiony = 800 self._display_surfrender = pygame.Surface( (resolutionx, resolutiony)) # Map 800,600 self._display_surf = pygame.display.set_mode((800, 600), pygame.RESIZABLE) # CWD path for images self._cwdpath = os.getcwd() pygame.display.set_caption("Scuffed StarCraft") pygame.display.set_icon( pygame.image.load(os.path.join(self._cwdpath, "Images", "sc2.png"))) # Ignore cursor for now need to figure out a way to do it on the OS probably because it lags # pygame.mouse.set_visible(False) pygame.event.set_grab(True) # Initialize FPS value (see .handlefps()) # initialize other values self._lasttime = 0 self._input = input.input() self._playerinfo = playerinfo.playerinfo() # Initialize Map Dimensions and Camera Set-Up self.map = Map.Map(resolutionx, resolutiony) # Initialize Overlay (UI) self.overlay = Overlay.Overlay() self.overlay.load_media(self._cwdpath) # Initialize Cursor/Map/Sounds and other general media self.load_media() # Initialize Troops and smaller entities self.load_entities() # Initialize Map resources self.load_resources() self.load_buildings() # Initialize Graph for Map self.load_Graph() # GAME OPTIONS self.overlay_enable = True # Toggles overlay self.worldgraph_editmode = False # Toggles being able to edit the world graph nodes self.worldgraph_render = False # Toggles being able to see the world graph self.bspgraph_render = False # Toggles being able to see the bsp graph self.clickcount = 0 self.clickpoints = [] pygame.mixer.music.load( os.path.join(self._cwdpath, "Sounds", "title_music.wav")) pygame.mixer.music.set_volume(0.5) pygame.mixer.music.play(-1)
def setup(self, x=None, y=None): #sprite list: self.player_list = arcade.SpriteList() self.wall_list = arcade.SpriteList() self.background_list = arcade.SpriteList() #player setup: self.player = Animation.PlayerCharacter() #setup map: map_name = f"maps/{self.map}.tmx" platforms_layer_name = 'walls' my_map = arcade.tilemap.read_tmx(map_name) # Only create the dialogue event list on the first load, reference list on successive map changes if self.first_load_of_game: # Set up Event Class # (Don't recreate Event class on new map load) self.event = Event.Event() self.event.dialogue_events_overworld = arcade.tilemap.process_layer( arcade.tilemap.read_tmx("maps/overworld.tmx"), "Dialogue_Events", TILE_SCALING) self.event.dialogue_events_dollarstore = arcade.tilemap.process_layer( arcade.tilemap.read_tmx("maps/DollarStore.tmx"), "Dialogue_Events", TILE_SCALING) self.event.dialogue_events_malmart = arcade.tilemap.process_layer( arcade.tilemap.read_tmx("maps/MalMart.tmx"), "Dialogue_Events", TILE_SCALING) self.event.dialogue_events_school = arcade.tilemap.process_layer( arcade.tilemap.read_tmx("maps/TheSchool.tmx"), "Dialogue_Events", TILE_SCALING) self.first_load_of_game = False # Only set-up encounters constructor/set-up on initial game load: self.encounter = Encounter.Encounter() self.encounter.setup(self.view_bottom, self.view_left) # Always display finished events self.finished_event = arcade.tilemap.process_layer( arcade.tilemap.read_tmx(map_name), "Finished_Event", TILE_SCALING) if self.map == "overworld": self.building_list = arcade.SpriteList() self.rand_range = 600 if x and y: self.player.center_x = x self.player.center_y = y else: self.player.center_x = 512 self.player.center_y = 5000 # Use the event list for the overworld self.dialogue_events_list = self.event.dialogue_events_overworld self.building_list = arcade.tilemap.process_layer( my_map, "buildings", TILE_SCALING) arcade.set_background_color(arcade.csscolor.BURLYWOOD) else: # Use event list for Dollar Store if self.map == "DollarStore": self.dialogue_events_list = self.event.dialogue_events_dollarstore # Use event list for MalMart elif self.map == "MalMart": self.dialogue_events_list = self.event.dialogue_events_malmart # Use event list for School elif self.map == "TheSchool": self.dialogue_events_list = self.event.dialogue_events_school self.rand_range = 300 self.door_list = arcade.SpriteList() self.player.center_x = 256 self.player.center_y = 2960 self.door_list = arcade.tilemap.process_layer( my_map, "doors", TILE_SCALING) arcade.set_background_color(arcade.csscolor.WHITE) self.player_list.append(self.player) # Set up overlay class self.overlay = Overlay.Overlay() self.overlay.load_media() #Set up Inventory Class self.inventory = Inventory.Inventory() #set up walls self.wall_list = arcade.tilemap.process_layer( map_object=my_map, layer_name=platforms_layer_name, scaling=TILE_SCALING) #set up background objects: self.background_list = arcade.tilemap.process_layer( my_map, "Background", TILE_SCALING) #setup background: if my_map.background_color: arcade.set_background_color(my_map.background_color) self.physics_engine = arcade.PhysicsEngineSimple( self.player, self.wall_list) self.view_bottom = 0 self.view_left = 0
men.buttonHovers((mx, my), clicked) # checks for hovers men.draw() # draws menu elif controls == True: controlMen.buttonHovers((mx, my), clicked) # checks for hovers controlMen.draw() # draws controls elif options == True: optionMen.buttonHovers((mx, my), clicked) # checks for hovers optionMen.draw() # draws controls pygame.display.flip() # refresh clock.tick(60) # set framerate if play == True: background.fill((173, 216, 230)) # sets background to sky color mainCamera = Camera.camera(screen, 0, 0, screenSize) # creates camera over = Overlay.overlay( screen, font, ItemList.itemList(loadPictures("data/images/Items/")) ) # creates overlay focussed on player worldBack = World.world( (10000, 5000), mainCamera, loadPictures("data/images/tiles/"), itemList, tileCracks, weaponPics, armorPics, over, lighting=activeLighting, ) # creates a world worldBack.worldGen("Grassland") # generates the world AIOn = worldBack.AIOn # global variable controlling whether the AI is active charList = CharacterList.characterList(armorPics)
def display(self, x=0, y=0): '''Called for every refresh; redraws the floor and objects based on the camera angle. Calls collision detection, handles the appropriate objects for keys, doors, etc.''' glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() self.camera.move(self.objects) self.camera.check_collisions(self.objects) self.camera.renderCamera() self.renderLightSource() self.makeFloor() # Transparent objects! glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) self.sort_by_dist() for obj in self.objects: if obj.get_dist(self.camera.pos_X, self.camera.pos_Y, self.camera.pos_Z) < 15: color = obj.get_color() pos = obj.get_pos() obj_type = obj.get_type() glPushMatrix() # Set the objects shininess, ambient, diffuse, and # specular reflections. The objects are slightly # transparent. <- (nick: Why?) glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 15) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], .5]) glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [.4, .4, .4, 1]) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [.9, .9, .9, .5]) glTranslate(pos[0], pos[1], pos[2]) if obj_type == 'block': glutSolidCube(2) elif obj_type == 'key' or obj_type == 'chest': if not obj.get_has(): glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 75) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], .5]) glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [.4, .4, .4, .7]) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [.9, .9, .9, .6]) self.makeobj(obj.get_type()) elif obj_type == 'zombie': glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 75) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], .5]) glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [.4, .4, .4, .7]) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [.9, .9, .9, .6]) zomX, zomY, zomZ = pos # We already grabbed pos. self.makeobj(obj.get_type()) elif obj_type == 'chest': glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 75) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], .5]) glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [.4, .4, .4, .7]) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [.9, .9, .9, .6]) self.makeobj(obj.get_type()) elif obj_type == 'door': if obj.get_key().get_has(): glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], .2]) glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [.4, .4, .4, .2]) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [.9, .9, .9, .2]) else: glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 75) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [color[0], color[1], color[2], .5]) glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [.4, .4, .4, .7]) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [.9, .9, .9, .6]) glRotate(obj.get_rotation(), 0, 1, 0) self.makeobj(obj.get_type()) else: glutSolidSphere(2, 40, 40) glPopMatrix() glDisable(GL_BLEND) Overlay.draw_overlay(self.camera, self.soundboard.paused) if self.camera.key_timeout > 0: Overlay.draw_text("Got a key!") self.camera.key_timeout -= 1 if self.camera.dead_timeout > 0: Overlay.draw_text("A zombie killed you!") self.camera.dead_timeout -= 1 if self.camera.treasure_timeout > 0: Overlay.draw_text("Got treasure!") self.camera.treasure_timeout -= 1 glutSwapBuffers()