commit 2763399ce23bb9bb5c47386bc97a697a6550466e Author: Le_dahut Date: Fri Jan 17 00:20:59 2014 +0100 Version originale, premier suivi de version dans GIT diff --git a/WireChem.py b/WireChem.py new file mode 100644 index 0000000..498f282 --- /dev/null +++ b/WireChem.py @@ -0,0 +1,1151 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import pyglet +import copy +import csv +import random +import time +import operator +from pyglet.gl import * +from pyglet.window import mouse +from pyglet.window import key +from pyglet import clock +from pyglet import image + + +''' ************************************************************************************************ ''' +''' Initialisation ''' + +def loaditems(n,file): + global items + with open(file, 'rb') as f: + liste=list(csv.reader(f,delimiter=';')) + for i in range(1,len(liste)): + items[liste[i][0]]={} + for j in range(1,len(liste[i])): + if liste[i][j][:1]=="#": + items[liste[i][0]][liste[0][j]]=int(liste[i][j][1:]) + elif liste[i][j][:1]=="[": + atemp=liste[i][j][1:-1].split(",") + items[liste[i][0]][liste[0][j]]=[int(atemp[k]) for k in range(len(atemp))] + elif liste[i][j][:1]=="{": + atemp=items[liste[i][0]][liste[0][j]]=liste[i][j][1:-1].split(",") + items[liste[i][0]][liste[0][j]]=[atemp[k] for k in range(len(atemp))] + elif liste[i][j][:2]=="0x": + items[liste[i][0]][liste[0][j]]=int(liste[i][j][2:],16) + elif liste[i][j][:1]=="&": + items[liste[i][0]][liste[0][j]]=float(liste[i][j][1:]) + elif liste[i][j][:1]=="@": + items[liste[i][0]][liste[0][j]]=items[liste[i][j][1:]] + else: + items[liste[i][0]][liste[0][j]]=liste[i][j] + if n!=0: + items[liste[i][0]]['value']=n+i-1 + items[items[liste[i][0]]['value']]=liste[i][0] + f.close() + return len(liste)-1 + +def initgrid(x,y): + global sizeworld,finished,allcout,selected,world,level,over,mousel,mouser,mousem,sizex,sizey,world_old,world_new,world_art,items,direction,zoom,play,stat,cycle,cout,thecout,rayon,unroll,debug,temp,decx,decy,nrj,tech,victory,current,names,thecolors,maxnrj,maxrayon,maxcycle,maxtemp,nom,descriptif,element + + ''' Directions des electrons en fonction de la position de la queue ''' + direction = {} + direction[(-1,-1)]=[(+1,+1),(+1,+0),(+0,+1),(+1,-1),(-1,+1),(+0,-1),(-1,+0),(-1,-1)] + direction[(-1,+0)]=[(+1,+0),(+1,-1),(+1,+1),(+0,-1),(+0,+1),(-1,-1),(-1,+1),(-1,+0)] + direction[(-1,+1)]=[(+1,-1),(+0,-1),(+1,+0),(-1,-1),(+1,+1),(-1,+0),(+0,+1),(-1,+1)] + direction[(+0,+1)]=[(+0,-1),(-1,-1),(+1,-1),(-1,+0),(+1,+0),(-1,+1),(+1,+1),(+0,+1)] + direction[(+0,-1)]=[(+0,+1),(+1,+1),(-1,+1),(+1,+0),(-1,+0),(+1,-1),(-1,-1),(+0,-1)] + direction[(+1,-1)]=[(-1,+1),(+0,+1),(-1,+0),(+1,+1),(-1,-1),(+1,+0),(+0,-1),(+1,-1)] + direction[(+1,+0)]=[(-1,+0),(-1,+1),(-1,-1),(+0,+1),(+0,-1),(+1,+1),(+1,-1),(+1,+0)] + direction[(+1,+1)]=[(-1,-1),(-1,+0),(+0,-1),(-1,+1),(+1,-1),(+0,+1),(+1,+0),(+1,+1)] + items = {} + sizeworld=loaditems(int("0x40000", 16),"data/worlds.dat") + loaditems(int("0x30000", 16),"data/elements2.dat") + loaditems(int("0x10000", 16),"data/menus2.dat") + loaditems(int("0x20000", 16),"data/menus.dat") + loaditems(0,"data/elements.dat") + + ''' Variables globales ''' + sizex=x + sizey=y + zoom=25 + stat=[0,0,0,0,0,0,0,0] + nom=descriptif=element='H' + names=["e","e","q","e","e","e","e","K","L","M","N","n","p"] + thecolors=[items['headb2']['color'],items['headb']['color'],items['headp']['color'],items['head']['color'],items['head2']['color'],items['headr']['color'],items['headr2']['color'],items['headb']['color'],items['headb']['color'],items['headb']['color'],items['headb']['color'],items['neut']['color'],items['prot']['color']] + victory=[0,0,0,0,0,0,0,1,0,0,0,1,1] + current=[0,0,0,0,0,0,0,0,0,0,0,0,0] + finished=[] + mousel=4 + mouser=0 + mousem=3 + maxnrj=maxrayon=maxcycle=maxtemp=99999 + allcout=thecout=world=over=play=cycle=rayon=temp=cout=decx=decy=unroll=nrj=debug=0 + selected=level=-1 + tech=9 + world_art = [[items['nothing']['value'] for y in range(sizey)] for x in range(sizex)] + world_new = [[items['nothing']['value'] for y in range(sizey)] for x in range(sizex)] + + +''' *********************************************************************************************** ''' +''' Sauvegarde/Restauration ''' + +'''format nom,element,descriptif,debug,zoom,decx,decy,tech,victory ''' + +def readpref(file): + global finished + with open(file, 'rb') as f: + try: + finished=list(csv.reader(f,delimiter=';'))[0] + f.close() + except: + print "no" + +def writepref(file): + global finished + with open(file, 'wb') as f: + writer = csv.writer(f, delimiter=';', quotechar='', quoting=csv.QUOTE_NONE) + writer.writerow(finished) + f.close() + +def readlittlegrid(file,key): + with open(file, 'rb') as f: + liste=list(csv.reader(f,delimiter=';')) + items[key]['nom']=liste[0][0] + items[key]['element']=liste[0][1] + items[key]['description']=liste[0][2] + items[key]['tech']=int(liste[0][7]) + items[key]['cout']=int(liste[0][8]) + victemp=liste[0][9][1:len(liste[0][9])-1].split(",") + items[key]['victory']=[int(victemp[k]) for k in range(len(victemp))] + items[key]['maxcycle']=int(liste[0][15]) + items[key]['maxnrj']=int(liste[0][16]) + items[key]['maxrayon']=int(liste[0][17]) + items[key]['maxtemp']=int(liste[0][18]) + f.close() + +def readcondgrid(file): + global current,cycle,nrj,rayon,temp + with open(file, 'rb') as f: + liste=list(csv.reader(f,delimiter=';')) + curtemp=liste[0][10][1:len(liste[0][10])-1].split(",") + current=[int(curtemp[k]) for k in range(len(curtemp))] + cycle=int(liste[0][11]) + nrj=int(liste[0][12]) + rayon=int(liste[0][13]) + temp=int(liste[0][14]) + f.close() + +def readgrid(file): + global unroll,mousel,mousem,mouser,cout,selected,sizex,sizey,world_old,world_new,world_art,items,zoom,play,stat,cycle,nrj,rayon,tech,decx,decy,unroll,stat,victory,current,temp,debug,nom,descriptif,element,maxnrj,maxrayon,maxcycle,maxtemp + try: + with open(file, 'rb') as f: + liste=list(csv.reader(f,delimiter=';')) + sizey=(len(liste)-1)/2 + sizex=len(liste[1]) + nom=liste[0][0] + element=liste[0][1] + descriptif=liste[0][2] + debug=int(liste[0][3]) + zoom=int(liste[0][4]) + decx=int(liste[0][5]) + decy=int(liste[0][6]) + tech=int(liste[0][7]) + cout=int(liste[0][8]) + victemp=liste[0][9][1:len(liste[0][9])-1].split(",") + victory=[int(victemp[k]) for k in range(len(victemp))] + curtemp=liste[0][10][1:len(liste[0][10])-1].split(",") + current=[int(curtemp[k]) for k in range(len(curtemp))] + cycle=int(liste[0][11]) + nrj=int(liste[0][12]) + rayon=int(liste[0][13]) + temp=int(liste[0][14]) + maxcycle=int(liste[0][15]) + maxnrj=int(liste[0][16]) + maxrayon=int(liste[0][17]) + maxtemp=int(liste[0][18]) + world_new = [[int(liste[sizey-i][j]) for i in range(sizey)] for j in range(sizex)] + world_art = [[int(liste[-i-1][j]) for i in range(sizey)] for j in range(sizex)] + stat=[0,0,0,0,0,0,0,0] + unroll=over=0 + if tech<0: + items[items['setcopper']['value']]='setnothinga' + items[items['setfiber']['value']]='setnothinga' + items[items['setnothing']['value']]='setnothinga' + items[items['others']['value']]='setnothinga' + elif tech<2: + items[items['setcopper']['value']]='setcopper' + items[items['setfiber']['value']]='setnothinga' + items[items['setnothing']['value']]='setnothing' + items[items['others']['value']]='others' + else: + items[items['setcopper']['value']]='setcopper' + items[items['setfiber']['value']]='setfiber' + items[items['setnothing']['value']]='setnothing' + items[items['others']['value']]='others' + f.close() + infos() + return True + except IOError: + return False + +def writegrid(file): + global sizex,sizey,world_old,world_new,world_art,items,play,cycle,nom,element,descriptif,debug,zoom,decx,decy,tech,victory + with open(file, 'wb') as f: + writer = csv.writer(f, delimiter=';', quotechar='', quoting=csv.QUOTE_NONE) + writer.writerow([nom,element,descriptif,debug,zoom,decx,decy,tech,cout,str(victory),str(current),cycle,nrj,rayon,temp,maxcycle,maxnrj,maxrayon,maxtemp]) + for j in range(sizey): + writer.writerow([world_new[i][sizey-j-1] for i in range(sizex)]) + for j in range(sizey): + writer.writerow([wart(i,-j-1) for i in range(sizex)]) + f.close() + +''' *********************************************************************************************** ''' +''' Fonctions programmees ''' + +def menu(dt,leveler): + global level,over + level=leveler + over=0 + +def calculate(dt): + nextgrid() + +def refresh(dt): + global world,level + if player.source and player.source.video_format: + glColor3ub(255,255,255) + player.get_texture().blit(0,0) + return + if level!=-1: + drawgrid(zoom) + else: + drawworld() + +''' *********************************************************************************************** ''' +''' Affichage ''' + +def drawsquare(x,y,x2,y2,full,color): + glColor3ub(color[0],color[1],color[2]) + if full>0: + glBegin(GL_QUADS) + else: + glBegin(GL_LINE_LOOP) + glVertex2i(x,y) + glVertex2i(x2,y) + glVertex2i(x2,y2) + glVertex2i(x,y2) + glEnd() + +def drawsemisquare(x,y,x2,y2,color): + glColor3ub(color[0],color[1],color[2]) + glBegin(GL_LINES) + thezoom=y2-y + glVertex2i(x,y) + glVertex2i(x,y+thezoom/4) + glVertex2i(x,y) + glVertex2i(x+thezoom/4,y) + glVertex2i(x2,y2) + glVertex2i(x2,y2-thezoom/4) + glVertex2i(x2,y2) + glVertex2i(x2-thezoom/4,y2) + glVertex2i(x,y2) + glVertex2i(x,y2-thezoom/4) + glVertex2i(x,y2) + glVertex2i(x+thezoom/4,y2) + glVertex2i(x2,y) + glVertex2i(x2,y+thezoom/4) + glVertex2i(x2,y) + glVertex2i(x2-thezoom/4,y) + glEnd() + +def drawitdem(x,y,art,thezoom,activation): + if 'text' in art: + if art['activable']==0: + drawsquare(x+1,y+1,x+thezoom-1,y+thezoom-1,0,[255,255,255]) + label=pyglet.text.Label(art['text'].decode('utf-8'),font_name='Liberation Mono',font_size=thezoom,x=x+thezoom/10,y=y+thezoom/10,color=(art['color'][0],art['color'][1],art['color'][2],255)) + else: + drawsemisquare(x+1,y+1,x+thezoom-1,y+thezoom-1,[255,255,255]) + if activation!=0: + label=pyglet.text.Label(art['text'].decode('utf-8'),font_name='Liberation Mono',font_size=thezoom,x=x+thezoom/10,y=y+thezoom/10,color=(art['color'][0],art['color'][1],art['color'][2],55+200*activation/10)) + else: + label=pyglet.text.Label(art['text'].decode('utf-8'),font_name='Liberation Mono',font_size=thezoom,x=x+thezoom/10,y=y+thezoom/10,color=(255,255,255,255)) + label.draw() + +def drawstat(x,y,x2,y2,color): + global thecolors,stat + drawsquare(x,y,x2,y2,0,color) + oldx=x + for i in range(7): + if stat[7]>0: + newx=oldx+float(stat[i])*(x2-x)/stat[7] + else: + newx=oldx + drawsquare(int(oldx),y,int(newx),y2,1,thecolors[i]) + oldx=newx + label=pyglet.text.Label(str(stat[7]),font_size=24,x=x+(x2-x)/2-(len(str(stat[7])))*12,y=y-(y-24)/2,bold=False,italic=False,color=(255, 255, 255,255)) + label.draw() + +def drawvictory(x,y,x2,y2,color): + global thecolors,victory,current,names + '''size=(x2-x)/sum(victory[i] for i in range(len(victory)))''' + size=21 + for i in range(len(victory)): + if victory[i]>0: + drawsquare(x+size*i,y,x+size*(i+1),y2,1,thecolors[i]) + drawsquare(x+size*i,y,x+size*(i+1),y2,0,[90,90,90]) + drawsquare(x+size*i,y,x+size*(i+1),int(y+float(current[i])/victory[i]*(y2-y)),1,[0,0,0]) + if victory[i]-current[i]>=0: + label=pyglet.text.Label(str(victory[i]-current[i]),font_size=24,x=x+size*i,y=y,bold=False,italic=False,color=(255, 255, 255,255)) + label.draw() + label=pyglet.text.Label(names[i],font_size=10,x=x+size*i,y=y2-10,bold=False,italic=False,color=(255, 255, 255,255)) + label.draw() + +def drawtxt(x): + text="{font_name 'Liberation Mono'}{font_size 22}{color (255, 255, 255, 255)}"+x+"}".encode('utf8') + label=pyglet.text.layout.TextLayout(pyglet.text.decode_attributed(text),dpi=72,multiline=True,width=732,height=140) + label.x=8 + label.y=8 + label.draw() + +def drawworld(): + global selected,victory,finished + glClear(GL_COLOR_BUFFER_BIT) + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + drawsquare(740,148,1016,8,1,[40,40,40]) + drawsquare(8,148,1016,8,0,[90,90,90]) + glColor3ub(255,255,255) + pic=image.load("picture/logo.png") + pic.blit(185,win.height-200) + pic=image.load("picture/logo2.png") + pic.blit(45,win.height-160) + if selected==-2: + glColor3ub(255,0,0) + else: + glColor3ub(255,255,255) + pic=image.load("picture/exit2.png") + pic.blit(940,win.height-100) + if selected==-3: + glColor3ub(255,0,0) + else: + glColor3ub(255,255,255) + pic=image.load("picture/arrows.png") + pic.blit(840,150) + if selected==-4: + glColor3ub(255,0,0) + else: + glColor3ub(255,255,255) + pic=image.load("picture/arrows2.png") + pic.blit(920,150) + glColor3ub(255,255,255) + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world: + glBegin(GL_LINES) + for n in ele['validate']: + if items[n]['world']==world: + glVertex2i(ele['coordx']+50,ele['coordy']+50) + glVertex2i(items[n]['coordx']+50,items[n]['coordy']+50) + glVertex2i(ele['coordx']+51,ele['coordy']+50) + glVertex2i(items[n]['coordx']+51,items[n]['coordy']+50) + glVertex2i(ele['coordx']+50,ele['coordy']+51) + glVertex2i(items[n]['coordx']+50,items[n]['coordy']+51) + glVertex2i(ele['coordx']+51,ele['coordy']+51) + glVertex2i(items[n]['coordx']+51,items[n]['coordy']+51) + glEnd() + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world: + readlittlegrid(ele['file'],items[int("0x40000",16)+i]) + if items[int("0x40000",16)+i] not in finished and not (ele['world']==0 and ele['grid']==0): + glColor3ub(60,60,60) + acolor=(90,90,90,255) + elif selected!=ele: + glColor3ub(255,120+int(ele['coordx']/1024.0*135),155+int(ele['coordx']/1024.0*100)) + acolor=(90,90,90,255) + else: + acolor=(255,255,255,255) + drawtxt(ele['description'].decode('utf-8')) + glColor3ub(255,255,255) + if ele['cout']>0: + pic=image.load('picture/cout.png') + pic.blit(740,110) + label=pyglet.text.Label(str(ele['cout']),font_size=15,x=780,y=120,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + if ele['maxcycle']<90000: + pic=image.load('picture/cycle.png') + pic.blit(740,65) + label=pyglet.text.Label(str(ele['maxcycle']),font_size=15,x=780,y=75,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + if ele['tech']>0: + pic=image.load('picture/tech.png') + pic.blit(940,110) + label=pyglet.text.Label(str(ele['tech']),font_size=15,x=980,y=120,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + if ele['maxrayon']<90000: + pic=image.load('picture/rayon.png') + pic.blit(940,65) + label=pyglet.text.Label(str(ele['maxrayon']),font_size=15,x=970,y=75,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + if ele['maxtemp']<90000: + pic=image.load('picture/temp.png') + pic.blit(850,110) + label=pyglet.text.Label(str(ele['maxtemp']),font_size=15,x=875,y=120,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + if ele['maxnrj']<90000: + pic=image.load('picture/nrj.png') + pic.blit(850,65) + label=pyglet.text.Label(str(ele['maxnrj']),font_size=15,x=875,y=75,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + victory=ele['victory'] + drawvictory(742,12,1016,50,[40,40,40]) + glColor3ub(255,0,0) + pic=image.load("picture/levels2.png") + pic.blit(ele['coordx'],ele['coordy']) + label=pyglet.text.Label(ele['element'],font_name='Liberation Mono',font_size=15,x=ele['coordx']+50,y=ele['coordy']+70,bold=True,italic=False,color=(int(ele['coordx']/1024.0*150), int(ele['coordx']/1024.0*150), int(ele['coordx']/1024.0*150),255)) + label.draw() + calc=(len(ele['nom'])*16-76)/2 + drawsquare(ele['coordx']+28-calc,ele['coordy']+2,ele['coordx']+28-calc+len(ele['nom'])*15,ele['coordy']-18,1,[40,int(ele['coordx']/1024.0*135),int(ele['coordx']/1024.0*100)]) + label=pyglet.text.Label(ele['nom'].decode('utf-8'),font_name='Liberation Mono',font_size=16,x=ele['coordx']+38-calc,y=ele['coordy']-15,bold=True,italic=False,color=acolor) + label.draw() + +def drawgrid(zoom): + global temp,debug,over,allcout,play + glClear(GL_COLOR_BUFFER_BIT) + drawsquare(decx-1+zoom,decy-1+zoom,decx+zoom*(sizex-1)+1,decy+zoom*(sizey-1)+2,0,[255,255,255]) + if play>0: + drawsquare(decx-1+zoom,decy-1+zoom,decx+zoom*(sizex-1)+1,decy+zoom*(sizey-1)+2,0,[255,0,0]) + drawsquare(decx-2+zoom,decy-2+zoom,decx+zoom*(sizex-1)+2,decy+zoom*(sizey-1)+3,0,[255,0,0]) + for x in range(1,sizex-1): + if x*zoom+decx>win.width: break + for y in range(1,sizey-1): + if y*zoom+decy>win.height: break + drawsquare(x*zoom+decx,y*zoom+decy,(x+1)*zoom+decx,(y+1)*zoom+decy,1,items[items[world_new[x][y]]]['color']) + drawitdem(x*zoom+decx,y*zoom+decy,items[items[wart(x,y)]],zoom,getactive(x,y)) + drawsquare(0,win.height,win.width,win.height-50,1,[40,40,40]) + drawsquare(0,50,win.width,0,1,[40,40,40]) + if unroll!=0: + if debug==1: + nbelements=44 + else: + nbelements=29 + size=win.width/nbelements + drawsquare(0,57+size,win.width,0,1,[40,40,40]) + cat=65555 + for i in range(nbelements): + art=items[items[int("0x30000",16)+i]] + if art['tech']<=tech: + drawitdem(10+i*size,55,items[items[int("0x30000",16)+i]],size-6,10) + if art['cat']!=cat: + drawsquare(7+i*size,55,8+i*size,55+size,0,[90,90,90]) + cat=art['cat'] + drawsquare(615,win.height-45,655,win.height-5,1,[255,255,255]) + label=pyglet.text.Label(element,font_size=20,x=636-len(element)*10,y=win.height-35,bold=False,italic=False,color=(0, 0, 0,255)) + label.draw() + if tech>3: + for i in range(4): + glColor3ub(255,255,255) + pic=image.load(items[items[int("0x10000",16)+i]]['icon']) + pic.blit(10+i*150,win.height-45) + label=pyglet.text.Label(str(eval(items[int("0x10000",16)+i])),font_size=24,x=50+i*150,y=win.height-29,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + label=pyglet.text.Label(str(eval("max"+items[int("0x10000",16)+i])),font_size=12,x=50+i*150,y=win.height-47,bold=True,italic=True,color=(110, 110, 110,255)) + label.draw() + drawvictory(660,win.height-45,1020,win.height-5,[90,90,90]) + for i in range(15): + glColor3ub(255,255,255) + if items[items[int("0x20000",16)+i]]['icon']=="/": + drawitdem(10+i*45,8,items[items[int("0x20000",16)+i]]['ref'],36,10) + elif items[items[int("0x20000",16)+i]]['icon']!="": + pic=image.load(items[items[int("0x20000",16)+i]]['icon']) + pic.blit(10+i*45,8) + else: + drawsquare(10+i*45,8,46+i*45,44,1,items[items[int("0x20000",16)+i]]['color']) + if i==11 or i==6: + drawsquare(5+i*45,8,6+i*45,44,0,[90,90,90]) + if i==1: + drawsquare(45+i*45,8,49+i*45,44,1,[0,0,0]) + drawsquare(45+i*45,8,49+i*45,44*10*len(str(play))/100,1,[255,0,0]) + if (mousel==i): + selectcolor=[255,0,0] + elif (mouser==i): + selectcolor=[0,255,0] + elif (mousem==i): + selectcolor=[0,0,255] + else: + selectcolor=[40,40,40] + drawsquare(10+i*45,8,46+i*45,44,0,selectcolor) + drawsquare(9+i*45,7,47+i*45,45,0,selectcolor) + drawsquare(5+15*45,8,6+15*45,44,0,[90,90,90]) + drawstat(10+15*45,8,46+(18)*45,44,[90,90,90]) + if tech>=0: + glColor3ub(255,255,255) + pic=image.load(items[items[int("0x10000",16)+4]]['icon']) + pic.blit(10+19*45,7) + if (cout-thecout)>0: + label=pyglet.text.Label(str(cout-thecout),font_size=15,x=46+19*45,y=18,bold=True,italic=False,color=(110, 110, 110,255)) + else: + label=pyglet.text.Label(str(cout-thecout),font_size=15,x=46+19*45,y=18,bold=True,italic=False,color=(255, 0, 0,255)) + label.draw() + if tech>0: + glColor3ub(255,255,255) + pic=image.load(items[items[int("0x10000",16)+5]]['icon']) + pic.blit(25+21*45,7) + label=pyglet.text.Label(str(tech),font_size=15,x=55+21*45,y=18,bold=True,italic=False,color=(110, 110, 110,255)) + label.draw() + if over>0: + label=pyglet.text.Label("GAME OVER",font_name='Liberation Mono',font_size=100,x=win.width/2-350,y=win.height/2-200,color=(255,255,255,255)) + label.draw() + msg=["Trop de matière reçue dans les senseurs","Les photons sont sortis du cadre de jeu","Colision de protons et de neutrons","Le canon a provoqué une collision","Vous avez généré trop de rayonements","Le nombre de cycle maximum a été atteint","La température est a un niveau inacceptable","Il n'y a plus d'energie disponible !"] + label=pyglet.text.Label(msg[over-1].decode('utf-8'),font_name='Liberation Mono',font_size=30,x=0,y=win.height/2-100,color=(255,255,255,255)) + label.draw() + if over<0: + label=pyglet.text.Label("VICTOIRE !",font_name='Liberation Mono',font_size=100,x=win.width/2-350,y=win.height/2-200,color=(255,255,255,255)) + label.draw() + label=pyglet.text.Label("Vous débloquez le/les niveaux suivant.".decode('utf-8'),font_name='Liberation Mono',font_size=30,x=0,y=win.height/2-100,color=(255,255,255,255)) + label.draw() + if allcout>0: + label=pyglet.text.Label("cout:"+str(allcout['cout']),font_name='Liberation Mono',font_size=10,x=950,y=win.height-20,color=(255,255,255,255)) + label.draw() + label=pyglet.text.Label("tech:"+str(allcout['tech']),font_name='Liberation Mono',font_size=10,x=950,y=win.height-40,color=(255,255,255,255)) + label.draw() +''' *********************************************************************************************** ''' +''' Fonctions liees aux menus ''' + +def raz(dummy1,dummy2,dummy3,dummy4): + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world and ele['grid']==level: + readgrid(ele['file']) + +def speed(x,y,dummy1,dummy2): + global play,zoom + if x==1980 and y==2: + play=float(play)*2 + else: + play=float(play)/2 + if play>=5: + play=0.01953125 + if play<0.01953125: + play=2.5 + clock.unschedule(calculate) + clock.schedule_interval(calculate,play) + +def others(x,y,dummy1,dummy2): + if x>=1 and y>=1 and x= 0: + world_art[x][y] = value + infos() + +def setnothinga(x,y,dummy1,dummy2): + infos() + +def setnothing(x,y,dummy1,dummy2): + if x>=1 and y>=1 and x=1 and y>=1 and x= 0: + world_new[x][y] = items['copper']['value'] + infos() + +def setfiber(x,y,dummy1,dummy2): + if x>=1 and y>=1 and x= 0: + world_new[x][y]=items['fiber']['value'] + infos() + +def levels(dummy1,dummy2,dummy3,dummy4): + global level,sizeworld + reallystop() + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world and ele['grid']==level: + writegrid(ele['file']+".user") + level=-1 + +def exits(dummy1,dummy2,dummy3,dummy4): + pyglet.app.exit() + +def run(dummy1,dummy2,dummy3,dummy4): + global play + if play>0: + reallystop() + else: + reallyrun() + +def move(dummy1,dummy2,dx,dy): + global decx,decy + decx=decx+dx + decy=decy+dy + +def screen(dummy1,dummy2,dummy3,dummy4): + if win.fullscreen: + win.set_fullscreen(fullscreen=False) + else: + win.set_fullscreen(fullscreen=True) + +def zoomm(x,y,dummy1,dummy2): + global zoom,decx,decy + if zoom>2: + decx=decx+2*x + decy=decy+2*y + zoom=zoom-2 + +def zoomp(x,y,dummy1,dummy2): + global zoom,decx,decy + decx=decx-2*x + decy=decy-2*y + zoom=zoom+2 + +''' *********************************************************************************************** ''' +''' Fonctions gestion du monde ''' + +def reallystop(): + global play,sizeworld,level + items['run']['icon']="picture/stop.png" + play=0 + clock.unschedule(calculate) + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world and ele['grid']==level: + readcondgrid(ele['file']) + erase() + retriern() + +def reallyrun(): + global play,sizeworld + play=0.15625 + items['run']['icon']="picture/run.png" + clock.schedule_interval(calculate,play) + +def retriern(): + for x in range(1,sizex-1): + for y in range(1,sizey-1): + art=wart(x,y) + typetri=items[art][:6] + if typetri=="triern": + acttri="" + idtri=items[art][8] + if len(items[art])==10: acttri=items[art][9] + world_art[x][y]=items['triern'+idtri+"-"+idtri+acttri]['value'] + +def swap(): + for dx,dy in direction: + if random.randint(0,100)>50: + temps=direction[(dx,dy)][1] + direction[(dx,dy)][1]=direction[(dx,dy)][2] + direction[(dx,dy)][2]=temps + if random.randint(0,100)>50: + temps=direction[(dx,dy)][3] + direction[(dx,dy)][3]=direction[(dx,dy)][4] + direction[(dx,dy)][4]=temps + if random.randint(0,100)>50: + temps=direction[(dx,dy)][5] + direction[(dx,dy)][5]=direction[(dx,dy)][6] + direction[(dx,dy)][6]=temps + +def gameover_ok(): + global over,level,sizeworld + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world and ele['grid']==level: + readcondgrid(ele['file']) + erase() + writegrid(ele['file']+".user") + clock.schedule_once(menu,2,level) + +def itsvictory_ok(): + global over,level,finished,sizeworld + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world and ele['grid']==level: + readcondgrid(ele['file']) + erase() + writegrid(ele['file']+".user") + finished.extend(ele['validate']) + writepref('data/pref.dat') + clock.schedule_once(menu,2,-1) + +def gameover(x): + global over + reallystop() + over=x + sound.queue(pyglet.resource.media("sound/gameover.mp3")) + sound.play() + +def itsvictory(): + global over + reallystop() + label=pyglet.text.Label("ViCTOIRE !",font_name='Liberation Mono',font_size=100,x=win.width/2-350,y=win.height/2-200,color=(255,255,255,255)) + over=-1 + sound.queue(pyglet.resource.media("sound/victoire.mp3")) + sound.play() + +def infos(): + global stat,sizex,sizey,cycle,thecout,victory,current + stat=[0,0,0,0,0,0,0,0] + thecout=0 + for x in range(1,sizex-1): + for y in range(1,sizey-1): + if world_new[x][y]==items['headb2']['value']: stat[0]=stat[0]+1 + if world_new[x][y]==items['headb']['value']: stat[1]=stat[1]+1 + if world_new[x][y]==items['headp']['value']: stat[2]=stat[2]+1 + if world_new[x][y]==items['head']['value']: stat[3]=stat[3]+1 + if world_new[x][y]==items['head2']['value']: stat[4]=stat[4]+1 + if world_new[x][y]==items['headr']['value']: stat[5]=stat[5]+1 + if world_new[x][y]==items['headr2']['value']: stat[6]=stat[6]+1 + if world_new[x][y]>=items['head']['value']: stat[7]=stat[7]+1 + if cycle!=0: desactive(x,y) + thecout=items[items[world_new[x][y]]]['cout']+items[items[wart(x,y)]]['cout']+thecout + tempvictoire=0 + for i in range(len(victory)): + if victory[i]-current[i]<0: + gameover(1) + break + tempvictoire=(victory[i]-current[i])|tempvictoire + if tempvictoire==0: itsvictory() + if rayon>maxrayon: gameover(5) + if cycle>maxcycle: gameover(6) + if temp>maxtemp: gameover(7) + if nrj>maxnrj: gameover(8) + +def erase(): + for x in range(1,sizex-1): + for y in range(1,sizey-1): + if world_new[x][y]==items['headp']['value'] or world_new[x][y]==items['tailp']['value']: + world_new[x][y]=items['fiber']['value'] + elif world_new[x][y]>=items['tail']['value']: + world_new[x][y]=items['copper']['value'] + elif world_new[x][y]>=items['prot']['value']: + world_new[x][y]=items['nothing']['value'] + +def wart(x,y): + return world_art[x][y] & int("0xFFFFFF",16) + +def getactive(x,y): + return (world_art[x][y] & int("0xFF000000",16))>>24 + +def isactive(x,y): + return world_art[x][y]>int("0xFFFFFF",16) + +def desactive(x,y): + if world_art[x][y]>int("0x1000000",16): + world_art[x][y]=world_art[x][y]-int("0x1000000",16) + +def active(x,y): + world_art[x][y]=world_art[x][y] | int("0x0A000000",16) + +def unsigned(x): + if x>int("0xFFF",16): + return x & int("0xF000",16) + else: + return x & int("0xF0",16) + +def ispositive(x): + if x>int("0xFFF",16): + return x & int("0xF00",16)==int("0x100",16) + else: + return x & int("0xF",16)==int("0x1",16) + +def isnegative(x): + if x>int("0xFFF",16): + return x & int("0xF00",16)==int("0x200",16) + else: + return x & int("0xF",16)==int("0x2",16) + +def positive(x): + if x>int("0xFFF",16): + return (x & int("0xF000",16))+int("0x100",16) + else: + return (x & int("0xF0",16))+int("0x1",16) + +def negative(x): + if x>int("0xFFF",16): + return (x & int("0xF000",16))+int("0x200",16) + else: + return (x & int("0xF0",16))+int("0x2",16) + +def invert(x): + if ispositive(x): + return negative(x) + else: + return positive(x) + +def isbig(x): + return (x & int("0xF000",16))==int("0x2000",16) + +def isgauche(n): + return n[0]==1 and n[1]==0 + +def isdroite(n): + return n[0]==-1 and n[1]==0 + +def nextgrid(): + global play,cycle,temp,rayon,nrj,current + world_old=copy.deepcopy(world_new) + swap() + for x in range(1,sizex-1): + for y in range(1,sizey-1): + value=world_old[x][y] + flag=0 + if (wart(x,y)==items['canonh']['value'] or wart(x,y)==items['canonh2']['value']) and ((cycle%40==0 and isactive(x,y)==False) or (cycle%10==0 and isactive(x,y))): + if world_new[x][y]>=items['head']['value']: + gameover(4) + elif world_new[x][y]==items['nothing']['value']: + temp=temp+5 + else: + world_new[x][y]=items['head']['value'] + nrj=nrj+1 + if wart(x,y)==items['canont']['value'] and ((cycle%40==0 and isactive(x,y)==False) or (cycle%10==0 and isactive(x,y))): + world_new[x][y]=items['tail']['value'] + if world_old[x][y] == items['headp']['value']: + world_new[x][y]=items['tailp']['value'] + elif world_old[x][y] >= items['head']['value']: + for dx,dy in ((-1,-1),(-1,+0),(-1,+1),(+0,-1),(+0,+1),(+1,-1),(+1,+0),(+1,+1)): + if world_old[x+dx][y+dy]>=value>>8: + break + for ex,ey in direction[(dx,dy)]: + if world_new[x+ex][y+ey]==items['headr']['value'] and world_new[x][y]==items['headr']['value']: + world_old[x+ex][y+ey]=items['headr2']['value'] + world_new[x+ex][y+ey]=items['headr2']['value'] + world_new[x][y]=items['copper']['value'] + break + if world_new[x+ex][y+ey]==items['headb']['value'] and world_new[x][y]==items['headb']['value']: + world_old[x+ex][y+ey]=items['headb2']['value'] + world_new[x+ex][y+ey]=items['headb2']['value'] + world_new[x][y]=items['copper']['value'] + break + if (world_new[x+ex][y+ey]==items['headb']['value'] and world_new[x][y]==items['headr']['value']) or (world_new[x+ex][y+ey]==items['headr']['value'] and world_new[x][y]==items['headb']['value']): + world_old[x+ex][y+ey]=items['copper']['value'] + world_new[x+ex][y+ey]=items['copper']['value'] + world_new[x][y]=items['copper']['value'] + break + if (world_new[x+ex][y+ey]==items['headb2']['value'] and world_new[x][y]==items['headr2']['value']) or (world_new[x+ex][y+ey]==items['headr2']['value'] and world_new[x][y]==items['headb2']['value']): + world_old[x+ex][y+ey]=items['nothing']['value'] + world_new[x+ex][y+ey]=items['nothing']['value'] + world_new[x][y]=items['nothing']['value'] + rayon=rayon+5 + break + if world_new[x+ex][y+ey]==items['headr2']['value'] and world_new[x][y]==items['headb']['value']: + world_old[x+ex][y+ey]=items['headr']['value'] + world_new[x+ex][y+ey]=items['headr']['value'] + world_new[x][y]=items['copper']['value'] + rayon=rayon+1 + break + if world_new[x+ex][y+ey]==items['headb2']['value'] and world_new[x][y]==items['headr']['value']: + world_old[x+ex][y+ey]=items['copper']['value'] + world_new[x+ex][y+ey]=items['copper']['value'] + world_new[x][y]=items['headr']['value'] + rayon=rayon+1 + break + art=wart(x+ex,y+ey) + if flag==0 and world_old[x+ex][y+ey]==items['copper']['value'] and world_new[x+ex][y+ey]0: numtri=numtri-1 + else: + if numtri>0: numtri=numtri-1 + world_art[x+ex][y+ey]=items['triern'+str(numtri)+"-"+idtri+acttri]['value'] + if art!=items['nothing']['value'] and world_new[x][y]>=items['head']['value']: + temp=items[items[art]]['temp']+temp + world_new[x][y] = value>>8 + break + elif value == items['tailp']['value']: + world_new[x][y]=items['fiber']['value'] + elif value >= items['tail']['value'] and world_new[x][y] < items['head']['value']: + newvalue=value-int("0x10", 16) + if newvalueworld: + world=items[items[int("0x40000",16)+i]]['world'] + +''' *********************************************************************************************** ''' +''' Fonctions evenementielles liees a la fenetre ''' + +@win.event +def on_key_press(symbol, modifiers): + global play,over,level + if player.source and player.source.video_format: + player.next() + ambiance.play() + return + if over>0: + gameover_ok() + return + if over<0: + itsvictory_ok() + return + if level<0: return + if symbol==key.SPACE: + nextgrid() + if symbol==key.BACKSPACE: + erase() + elif symbol==key.RETURN: + run(0,0,0,0) + elif symbol==key.NUM_SUBTRACT: + speed(1980,2,0,0) + elif symbol==key.NUM_ADD: + speed(1980,1,0,0) + +@win.event +def on_mouse_motion(x, y, dx, dy): + global world,selected,allcout,over,level,sizeworld + if level>=0: + realx=(x-decx)/zoom + realy=(y-decy)/zoom + if unroll==1: + if debug==1: + nbelements=44 + else: + nbelements=29 + size=win.width/nbelements + allcout=0 + for i in range(nbelements): + if x>=5+i*size and x<=5+i*size+size and y>=55 and y<55+size: + if items[items[int("0x30000",16)+i]]['tech']<=tech: + allcout=items[items[int("0x30000",16)+i]] + return + selected=-1 + for i in range(sizeworld): + ele=items[items[int("0x40000",16)+i]] + if ele['world']==world: + if x>ele['coordx']+20 and xele['coordy']+0 and y940 and y>win.height-100 and x<1024 and y840 and y>150 and x<920 and y<240: + selected=-3 + if x>920 and y>150 and x<1024 and y<240: + selected=-4 + +@win.event +def on_mouse_drag(x, y, dx, dy, buttons, modifiers): + global zoom,mousel,mouser,mousem,over,level + if player.source and player.source.video_format: + player.next() + ambiance.play() + return + if over>0: + gameover_ok() + return + if over<0: + itsvictory_ok() + return + if level<0: return + realx=(x-decx)/zoom + realy=(y-decy)/zoom + mouses=23 + if buttons == mouse.LEFT: + mouses=mousel + if buttons == mouse.RIGHT: + mouses=mouser + if buttons == mouse.MIDDLE: + mouses=mousem + if mouses!=23 and items[items[int("0x20000",16)+mouses]]['drag']==1 and (unroll==1 or y>100) and (unroll==0 or y>50): + eval(items[int("0x20000",16)+mouses]+"("+str(realx)+","+str(realy)+","+str(dx)+","+str(dy)+")") + +@win.event +def on_mouse_press(x, y, button, modifiers): + global zoom,mousel,mouser,mousem,unroll,over,level,selected,world + if player.source and player.source.video_format: + player.next() + ambiance.play() + return + if over>0: + gameover_ok() + return + if over<0: + itsvictory_ok() + return + if level<0: + if selected==-2: + pyglet.app.exit() + elif selected==-4 and world>0: + world=world-1 + elif selected==-3 and world<2: + world=world+1 + elif selected>-1: + level=selected['grid'] + if readgrid(selected['file']+".user")==False : readgrid(selected['file']) + if selected['tuto']!="": + player.queue(pyglet.resource.media(selected['tuto'])) + player.play() + ambiance.pause() + selected=-1 + return + realx=(x-decx)/zoom + realy=(y-decy)/zoom + for i in range(15): + if x>=10+i*45 and x<=49+i*45 and y>=8 and y<44: + if 'color' in items[items[int("0x20000",16)+i]] and items[items[int("0x20000",16)+i]]['color']!=[40,40,40]: + if button == mouse.LEFT: + mousel=i + if button == mouse.RIGHT: + mouser=i + if button == mouse.MIDDLE: + mousem=i + if button!="" and i==14: + if unroll==1: + unroll=0 + else: + unroll=1 + return + if unroll==1: + if debug==1: + nbelements=44 + else: + nbelements=29 + size=win.width/nbelements + for i in range(nbelements): + if x>=5+i*size and x<=5+i*size+size and y>=55 and y<55+size: + if items[items[int("0x30000",16)+i]]['tech']<=tech: + items['others']['ref']=items[items[int("0x30000",16)+i]] + if button == mouse.LEFT: + mousel=14 + if button == mouse.RIGHT: + mouser=14 + if button == mouse.MIDDLE: + mousem=14 + return + mouses=23 + if button == mouse.LEFT: + mouses=mousel + if button == mouse.RIGHT: + mouses=mouser + if button == mouse.MIDDLE: + mouses=mousem + if mouses!=23: + eval(items[int("0x20000",16)+mouses]+"("+str(realx)+","+str(realy)+","+str(0)+","+str(0)+")") + +if __name__ == '__main__': + main() diff --git a/data/elements.dat b/data/elements.dat new file mode 100644 index 0000000..b46eebd --- /dev/null +++ b/data/elements.dat @@ -0,0 +1,20 @@ +/;color;cout;value +copper;[240,100,38];#1;0x1 +fiber;[208,213,79];#5;0x2 +tail;[60,50,50];#1;0x10 +tail2;[60,50,50];#1;0x20 +tailr;[150,50,50];#1;0x11 +tailr2;[150,50,50];#1;0x21 +tailb;[50,50,150];#1;0x12 +tailb2;[50,50,150];#1;0x22 +head;[60,60,60];#1;0x1000 +head2;[40,40,40];#1;0x2000 +headr;[200,50,50];#1;0x1100 +headr2;[255,0,0];#1;0x2100 +headb;[50,50,200];#1;0x1200 +headb2;[0,0,255];#1;0x2200 +nothing;[0,0,0];#0;0x0 +headp;[44,120,44];#5;0x1300 +tailp;[68,165,68];#5;0x13 +prot;[122,49,25];#0;0x4 +neut;[75,119,157];#0;0x5 diff --git a/data/elements2.dat b/data/elements2.dat new file mode 100644 index 0000000..d1d56b3 --- /dev/null +++ b/data/elements2.dat @@ -0,0 +1,55 @@ +/;text;color;cout;temp;tech;cat;nrj;activable +null;;[0,0,0];#0;#0;#0;#0;#0;#0 +positiver;+;[255,0,0];#60;&0.05;#2;#1;#0;#1 +negativer;-;[0,0,255];#60;&0.05;#4;#1;#0;#1 +inverter;∞;[125,13,114];#20;&0.05;#1;#1;#0;#0 +neutraliser;O;[90,90,90];#20;&0.05;#3;#1;#0;#0 +dir1;◄;[125,13,114];#25;&0.05;#5;#2;#0;#0 +dir2;►;[125,13,114];#25;&0.05;#5;#2;#0;#0 +trierb;▪;[0,0,255];#150;&0.05;#6;#3;#0;#0 +trierr;▪;[255,0,0];#150;&0.05;#6;#3;#0;#0 +trierp;▪;[44,120,44];#200;&0.05;#8;#3;#0;#1 +trierg;↔;[125,13,114];#150;&0.05;#5;#3;#0;#0 +triern1-1;1;[125,13,114];#250;&0.05;#8;#3;#0;#0 +triern2-2;2;[125,13,114];#250;&0.05;#8;#3;#0;#0 +triern4-4;4;[125,13,114];#250;&0.05;#8;#3;#0;#0 +triern4-4a;4;[125,13,114];#300;&0.05;#9;#3;#0;#1 +triern8-8a;8;[125,13,114];#300;&0.05;#9;#3;#0;#1 +canonh;■;[90,90,90];#50;#0;#1;#4;#1;#1 +canont;□;[90,90,90];#20;#0;#5;#4;#0;#1 +destroyer;X;[125,13,114];#40;#0;#7;#4;#0;#0 +photonizer;≈;[44,120,44];#30;&0.5;#2;#4;#0;#0 +photonizer2;=;[44,120,44];#150;&1.0;#8;#4;#0;#0 +reactor;⌂;[125,13,114];#100;#2;#3;#4;#0;#1 +senserK;K;[50,50,150];#80;#0;#3;#5;#0;#1 +senserL;L;[50,50,150];#80;#0;#6;#5;#0;#1 +senserM;M;[50,50,150];#80;#0;#7;#5;#0;#1 +senserN;N;[50,50,150];#80;#0;#8;#5;#0;#1 +sensern;n;[75,119,157];#80;#0;#4;#5;#0;#1 +senserp;p;[122,49,25];#80;#0;#3;#5;#0;#1 +calor;Ж;[240,30,30];#300;#0;#9;#6;#0;#0 +sensere;e;[60,60,60];#0;#0;#0;#7;#0;#0 +senserf;e;[200,50,50];#0;#0;#0;#7;#0;#0 +senserg;e;[0,0,255];#0;#0;#0;#7;#0;#0 +senserh;e;[60,60,60];#0;#0;#0;#7;#0;#1 +positiver2;+;[255,0,0];#0;&0.05;#0;#7;#0;#0 +canonh2;■;[125,13,114];#0;#0;#0;#7;#1;#0 +triern0-1;0;[255,255,255];#250;&0.05;#0;#7;#0;#0 +triern0-2;0;[255,255,255];#250;&0.05;#0;#7;#0;#0 +triern0-4;0;[255,255,255];#250;&0.05;#0;#7;#0;#0 +triern1-2;1;[255,255,255];#250;&0.05;#0;#7;#0;#0 +triern1-4;1;[255,255,255];#250;&0.05;#0;#7;#0;#0 +triern2-4;2;[255,255,255];#250;&0.05;#0;#7;#0;#0 +triern3-4;3;[125,13,114];#250;&0.05;#0;#7;#0;#0 +triern7-8a;7;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern6-8a;6;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern5-8a;5;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern4-8a;5;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern3-8a;3;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern2-8a;2;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern1-8a;1;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern0-8a;0;[255,255,255];#300;&0.05;#0;#7;#0;#1 +triern3-4a;3;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern2-4a;2;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern1-4a;1;[125,13,114];#300;&0.05;#0;#7;#0;#1 +triern0-4a;0;[255,255,255];#300;&0.05;#0;#7;#0;#1 diff --git a/data/level0-0.dat b/data/level0-0.dat new file mode 100644 index 0000000..e0f71f3 --- /dev/null +++ b/data/level0-0.dat @@ -0,0 +1,11 @@ +Introduction;e0;Prise en main de l'interface de WireChem{#169} et amener l'électron neutre sur le senseur.;1;86;-55;170;-1;0;[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;16;4096;1;1;1;1;1;1;1;1;1;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;196637;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-1.dat b/data/level0-1.dat new file mode 100644 index 0000000..ad47835 --- /dev/null +++ b/data/level0-1.dat @@ -0,0 +1,19 @@ +Trajectoires;e0;Comprendre les trajectoires empruntées par les électrons afin de mieux appréhender la conception de systèmes.;1;58;-6;130;-1;0;[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;1;1;1;1;1;1;1;1;1;1;1;0;0;0;0;0;0 +0;1;1;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0 +0;1;0;0;1;1;1;1;0;0;0;1;0;0;0;0;0;0 +0;16;4096;1;1;1;1;0;1;1;1;0;1;1;1;1;1;0 +0;1;0;0;1;1;1;1;0;0;0;1;0;0;0;0;0;0 +0;1;1;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0 +0;1;1;1;1;1;1;1;1;1;1;1;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;196637;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-2.dat b/data/level0-2.dat new file mode 100644 index 0000000..e4a3408 --- /dev/null +++ b/data/level0-2.dat @@ -0,0 +1,11 @@ +Pistes;e0;Utiliser des pistes afin de réaliser un circuit qui permet l'arrivée d'un électron neutre sur le senseur.;0;86;-55;170;0;15;[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;16;4096;0;0;0;0;0;0;0;0;1;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;196637;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-3.dat b/data/level0-3.dat new file mode 100644 index 0000000..38b1693 --- /dev/null +++ b/data/level0-3.dat @@ -0,0 +1,11 @@ +Positiveur;e+;Comprendre le fonctionnement de l'élément positiveur et générer 8 électrons positifs sur le senseur.;0;86;-55;170;0;16;[0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;1;1;0;0;0;1;0;0;0;0;1;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;196642;0;0;0;0;196641;0;0;0;0;196638;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-4.dat b/data/level0-4.dat new file mode 100644 index 0000000..936d54b --- /dev/null +++ b/data/level0-4.dat @@ -0,0 +1,11 @@ +Superelectrons;e-;Générer 2 super électrons negatifs par colision et les amener sur le senseur;0;86;-55;170;1;81;[2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;1;0;0;0;0;0;0;0;0;0;0;0 +0;1;0;0;0;0;0;0;0;0;0;1;0 +0;1;0;0;0;0;1;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;196639;0 +0;196624;0;0;0;0;196641;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-5.dat b/data/level0-5.dat new file mode 100644 index 0000000..645c349 --- /dev/null +++ b/data/level0-5.dat @@ -0,0 +1,11 @@ +Activation;e0;L'objectif est de générer 6 électrons neutre et découvrir les liaisons fibres par lesquelles transitent les photons. Certains modifieurs nécessitent désormais l'activation par des photons.;0;110;-46;134;1;136;[0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0 +0;0;0;1;0;0;0;0;1;4096 +0;1;2;2;0;0;0;0;2;0 +0;2;0;0;2;2;2;2;2;2 +0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0 +0;0;0;196627;0;0;0;0;196640;0 +0;196624;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-6.dat b/data/level0-6.dat new file mode 100644 index 0000000..d0b5392 --- /dev/null +++ b/data/level0-6.dat @@ -0,0 +1,19 @@ +Fibres;eX;A vous de dessiner votre infrastructure a base de fibres et de pistes mais aussi de modifieur activable afin de faire parvenir des éléctrons positifs et neutres sur les senseurs.;0;60;-30;112;2;230;[0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;1;1;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;2;2;2;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;1;2;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;2;2;2;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;1;1;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;196640;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;196638;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-7.dat b/data/level0-7.dat new file mode 100644 index 0000000..1265f68 --- /dev/null +++ b/data/level0-7.dat @@ -0,0 +1,19 @@ +Protons;p;Générer deux protons sur le senseur en utilisant un réacteur et un super-positron. Le réacteur est un élément qui nécessite l'activation.;0;60;-32;108;2;370;[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;1;1;1;0;1;1;1;0;0 +0;0;0;0;0;0;0;0;0;1;1;1;1;2;2;1;0;0 +0;0;0;0;0;0;0;0;0;1;2;1;2;1;1;0;0;0 +0;0;0;0;0;0;0;0;0;0;1;2;1;1;1;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;1;2;2;2;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;2;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;2;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;196609;0;0 +0;0;0;0;0;0;0;0;0;0;196624;0;0;0;0;196629;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;196627;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;196635;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level0-8.dat b/data/level0-8.dat new file mode 100644 index 0000000..b2d243e --- /dev/null +++ b/data/level0-8.dat @@ -0,0 +1,19 @@ +Hydrogène;H;Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.;0;60;-32;108;3;750;[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;196619;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/level1-0.dat b/data/level1-0.dat new file mode 100644 index 0000000..1d1bb50 --- /dev/null +++ b/data/level1-0.dat @@ -0,0 +1,19 @@ +Deuterium;D;Générer un isostope de l'hydrogène qui comporte un proton et un neutron ainsi qu'un électron négatif sur la couche K.;0;60;-32;108;4;1300;[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1];[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];0;0;0;0;99999;99999;99999;99999 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;1;1;1;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;196619;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 +0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 diff --git a/data/menus.dat b/data/menus.dat new file mode 100644 index 0000000..7bb421c --- /dev/null +++ b/data/menus.dat @@ -0,0 +1,17 @@ +/;icon;drag;color;ref +run;picture/stop.png;#0;; +speed;picture/speed.png;#0;; +raz;picture/raz.png;#0;; +move;picture/move.png;#1;; +zoomp;picture/zoomp.png;#0;; +zoomm;picture/zoomm.png;#0;; +stat;picture/stat.png;#0;; +levels;picture/levels.png;#0;; +screen;picture/screen.png;#0;; +settings;picture/settings.png;#0;; +exits;picture/exits.png;#0;; +setcopper;;#1;[240,100,38]; +setfiber;;#1;[208,213,79]; +setnothing;;#1;[0,0,0]; +others;/;#1;;@null +setnothinga;;#1;[40,40,40]; diff --git a/data/menus2.dat b/data/menus2.dat new file mode 100644 index 0000000..c771ba8 --- /dev/null +++ b/data/menus2.dat @@ -0,0 +1,7 @@ +/;icon +cycle;picture/cycle.png +nrj;picture/nrj.png +rayon;picture/rayon.png +temp;picture/temp.png +cout;picture/cout.png +tech;picture/tech.png diff --git a/data/pref.dat b/data/pref.dat new file mode 100644 index 0000000..7e845b2 --- /dev/null +++ b/data/pref.dat @@ -0,0 +1 @@ +level0-1;level0-8;level0-2;level0-2;level0-2;level0-2;level0-3;level0-4;level0-5;level0-6;level0-6;level0-6 diff --git a/data/worlds.dat b/data/worlds.dat new file mode 100644 index 0000000..673bbf3 --- /dev/null +++ b/data/worlds.dat @@ -0,0 +1,11 @@ +/;file;world;grid;coordx;coordy;validate;tuto +level0-0;data/level0-0.dat;#0;#0;#30;#450;{level0-1,level0-8};movie/level0-0.mp4 +level0-1;data/level0-1.dat;#0;#1;#30;#200;{level0-2}; +level0-2;data/level0-2.dat;#0;#2;#180;#300;{level0-3}; +level0-3;data/level0-3.dat;#0;#3;#330;#350;{level0-4}; +level0-4;data/level0-4.dat;#0;#4;#480;#380;{level0-5}; +level0-5;data/level0-5.dat;#0;#5;#480;#200;{level0-6}; +level0-6;data/level0-6.dat;#0;#6;#640;#200;{level0-7}; +level0-7;data/level0-7.dat;#0;#7;#800;#290;{level0-8}; +level0-8;data/level0-8.dat;#0;#8;#900;#450;{level1-0}; +level1-0;data/level1-0.dat;#1;#0;#30;#200;{level0-8}; diff --git a/music/ambiance1.mp3 b/music/ambiance1.mp3 new file mode 100644 index 0000000..ba9466f Binary files /dev/null and b/music/ambiance1.mp3 differ diff --git a/picture/arrows.png b/picture/arrows.png new file mode 100644 index 0000000..81b9d94 Binary files /dev/null and b/picture/arrows.png differ diff --git a/picture/arrows2.png b/picture/arrows2.png new file mode 100644 index 0000000..aad54dc Binary files /dev/null and b/picture/arrows2.png differ diff --git a/picture/cout.png b/picture/cout.png new file mode 100644 index 0000000..d338eb6 Binary files /dev/null and b/picture/cout.png differ diff --git a/picture/cycle.png b/picture/cycle.png new file mode 100644 index 0000000..01d2ec7 Binary files /dev/null and b/picture/cycle.png differ diff --git a/picture/exit2.png b/picture/exit2.png new file mode 100644 index 0000000..f43632b Binary files /dev/null and b/picture/exit2.png differ diff --git a/picture/exits.png b/picture/exits.png new file mode 100644 index 0000000..13a721d Binary files /dev/null and b/picture/exits.png differ diff --git a/picture/levels.png b/picture/levels.png new file mode 100644 index 0000000..cc5c830 Binary files /dev/null and b/picture/levels.png differ diff --git a/picture/levels2.png b/picture/levels2.png new file mode 100644 index 0000000..8ee111e Binary files /dev/null and b/picture/levels2.png differ diff --git a/picture/logo.png b/picture/logo.png new file mode 100644 index 0000000..c8a98ba Binary files /dev/null and b/picture/logo.png differ diff --git a/picture/logo2.png b/picture/logo2.png new file mode 100644 index 0000000..e2a2b1d Binary files /dev/null and b/picture/logo2.png differ diff --git a/picture/move.png b/picture/move.png new file mode 100644 index 0000000..aea5452 Binary files /dev/null and b/picture/move.png differ diff --git a/picture/nrj.png b/picture/nrj.png new file mode 100644 index 0000000..f63a4b3 Binary files /dev/null and b/picture/nrj.png differ diff --git a/picture/rayon.png b/picture/rayon.png new file mode 100644 index 0000000..002295c Binary files /dev/null and b/picture/rayon.png differ diff --git a/picture/raz.png b/picture/raz.png new file mode 100644 index 0000000..a1ab0e9 Binary files /dev/null and b/picture/raz.png differ diff --git a/picture/run.png b/picture/run.png new file mode 100644 index 0000000..1d00a6d Binary files /dev/null and b/picture/run.png differ diff --git a/picture/screen.png b/picture/screen.png new file mode 100644 index 0000000..1d80986 Binary files /dev/null and b/picture/screen.png differ diff --git a/picture/settings.png b/picture/settings.png new file mode 100644 index 0000000..7bb83c4 Binary files /dev/null and b/picture/settings.png differ diff --git a/picture/speed.png b/picture/speed.png new file mode 100644 index 0000000..ed158fa Binary files /dev/null and b/picture/speed.png differ diff --git a/picture/stat.png b/picture/stat.png new file mode 100644 index 0000000..0c4174b Binary files /dev/null and b/picture/stat.png differ diff --git a/picture/stop.png b/picture/stop.png new file mode 100644 index 0000000..e8b7d26 Binary files /dev/null and b/picture/stop.png differ diff --git a/picture/tech.png b/picture/tech.png new file mode 100644 index 0000000..d613151 Binary files /dev/null and b/picture/tech.png differ diff --git a/picture/temp.png b/picture/temp.png new file mode 100644 index 0000000..8ee2399 Binary files /dev/null and b/picture/temp.png differ diff --git a/picture/zoomm.png b/picture/zoomm.png new file mode 100644 index 0000000..c0d632a Binary files /dev/null and b/picture/zoomm.png differ diff --git a/picture/zoomp.png b/picture/zoomp.png new file mode 100644 index 0000000..92383e9 Binary files /dev/null and b/picture/zoomp.png differ diff --git a/sound/gameover.mp3 b/sound/gameover.mp3 new file mode 100644 index 0000000..1e888a7 Binary files /dev/null and b/sound/gameover.mp3 differ diff --git a/sound/victoire.mp3 b/sound/victoire.mp3 new file mode 100644 index 0000000..b65d523 Binary files /dev/null and b/sound/victoire.mp3 differ