a-robots-conundrum/robotgame.py

83 lines
2.7 KiB
Python
Raw Normal View History

2012-08-07 11:47:55 +02:00
#!/usr/bin/env python
# This file is part of ROBOTGAME
#
# ROBOTGAME 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.
#
# ROBOTGAME 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
2012-08-07 13:21:01 +02:00
# ROBOTGAME. If not, see <http://www.gnu.org/licenses/>.
2012-08-07 11:47:55 +02:00
#
# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
#
# robotgame.py
# --------------------
# date created : Tue Aug 7 2012
# copyright : (C) 2012 Sakse Dalum
# maintained by : Sakse Dalum <don_s@hongabar.org>
2012-08-07 13:21:01 +02:00
"""
The main entrance point.
"""
from __future__ import print_function
import sys
2012-08-07 16:18:06 +02:00
import os
2012-08-07 13:21:01 +02:00
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()
2012-08-07 15:40:42 +02:00
if not pygame.image.get_extended():
print("Pygame does not support extended image support.")
sys.exit()
2012-08-07 13:21:01 +02:00
import argparse
2012-08-07 11:47:55 +02:00
import robotgame
2012-08-07 13:21:01 +02:00
if __name__ == '__main__':
# 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="specifies the resolution of the game")
args = vars(parser.parse_args())
resolution = tuple([int(x) for x in args['resolution'].split('x')])
fullscreen = bool(args['fullscreen'])
print("Display width: %d, display height: %d, fullscreen: %s"
% (resolution[0], resolution[1], fullscreen))
icon = os.path.abspath(os.path.join("resources", "graphics", "icon.png"))
pygame.display.set_icon(pygame.image.load(icon))
pygame.display.set_caption("ROBOTGAME")
2012-08-07 13:21:01 +02:00
window = pygame.display.set_mode(resolution,
pygame.FULLSCREEN if fullscreen else 0)
game = robotgame.game.Game(window)
game.start()