100 lines
3.5 KiB
Python
Executable File
100 lines
3.5 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# This file is part of A Robot's Conundrum.
|
|
#
|
|
# A Robot's Conundrum is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by the Free
|
|
# Software Foundation, either version 3 of the License, or (at your option) any
|
|
# later version.
|
|
#
|
|
# A Robot's Conundrum is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
# details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along with
|
|
# A Robot's Conundrum. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
|
|
#
|
|
# a-robots-conundrum
|
|
# --------------------
|
|
# date created : Tue Aug 7 2012
|
|
# copyright : (C) 2012 Sakse Dalum
|
|
# maintained by : Sakse Dalum <don_s@hongabar.org>
|
|
|
|
"""
|
|
The main entrance point.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
|
|
import sys
|
|
import os
|
|
import pygame
|
|
|
|
# Initialise all Pygame modules
|
|
pygame.init()
|
|
# Check if critical Pygame modules were initialised properly before continuing.
|
|
module_names = ['display', 'mixer']
|
|
for module_name in module_names:
|
|
module = getattr(pygame, module_name)
|
|
if not module.get_init():
|
|
print("Failed to initialise %s module." % module_name)
|
|
sys.exit()
|
|
if not pygame.image.get_extended():
|
|
print("Pygame does not support extended image support.")
|
|
sys.exit()
|
|
|
|
import argparse
|
|
|
|
import arobotsconundrum
|
|
|
|
if __name__ == '__main__':
|
|
# Get the absolute path for the directory of the script.
|
|
directory = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
# Parse command-line arguments
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('-r',
|
|
'--resolution',
|
|
type=str,
|
|
default="800x600",
|
|
help="specifies the resolution of the game")
|
|
parser.add_argument('-f',
|
|
'--fullscreen',
|
|
action='store_const',
|
|
const=True,
|
|
default=False,
|
|
help="toggles fullscreen")
|
|
parser.add_argument('-n',
|
|
'--disable-music',
|
|
action='store_const',
|
|
const=True,
|
|
default=False,
|
|
help="disables in-game music")
|
|
parser.add_argument('-l',
|
|
'--level',
|
|
type=int,
|
|
help="go directly to level n")
|
|
|
|
args = vars(parser.parse_args())
|
|
resolution = tuple([int(x) for x in args['resolution'].split('x')])
|
|
fullscreen = bool(args['fullscreen'])
|
|
disable_music = bool(args['disable_music'])
|
|
goto_level = args['level']
|
|
|
|
print("Display width: %d, display height: %d, fullscreen: %s"
|
|
% (resolution[0], resolution[1], fullscreen))
|
|
|
|
icon = os.path.join(directory, "resources", "graphics", "icon.png")
|
|
pygame.display.set_icon(pygame.image.load(icon))
|
|
pygame.display.set_caption("A Robot's Conundrum")
|
|
|
|
window = pygame.display.set_mode(resolution,
|
|
pygame.FULLSCREEN if fullscreen else 0)
|
|
|
|
game = arobotsconundrum.game.Game(window, directory, disable_music,
|
|
initial_goto_level=goto_level)
|
|
game.start()
|