einstein/einsteingame/main.py

97 lines
2.2 KiB
Python
Raw Normal View History

2015-10-04 12:34:09 +00:00
#! /usr/bin/env python3
from random import randint
import os
import sys
import gi
gi.require_version('Clutter', '1.0')
from gi.repository import Clutter
2015-10-30 16:42:05 +00:00
from gi.repository import GLib
2015-10-04 12:34:09 +00:00
2015-11-04 12:46:33 +00:00
from .messages import msg
from .resources import ResourcesCollection, resources
2015-11-03 16:38:03 +00:00
from .utils import ensureDirExists
2015-10-04 12:34:09 +00:00
win32 = False
apple = False
2015-10-30 16:42:05 +00:00
developer = True
2015-10-04 12:34:09 +00:00
2015-10-30 16:42:05 +00:00
PREFIX = '/usr'
2015-11-04 12:46:33 +00:00
2015-10-04 12:34:09 +00:00
# stage = Clutter.Stage()
# stage.connect('destroy', lambda x: Clutter.main_quit())
# stage.title = 'Test'
# background = Clutter.Color()
# background.red, background.blue, background.green, background.alpha = 10, 10, 10, 255
# stage.set_background_color(background)
#
# actorRectangle = Clutter.Actor()
# actorRectangle.set_size(100, 100)
# actorRectangle.set_position(100, 100)
# rectColor = Clutter.Color()
# rectColor.red, rectColor.blue, rectColor.green, rectColor.alpha = 100, 100, 100, 255
# actorRectangle.set_background_color(rectColor)
#
# def changeRectanglePosition(x, y):
# sizex, sizey = stage.get_size()
# newx = randint(0, sizex)
# newy = randint(0, sizey)
# actorRectangle.set_position(newx, newy)
#
# actorRectangle.set_reactive(True)
# actorRectangle.connect('enter-event', changeRectanglePosition)
#
# stage.add_actor(actorRectangle)
# stage.show()
# Clutter.main()
2015-11-04 12:46:33 +00:00
stage = None
sound = None
def initScreen():
Clutter.init()
stage = Clutter.Stage()
stage.connect('destroy', lambda x: Clutter.main_quit())
stage.set_size(800, 600)
stage.title = 'Einstein'
def initAudio():
# sound = Sound()
pass
2015-10-04 12:34:09 +00:00
def loadResources(selfPath):
dirs = []
if win32:
dirs.append(getStorage().get("path", "") + "\\res")
elif apple:
dirs.append(getResourcesPath(selfPath))
else:
dirs.append(PREFIX + "/share/einstein/res")
dirs.append(os.environ["HOME"] + "/.einstein/res")
2015-10-30 16:42:05 +00:00
if developer:
dirs.append(os.path.dirname(os.path.dirname(__file__)))
2015-10-04 12:34:09 +00:00
dirs.append("res")
dirs.append(".")
resources = ResourcesCollection(dirs)
2015-11-04 12:46:33 +00:00
msg.load(resources)
2015-10-04 12:34:09 +00:00
2015-11-04 16:30:48 +00:00
return resources
2015-11-03 16:38:03 +00:00
def main(script, *args):
2015-10-04 12:34:09 +00:00
ensureDirExists(os.environ["HOME"] + "/.einstein")
2015-11-04 16:30:48 +00:00
resources = loadResources(sys.argv[0])
initScreen()
initAudio()
2015-11-04 12:46:33 +00:00
# menu()
# getStorage().flush()
2015-11-04 16:30:48 +00:00
resources.dump()