From 21d978f459015387234b5dde71233912e02c7f5f Mon Sep 17 00:00:00 2001 From: Le_dahut Date: Thu, 22 May 2014 20:29:26 +0200 Subject: [PATCH] =?UTF-8?q?-Creation=20de=20deux=20classes=20pour=20les=20?= =?UTF-8?q?deux=20fen=C3=AAtre=20:=20menu=20principal=20et=20plateau=20de?= =?UTF-8?q?=20jeu.=20-R=C3=A9cup=C3=A9ration=20des=20fonction=20de=20lectu?= =?UTF-8?q?re=20et=20d'=C3=A9criture=20de=20donn=C3=A9es=20dans=20les=20"s?= =?UTF-8?q?helves".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WireChem.py | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/WireChem.py b/WireChem.py index 07bec2e..ecc3d09 100644 --- a/WireChem.py +++ b/WireChem.py @@ -32,6 +32,100 @@ from pyglet import image from os.path import expanduser ''' *********************************************************************************************** ''' -''' Lancement & initialisation ''' - +''' Fonctions d'initialisation ''' + +def sync(): + global Uworlds,finished + write(gethome()+"/dbdata",["Uworlds","finished"]) + +def verifyhome(): + global Uworlds,finished + if not os.path.exists(gethome()): + os.makedirs(gethome()) + if not os.path.exists(gethome()+"/dbdata"): + Uworlds=[[{0:0}]] + finished=[(0,0)] + sync() + +def gethome(): + home = expanduser("~")+"/.wirechem" + return home + +def write(afile,var): + d=shelve.open(afile,writeback=True) + for k in var: + d[k]=copy.deepcopy(globals()[k]) + d.sync() + d.close() + +def read(afile): + d=shelve.open(afile,writeback=True) + for k in d.keys(): + globals()[k]=copy.deepcopy(d[k]) + d.close() + +def load(d): + for k in d.keys(): + if k[0]!="_": + globals()[k]=copy.deepcopy(d[k]) + +def reference(var,noms): + if len(noms)==2: + for y in range(len(var)): + for x in range(len(var[y])): + var[y][x][noms[0]]=y + var[y][x][noms[1]]=x + else: + for x in range(len(var[y])): + var[x][y][noms[0]]=x + +def duplicateref(d): + for k in d.keys(): + d[d[k]['nom']]=d[k] + +''' *********************************************************************************************** ''' +''' Gestion du plateau de jeu ''' + +class game(pyglet.window.Window): + def __init__(self, *args, **kwargs): + super(game, self).__init__(resizable=True, fullscreen=False, visible=True, caption="Wirechem: The new chemistry game") + self.batch = pyglet.graphics.Batch() + self.clocks=[clock.schedule(self.draw)] + self.labels = [] + + def draw(self,dt): + glClearColor(0,0,0,255) + self.clear() + +''' *********************************************************************************************** ''' +''' Gestion du menu principal ''' + +class menu(pyglet.window.Window): + def __init__(self, *args, **kwargs): + super(menu, self).__init__(resizable=True, fullscreen=False, visible=True, caption="Wirechem: The new chemistry game") + self.batch = pyglet.graphics.Batch() + self.clocks=[clock.schedule(self.draw)] + + + def draw(self,dt): + glClearColor(0,0,0,255) + self.clear() + self.batch.draw() + +''' *********************************************************************************************** ''' +''' Initialisation ''' + +glEnable(GL_BLEND); +'''glEnable(GL_LINE_SMOOTH); +glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);''' +glEnable(GL_LINE_STIPPLE) +glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +menu_principal = menu(resizable=True) +pyglet.app.run() + + + + + +