def __init__(self):
        self.config = assets.getData("config.json")
        self.scale = self.config["scale"]
        self.width = metrics.SCREEN_WIDTH * self.scale
        self.height = metrics.SCREEN_HEIGHT * self.scale

        assets.setVolume(float(self.config["volume"]) / 100.0)

        fullscreen = 0
        if self.config["fullscreen"]:
            fullscreen = pygame.FULLSCREEN

        # Changing some of the mixer settings reduces the delay before playing sound effects
        pygame.mixer.pre_init(44100, -16, 2, 2048)
        pygame.init()
        pygame.display.set_caption("Gunmetal Gray")  # TODO: Come up with better name
        #pygame.display.set_icon(pygame.image.load(assets.path("graphics/icon.png")))
        pygame.mouse.set_visible(False)
        self.display = pygame.display.set_mode((self.width, self.height), pygame.HWSURFACE | pygame.DOUBLEBUF | fullscreen)
        self.surface = pygame.Surface((metrics.SCREEN_WIDTH, metrics.SCREEN_HEIGHT), pygame.HWSURFACE)

        self.clock = pygame.time.Clock()

        inputs.init(self.config)

        statemgr.init()
        statemgr.switch("title")

        self.playing = True

        self.debug_mode = False
示例#2
0
    logs_basedir = "%s/logs" % basedir
    if not os.path.exists(logs_basedir):
        os.mkdir(logs_basedir)
    logfile = "%s/piautomator.log" % logs_basedir
    formatting = logging.Formatter(log_format, None)
    handler = RotatingFileHandler(logfile, maxBytes=1024 * 1024 * 100, backupCount=3)
    handler.setFormatter(formatting)
    logging.root.addHandler(handler)
else:
    logging.basicConfig(format=log_format)

# Initialize all components
global automation_context
automation_context = AutomationContext(config)
automation_context.receivers = receivers.init(automation_context)
automation_context.inputs = inputs.init(automation_context)
automation_context.rule_context = rules.init(automation_context)

automation_context.start()

# Setup the handler that will terminate our event loops.
global running
running = True

def signal_handler(signal, frame):
    global running
    running = False
    automation_context.stop()
    print 'Terminated'

示例#3
0
import graphics
import physics
import inputs
import logic
import ai
import roster
from player import Player

roster.init()
inputs.init()
graphics.init()

def reset():
	global players, AIs

	local_player_input = inputs.PlayerInputs()
	ai_input = inputs.PlayerInputs()
	players = (Player(200.0, 500.0, local_player_input), Player(600.0, 500.0, ai_input))

	inputs.reset(local_player_input)
	graphics.reset(players)
	physics.init(players)
	logic.init(players)

	AIs = roster.get_next_players()

reset()
iterations = 0
while True:
	iterations += 1
示例#4
0
        os.mkdir(logs_basedir)
    logfile = "%s/piautomator.log" % logs_basedir
    formatting = logging.Formatter(log_format, None)
    handler = RotatingFileHandler(logfile,
                                  maxBytes=1024 * 1024 * 100,
                                  backupCount=3)
    handler.setFormatter(formatting)
    logging.root.addHandler(handler)
else:
    logging.basicConfig(format=log_format)

# Initialize all components
global automation_context
automation_context = AutomationContext(config)
automation_context.receivers = receivers.init(automation_context)
automation_context.inputs = inputs.init(automation_context)
automation_context.rule_context = rules.init(automation_context)

automation_context.start()

# Setup the handler that will terminate our event loops.
global running
running = True


def signal_handler(signal, frame):
    global running
    running = False
    automation_context.stop()
    print 'Terminated'
示例#5
0
def main():
    game = Game(8)

    inputs.init()
    game_loop(game)
    inputs.close()