本文整理汇总了Python中Resource.Resource.fileName方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.fileName方法的具体用法?Python Resource.fileName怎么用?Python Resource.fileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource.Resource
的用法示例。
在下文中一共展示了Resource.fileName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameEngine
# 需要导入模块: from Resource import Resource [as 别名]
# 或者: from Resource.Resource import fileName [as 别名]
class GameEngine(Engine):
"""The main game engine."""
def __init__(self, config = None):
"""
Constructor.
@param config: L{Config} instance for settings
"""
if not config:
config = Config.load()
self.config = config
fps = self.config.get("video", "fps")
tickrate = self.config.get("engine", "tickrate")
Engine.__init__(self, fps = fps, tickrate = tickrate)
pygame.init()
self.title = _("Frets on Fire")
self.restartRequested = False
self.handlingException = False
self.video = Video(self.title)
self.audio = Audio()
Log.debug("Initializing audio.")
frequency = self.config.get("audio", "frequency")
bits = self.config.get("audio", "bits")
stereo = self.config.get("audio", "stereo")
bufferSize = self.config.get("audio", "buffersize")
self.audio.pre_open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)
pygame.init()
self.audio.open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)
Log.debug("Initializing video.")
width, height = [int(s) for s in self.config.get("video", "resolution").split("x")]
fullscreen = self.config.get("video", "fullscreen")
multisamples = self.config.get("video", "multisamples")
self.video.setMode((width, height), fullscreen = fullscreen, multisamples = multisamples)
# Enable the high priority timer if configured
if self.config.get("engine", "highpriority"):
Log.debug("Enabling high priority timer.")
self.timer.highPriority = True
viewport = glGetIntegerv(GL_VIEWPORT)
h = viewport[3] - viewport[1]
w = viewport[2] - viewport[0]
geometry = (0, 0, w, h)
self.img = ImgContext(geometry)
glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3]))
self.input = Input()
self.view = View(self, geometry)
self.resizeScreen(w, h)
self.resource = Resource(Version.dataPath())
self.server = None
self.sessions = []
self.mainloop = self.loading
# Load game modifications
Mod.init(self)
theme = Config.load(self.resource.fileName("theme.ini"))
Theme.open(theme)
# Make sure we are using the new upload URL
if self.config.get("game", "uploadurl").startswith("http://kempele.fi"):
self.config.set("game", "uploadurl", "http://fretsonfire.sourceforge.net/play")
self.addTask(self.audio, synchronized = False)
self.addTask(self.input, synchronized = False)
self.addTask(self.view)
self.addTask(self.resource, synchronized = False)
self.data = Data(self.resource, self.img)
self.input.addKeyListener(FullScreenSwitcher(self), priority = True)
self.input.addSystemEventListener(SystemEventHandler(self))
self.debugLayer = None
self.startupLayer = None
self.loadingScreenShown = False
Log.debug("Ready.")
def setStartupLayer(self, startupLayer):
"""
Set the L{Layer} that will be shown when the all
the resources have been loaded. See L{Data}
@param startupLayer: Startup L{Layer}
"""
self.startupLayer = startupLayer
def isDebugModeEnabled(self):
return bool(self.debugLayer)
def setDebugModeEnabled(self, enabled):
#.........这里部分代码省略.........
示例2: GameEngine
# 需要导入模块: from Resource import Resource [as 别名]
# 或者: from Resource.Resource import fileName [as 别名]
class GameEngine(object):
"""The main game engine."""
def __init__(self, config = None):
"""
Constructor.
@param config: L{Config} instance for settings
"""
if not config:
config = Config.load()
self.config = config
self.fps = self.config.get("video", "fps")
pygame.init()
self.title = _("Frets on Fire")
self.restartRequested = False
self.handlingException = False
self.video = Video(self.title)
self.audio = Audio()
log.debug("Initializing audio.")
frequency = self.config.get("audio", "frequency")
bits = self.config.get("audio", "bits")
stereo = self.config.get("audio", "stereo")
bufferSize = self.config.get("audio", "buffersize")
self.audio.pre_open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)
pygame.init()
self.audio.open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)
log.debug("Initializing video.")
width, height = [int(s) for s in self.config.get("video", "resolution").split("x")]
fullscreen = self.config.get("video", "fullscreen")
multisamples = self.config.get("video", "multisamples")
self.video.setMode((width, height), fullscreen = fullscreen, multisamples = multisamples)
viewport = glGetIntegerv(GL_VIEWPORT)
h = viewport[3] - viewport[1]
w = viewport[2] - viewport[0]
geometry = (0, 0, w, h)
self.img = ImgContext(geometry)
glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3]))
self.input = Input()
self.view = View(self, geometry)
self.resizeScreen(w, h)
self.resource = Resource(Version.dataPath())
self.server = None
self.mainloop = self.loading
# Load game modifications
Mod.init(self)
theme = Config.load(self.resource.fileName("theme.ini"))
Theme.open(theme)
# Make sure we are using the new upload URL
if self.config.get("game", "uploadurl").startswith("http://kempele.fi"):
self.config.set("game", "uploadurl", "http://fretsonfire.sourceforge.net/play")
self.running = True
self.timer = FpsTimer()
self.tickDelta = 0
self.task = TaskEngine(self)
self.task.addTask(self.input, synced = False)
self.task.addTask(self.view)
self.task.addTask(self.resource, synced = False)
self.data = Data(self.resource, self.img)
self.input.addKeyListener(FullScreenSwitcher(self), priority = True)
self.input.addSystemEventListener(SystemEventHandler(self))
self.debugLayer = None
self.startupLayer = None
self.loadingScreenShown = False
log.debug("Ready.")
def enableGarbageCollection(self, enabled):
"""
Enable or disable garbage collection whenever a random garbage
collection run would be undesirable. Disabling the garbage collector
has the unfortunate side-effect that your memory usage will skyrocket.
"""
if enabled:
gc.enable()
else:
gc.disable()
def collectGarbage(self):
"""
Run a garbage collection run.
"""
gc.collect()
#.........这里部分代码省略.........