-Implémentation de toutes les fonctions du langage 'Tuto'
-Correction d'un bogue lors du lancement d'une paillasse sans tutoriel -Ajout d'un document au format Markdown qui décrit le langage 'Tuto'
This commit is contained in:
parent
8977108aa5
commit
bafb591802
|
@ -0,0 +1,96 @@
|
||||||
|
----------------------------------------------------------------
|
||||||
|
## WireChem
|
||||||
|
|
||||||
|
![The new chemistry game](logo.png)
|
||||||
|
|
||||||
|
http://wirechem.dahut.fr
|
||||||
|
|
||||||
|
*(C) Copyright 2013-2014 Nicolas Hordé
|
||||||
|
Licence GPL V3.0*
|
||||||
|
|
||||||
|
----------------------------------------------------------------
|
||||||
|
### Langage pour la création de Tutoriel
|
||||||
|
|
||||||
|
Les coordonnées sont celles du 1024x768 avec interpolation selon la
|
||||||
|
resolution choisie. Les commandes sont insensibles à la casse.
|
||||||
|
|
||||||
|
*Fonctions d'attente*
|
||||||
|
|
||||||
|
####WAIT
|
||||||
|
|
||||||
|
Attend un click ou un appuie sur une touche.
|
||||||
|
|
||||||
|
####WAIT sec
|
||||||
|
|
||||||
|
Attend le nombre de seconde spécifiés.
|
||||||
|
|
||||||
|
####WAIT MENU,menu,element
|
||||||
|
|
||||||
|
Attend le click sur le menu.
|
||||||
|
|
||||||
|
####WAIT DRAG,[bouton]
|
||||||
|
|
||||||
|
Attend un deplacement de curseur.
|
||||||
|
|
||||||
|
####WAIT CLICK,[bouton]
|
||||||
|
|
||||||
|
Attend un click du bouton.
|
||||||
|
|
||||||
|
*Fonctions d'affichage*
|
||||||
|
|
||||||
|
####MSG message
|
||||||
|
|
||||||
|
envoie un message à l'écran avec mise en forme.
|
||||||
|
|
||||||
|
####RECT x1,y1,x2,y2
|
||||||
|
|
||||||
|
dessine un carré rouge pour attirer l'attention de l'utilisateur sur une
|
||||||
|
zone à l'écran dont les coordonnées sont spécifiées.
|
||||||
|
|
||||||
|
####ARROW x1,y1,x2,y2
|
||||||
|
|
||||||
|
dessine une flèche rouge pour attirer l'attention de l'utilisateur sur une
|
||||||
|
zone à l'écran dont les coordonnées sont spécifiées.
|
||||||
|
|
||||||
|
####DEL
|
||||||
|
|
||||||
|
efface tout ce qui a été dessiné à l'écran.
|
||||||
|
|
||||||
|
*Fonctions menu*
|
||||||
|
|
||||||
|
####MENU menu,element,button
|
||||||
|
|
||||||
|
Clique sur un élément de menu.
|
||||||
|
|
||||||
|
####SELECT menu,element,button
|
||||||
|
|
||||||
|
Choisi un élément de menu.
|
||||||
|
|
||||||
|
####SET menu,element ou UNSET
|
||||||
|
|
||||||
|
Met en surbrillance un élément du menu.
|
||||||
|
|
||||||
|
####UNSET menu,element
|
||||||
|
|
||||||
|
Retire la surbrillance d'un élément du menu.
|
||||||
|
|
||||||
|
*fonctions gameplay*
|
||||||
|
|
||||||
|
####NEXT
|
||||||
|
|
||||||
|
Fait la prochaine génération de la grille de simulation.
|
||||||
|
|
||||||
|
####TECH niveau
|
||||||
|
|
||||||
|
Change le niveau technologique.
|
||||||
|
|
||||||
|
*fonction souris*
|
||||||
|
|
||||||
|
####CLICK x,y,button
|
||||||
|
|
||||||
|
Simule un clique sur le plateau de jeu aux coordonnées x,y.
|
||||||
|
|
||||||
|
####DRAG x1,y1,x2,y2,button
|
||||||
|
|
||||||
|
Simule un clique sur le plateau de jeu entre les coordonnées fournies.
|
||||||
|
|
57
WireChem.py
57
WireChem.py
|
@ -158,7 +158,8 @@ def resize():
|
||||||
decy=-zoom+(win.height-zoom*(sizey-2))/2
|
decy=-zoom+(win.height-zoom*(sizey-2))/2
|
||||||
|
|
||||||
def readlevel(w,l,user):
|
def readlevel(w,l,user):
|
||||||
global worlds,cout,selected,sizex,sizey,stat,debug,tech
|
global tuto,worlds,cout,selected,sizex,sizey,stat,debug,tech
|
||||||
|
tuto=''
|
||||||
if user:
|
if user:
|
||||||
if w<len(Uworlds) and l<len(Uworlds[w]) and Uworlds[w][l].has_key("element"):
|
if w<len(Uworlds) and l<len(Uworlds[w]) and Uworlds[w][l].has_key("element"):
|
||||||
load(Uworlds[w][l])
|
load(Uworlds[w][l])
|
||||||
|
@ -367,6 +368,20 @@ def drawsquare(x,y,x2,y2,full,color):
|
||||||
glVertex2i(x,y2)
|
glVertex2i(x,y2)
|
||||||
glEnd()
|
glEnd()
|
||||||
|
|
||||||
|
def drawarrow(x,y,x2,y2,color):
|
||||||
|
glColor3ub(color[0],color[1],color[2])
|
||||||
|
glBegin(GL_LINE_LOOP)
|
||||||
|
glVertex2i(x,y)
|
||||||
|
glVertex2i(x2,y2)
|
||||||
|
glEnd()
|
||||||
|
angle=math.atan(float(y2-y)/(x2-x))
|
||||||
|
glBegin(GL_POLYGON)
|
||||||
|
glVertex2i(x2,y2)
|
||||||
|
glVertex2i(int(20*math.cos(angle+160*3.14/180))+x2,int(20*math.sin(angle+160*3.14/180))+y2)
|
||||||
|
glVertex2i(int(10*math.cos(angle+180*3.14/180))+x2,int(10*math.sin(angle+180*3.14/180))+y2)
|
||||||
|
glVertex2i(int(20*math.cos(angle-160*3.14/180))+x2,int(20*math.sin(angle-160*3.14/180))+y2)
|
||||||
|
glEnd()
|
||||||
|
|
||||||
def drawsemisquare(x,y,x2,y2,color):
|
def drawsemisquare(x,y,x2,y2,color):
|
||||||
if len(color)==4:
|
if len(color)==4:
|
||||||
glColor4ub(color[0],color[1],color[2],color[3])
|
glColor4ub(color[0],color[1],color[2],color[3])
|
||||||
|
@ -871,7 +886,10 @@ def drawtuto():
|
||||||
global tuto,rect,msg,menus
|
global tuto,rect,msg,menus
|
||||||
drawsquare(win.width-384,menus[0][0]['size'],win.width,menus[0][0]['size']+200,2,[40,40,40,200])
|
drawsquare(win.width-384,menus[0][0]['size'],win.width,menus[0][0]['size']+200,2,[40,40,40,200])
|
||||||
if type(rect) is list:
|
if type(rect) is list:
|
||||||
|
if rect[4]==0:
|
||||||
drawsquare(rect[0]*win.width/1024,rect[1]*win.height/768,rect[2]*win.width/1024,rect[3]*win.height/768,2,[255,0,0,20])
|
drawsquare(rect[0]*win.width/1024,rect[1]*win.height/768,rect[2]*win.width/1024,rect[3]*win.height/768,2,[255,0,0,20])
|
||||||
|
else:
|
||||||
|
drawarrow(rect[0]*win.width/1024,rect[1]*win.height/768,rect[2]*win.width/1024,rect[3]*win.height/768,[255,0,0])
|
||||||
txt_message.x=win.width-384
|
txt_message.x=win.width-384
|
||||||
txt_message.y=menus[0][0]['size']
|
txt_message.y=menus[0][0]['size']
|
||||||
document=pyglet.text.decode_attributed("{font_name 'OpenDyslexicAlta'}{font_size 18}{color (255, 255, 255, 255)}"+msg.decode('utf-8')+"}".encode('utf8'))
|
document=pyglet.text.decode_attributed("{font_name 'OpenDyslexicAlta'}{font_size 18}{color (255, 255, 255, 255)}"+msg.decode('utf-8')+"}".encode('utf8'))
|
||||||
|
@ -1569,7 +1587,7 @@ def motion_popup(state):
|
||||||
''' Fonctions liée à la gestion des menus '''
|
''' Fonctions liée à la gestion des menus '''
|
||||||
|
|
||||||
def launch(x,y,dx,dy,i,j,buttons,modifiers,onmenu):
|
def launch(x,y,dx,dy,i,j,buttons,modifiers,onmenu):
|
||||||
global menus,decx,decy,zoom
|
global menus,decx,decy,zoom,tuto
|
||||||
realx=(x-decx)/zoom
|
realx=(x-decx)/zoom
|
||||||
realy=(y-decy)/zoom
|
realy=(y-decy)/zoom
|
||||||
state={'x':x,'y':y,'realx':realx, 'realy':realy, 'dx':dx, 'dy':dy, 'i':i, 'j':j, 'buttons':buttons, 'modifiers':modifiers, 'onmenu': onmenu}
|
state={'x':x,'y':y,'realx':realx, 'realy':realy, 'dx':dx, 'dy':dy, 'i':i, 'j':j, 'buttons':buttons, 'modifiers':modifiers, 'onmenu': onmenu}
|
||||||
|
@ -1583,6 +1601,21 @@ def launch(x,y,dx,dy,i,j,buttons,modifiers,onmenu):
|
||||||
'''print state'''
|
'''print state'''
|
||||||
if onmenu and state['event']=='click' and menus[i][0]['selectable']:
|
if onmenu and state['event']=='click' and menus[i][0]['selectable']:
|
||||||
menus[i][0]['mouse'][buttons-1]=j
|
menus[i][0]['mouse'][buttons-1]=j
|
||||||
|
if tuto!='' and tuto[1]<len(tuto[0]):
|
||||||
|
cmd,arg=tuto[0][tuto[1]]
|
||||||
|
if cmd=='wait':
|
||||||
|
if arg[0].lower()==state['event']:
|
||||||
|
if buttons==int(arg[1]) or len(arg)==1 or arg[1]=='' or int(arg[1])==0:
|
||||||
|
tuto[1]+=1
|
||||||
|
clock.schedule_once(execute,dt)
|
||||||
|
elif arg[0].lower()=='menu':
|
||||||
|
if buttons==int(arg[1]) or len(arg)==1 or arg[1]=='' or int(arg[1])==0:
|
||||||
|
tuto[1]+=1
|
||||||
|
clock.schedule_once(execute,dt)
|
||||||
|
else:
|
||||||
|
if state['event']=='click':
|
||||||
|
tuto[1]+=1
|
||||||
|
clock.schedule_once(execute,dt)
|
||||||
if menus[i][j].has_key(state['event']):
|
if menus[i][j].has_key(state['event']):
|
||||||
if type(menus[i][j][state['event']]) is list:
|
if type(menus[i][j][state['event']]) is list:
|
||||||
if callable(eval(menus[i][j][state['event']][menus[i][j]['choose']])):
|
if callable(eval(menus[i][j][state['event']][menus[i][j]['choose']])):
|
||||||
|
@ -1655,9 +1688,9 @@ def execute(dt):
|
||||||
cmd,arg=tuto[0][tuto[1]]
|
cmd,arg=tuto[0][tuto[1]]
|
||||||
print cmd,arg
|
print cmd,arg
|
||||||
if cmd=='rect':
|
if cmd=='rect':
|
||||||
rect=[int(arg[0]),int(arg[1]),int(arg[2]),int(arg[3])]
|
rect=[int(arg[0]),int(arg[1]),int(arg[2]),int(arg[3]),0]
|
||||||
elif cmd=='wait':
|
elif cmd=='wait':
|
||||||
if int(arg[0])>0: dt=int(arg[0])
|
if int(arg[0])>0 and len(arg)==1 and arg[0]!='': dt=int(arg[0])
|
||||||
elif cmd=='next':
|
elif cmd=='next':
|
||||||
nextgrid()
|
nextgrid()
|
||||||
elif cmd=='del':
|
elif cmd=='del':
|
||||||
|
@ -1674,8 +1707,17 @@ def execute(dt):
|
||||||
menus[int(arg[0])][int(arg[1])]['squarred']=True
|
menus[int(arg[0])][int(arg[1])]['squarred']=True
|
||||||
elif cmd=='unset':
|
elif cmd=='unset':
|
||||||
menus[int(arg[0])][int(arg[1])]['squarred']=False
|
menus[int(arg[0])][int(arg[1])]['squarred']=False
|
||||||
tuto[1]+=1
|
elif cmd=='arrow':
|
||||||
|
rect=[int(arg[0]),int(arg[1]),int(arg[2]),int(arg[3]),1]
|
||||||
|
elif cmd=='menu':
|
||||||
|
launch(0,0,0,0,int(arg[0]),int(arg[1]),int(arg[2]),0,True)
|
||||||
|
elif cmd=='click':
|
||||||
|
launch(int(arg[0]),int(arg[1]),0,0,0,0,int(arg[2]),0,False)
|
||||||
|
elif cmd=='drag':
|
||||||
|
launch(int(arg[0]),int(arg[1]),int(arg[2])-int(arg[0]),int(arg[3])-int(arg[1]),0,0,int(arg[4]),0,False)
|
||||||
|
if dt!=0:
|
||||||
clock.schedule_once(execute,dt)
|
clock.schedule_once(execute,dt)
|
||||||
|
tuto[1]+=1
|
||||||
|
|
||||||
''' *********************************************************************************************** '''
|
''' *********************************************************************************************** '''
|
||||||
''' Fonctions evenementielles '''
|
''' Fonctions evenementielles '''
|
||||||
|
@ -1683,6 +1725,11 @@ def execute(dt):
|
||||||
@win.event
|
@win.event
|
||||||
def on_key_press(symbol, modifiers):
|
def on_key_press(symbol, modifiers):
|
||||||
global play,over,level
|
global play,over,level
|
||||||
|
if tuto!='' and tuto[1]<len(tuto[0]):
|
||||||
|
cmd,arg=tuto[0][tuto[1]]
|
||||||
|
if cmd=='wait' and len(arg)==1 and arg[0]=='':
|
||||||
|
tuto[1]+=1
|
||||||
|
clock.schedule_once(execute,dt)
|
||||||
if player.source and player.source.video_format:
|
if player.source and player.source.video_format:
|
||||||
player.next()
|
player.next()
|
||||||
ambiance.play()
|
ambiance.play()
|
||||||
|
|
9
dbsrc
9
dbsrc
|
@ -43,19 +43,26 @@ worlds=[[{'nom': 'Introduction',
|
||||||
[0, 0, 0, 0, 0]],
|
[0, 0, 0, 0, 0]],
|
||||||
'tuto':'''
|
'tuto':'''
|
||||||
mSG CECI EST LE TUTO ;)
|
mSG CECI EST LE TUTO ;)
|
||||||
|
arrow 700,100,420,50
|
||||||
waIT 2
|
waIT 2
|
||||||
next
|
next
|
||||||
wait 1
|
wait
|
||||||
|
msg <appuie sur touche>
|
||||||
rEct 90 ,90 ,200 , 200
|
rEct 90 ,90 ,200 , 200
|
||||||
next
|
next
|
||||||
next
|
next
|
||||||
tech 8
|
tech 8
|
||||||
|
menu 0,1
|
||||||
|
wait 2
|
||||||
|
menu 0,1
|
||||||
select 0,2,2
|
select 0,2,2
|
||||||
set 0, 6
|
set 0, 6
|
||||||
wait 2
|
wait 2
|
||||||
MSg cool non ?
|
MSg cool non ?
|
||||||
tech -1
|
tech -1
|
||||||
wait 4
|
wait 4
|
||||||
|
wait menu,1
|
||||||
|
wait click,2
|
||||||
del
|
del
|
||||||
unset 0, 6
|
unset 0, 6
|
||||||
''',
|
''',
|
||||||
|
|
Loading…
Reference in New Issue