mirror of
https://forge.apps.education.fr/phroy/codetower.git
synced 2024-01-27 11:35:17 +01:00
ajout du about, correction du near des tours
This commit is contained in:
parent
52e91a553b
commit
c0301f4848
BIN
asset/icons/icon_about.FCStd
Normal file
BIN
asset/icons/icon_about.FCStd
Normal file
Binary file not shown.
1775
asset/icons/icon_about.obj
Normal file
1775
asset/icons/icon_about.obj
Normal file
File diff suppressed because it is too large
Load Diff
62
asset/icons/icon_about.svg
Normal file
62
asset/icons/icon_about.svg
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
viewBox="0 0 210 297"
|
||||
version="1.1"
|
||||
id="svg30"
|
||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||
sodipodi:docname="icon_about.svg">
|
||||
<defs
|
||||
id="defs24" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="70.748032"
|
||||
inkscape:cy="828.60379"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1016"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata27">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
style="fill:#000000;stroke:none;stroke-width:0.26458332"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4"
|
||||
d="m 16.199828,10.573438 c 0.21167,0.502708 0.3175,1.049513 0.3175,1.640416 0,0.08819 -0.0309,0.16316 -0.0926,0.224896 -0.0617,0.06173 -0.1367,0.0926 -0.2249,0.0926 h -0.87313 l -0.10583,0.542396 0.82021,0.343958 0.17198,0.17198 c 0.0353,0.07937 0.0353,0.15875 0,0.238125 -0.20285,0.502708 -0.51594,0.965729 -0.93927,1.389062 l -0.21167,0.07937 -0.22489,-0.07937 -0.62177,-0.621771 -0.46303,0.3175 0.34396,0.806979 c 0.0353,0.07937 0.0353,0.158751 0,0.238126 l -0.17198,0.171979 c -0.50271,0.211667 -1.04951,0.3175 -1.64041,0.3175 -0.0882,0 -0.16317,-0.03087 -0.2249,-0.0926 -0.0617,-0.06173 -0.0926,-0.136699 -0.0926,-0.224896 v -0.873125 l -0.5424,-0.0926 -0.33073,0.80698 -0.17198,0.171979 c -0.0794,0.03528 -0.15875,0.03528 -0.23812,0 -0.51153,-0.202847 -0.9745502,-0.511528 -1.3890702,-0.926042 -0.0617,-0.06173 -0.0926,-0.136699 -0.0926,-0.224896 0,-0.08819 0.0309,-0.163159 0.0926,-0.224895 l 0.62178,-0.621771 -0.3175,-0.463021 -0.82021,0.343958 c -0.0794,0.03528 -0.15876,0.03528 -0.23813,0 l -0.17198,-0.171979 c -0.21167,-0.502708 -0.3175,-1.049514 -0.3175,-1.640417 0,-0.08819 0.0309,-0.163159 0.0926,-0.224895 0.0617,-0.06173 0.1367,-0.0926 0.22489,-0.0926 h 0.87313 l 0.10583,-0.542395 -0.82021,-0.33073 -0.17198,-0.171979 c -0.0353,-0.07937 -0.0353,-0.15875 0,-0.238125 0.20285,-0.511527 0.51594,-0.974548 0.93927,-1.389062 0.0617,-0.06173 0.13229,-0.0926 0.21167,-0.0926 0.0882,0 0.16316,0.03087 0.2249,0.0926 l 0.6217702,0.621771 c 0.14993,-0.123473 0.30427,-0.229306 0.46302,-0.3175 l -0.34396,-0.820209 c -0.0353,-0.07937 -0.0353,-0.15875 0,-0.238125 0.0353,-0.07937 0.0926,-0.136701 0.17198,-0.171979 0.50271,-0.211667 1.04951,-0.3175 1.64042,-0.3175 0.0882,0 0.16316,0.03087 0.22489,0.0926 0.0617,0.06173 0.0926,0.136699 0.0926,0.224896 v 0.873125 l 0.54239,0.105833 0.34396,-0.820208 c 0.0265,-0.07937 0.0794,-0.136701 0.15875,-0.171979 0.0794,-0.03528 0.16316,-0.03528 0.25135,0 0.32632,0.132291 0.63941,0.31309 0.93928,0.542396 l 0.43656,0.396875 c 0.0617,0.06173 0.0926,0.136698 0.0926,0.224895 l -0.0926,0.211667 -0.60854,0.621771 0.30427,0.463021 0.82021,-0.343959 c 0.0794,-0.03528 0.15875,-0.03528 0.23812,0 l 0.17198,0.17198 m -3.91583,-0.410105 c -0.56445,0 -1.04952,0.198438 -1.45521,0.595313 -0.39687,0.405695 -0.59531,0.890764 -0.59531,1.455208 0,0.564445 0.19844,1.049514 0.59531,1.455209 0.40569,0.396875 0.89076,0.595312 1.45521,0.595312 0.56444,0 1.04951,-0.198437 1.4552,-0.595312 0.39688,-0.405695 0.59532,-0.890764 0.59532,-1.455209 0,-0.564444 -0.19844,-1.049513 -0.59532,-1.455208 -0.40569,-0.396875 -0.89076,-0.595313 -1.4552,-0.595313 m 0,1.031875 c 0.28222,0 0.52475,0.09701 0.7276,0.291042 0.20285,0.202847 0.30427,0.445382 0.30427,0.727604 0,0.282223 -0.10142,0.524757 -0.30427,0.727604 -0.20285,0.202847 -0.44538,0.304271 -0.7276,0.304271 -0.28223,0 -0.52476,-0.101424 -0.72761,-0.304271 -0.19403,-0.202847 -0.29104,-0.445381 -0.29104,-0.727604 0,-0.282222 0.097,-0.524757 0.29104,-0.727604 0.20285,-0.194028 0.44538,-0.291042 0.72761,-0.291042"
|
||||
sodipodi:nodetypes="cscscccccccccccccsssccccccsccccccscsccccccsccccccsssccccccccccccccccscscsccccscscscc" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
BIN
codetower-19.blend
Normal file
BIN
codetower-19.blend
Normal file
Binary file not shown.
233
ct.py
233
ct.py
@ -1,4 +1,5 @@
|
||||
import importlib
|
||||
# import imp
|
||||
import bge # Blender Game Engine (UPBGE)
|
||||
import bpy # Blender
|
||||
import aud # Sounds
|
||||
@ -10,6 +11,9 @@ import webbrowser
|
||||
import threading # Multithreading
|
||||
import xml.etree.ElementTree as ET # Creating/parsing XML file
|
||||
|
||||
import ct_map1 as ct_map # waves script
|
||||
# import ct_cmd # user script (commands)
|
||||
|
||||
###############################################################################
|
||||
# ct.py
|
||||
# @title: the CodeTower game
|
||||
@ -30,14 +34,15 @@ import xml.etree.ElementTree as ET # Creating/parsing XML file
|
||||
###############################################################################
|
||||
|
||||
# Dynamic import user file
|
||||
sys.setrecursionlimit(10**5) # Limite sur la récursivité (valeur par défaut : 1000) -> segfault de Blender
|
||||
sys.setrecursionlimit(10**6) # Limite sur la récursivité (valeur par défaut : 1000) -> segfault de Blender
|
||||
importlib.invalidate_caches()
|
||||
ct_map = importlib.import_module('ct_map1') # waves script
|
||||
ct_cmd = importlib.import_module('ct_cmd') # user script (commands)
|
||||
# ct_map = importlib.import_module('ct_map1') # Waves script
|
||||
ct_cmd = importlib.import_module('ct_cmd') # User script (commands)
|
||||
|
||||
# UPBGE scene
|
||||
scene = bge.logic.getCurrentScene()
|
||||
eevee = bpy.context.scene.eevee
|
||||
fps_time=0.0
|
||||
|
||||
# Config file
|
||||
# print (os.getcwd())
|
||||
@ -45,24 +50,26 @@ ct_config = ET.parse('ct_config.xml')
|
||||
ct_config_tree = ct_config.getroot()
|
||||
|
||||
# Colors
|
||||
color_magenta = [0.800, 0.005, 0.315,1]
|
||||
color_orange = [0.799, 0.130, 0.063,1]
|
||||
color_white = [0.8, 0.8, 0.8, 1]
|
||||
color_yellow = [0.8, 0.619, 0.021, 1]
|
||||
color_black = [0, 0, 0, 1]
|
||||
color_magenta = (0.800, 0.005, 0.315,1)
|
||||
color_orange = (0.799, 0.130, 0.063,1)
|
||||
color_white = (0.8, 0.8, 0.8, 1)
|
||||
color_yellow = (0.8, 0.619, 0.021, 1)
|
||||
color_black = (0, 0, 0, 1)
|
||||
|
||||
color_kaykit_black = [0.019, 0.032, 0.037, 1]
|
||||
color_kaykit_black = (0.019, 0.032, 0.037, 1)
|
||||
|
||||
color_endbanner_bluelight = [0.361, 0.527, 0.716, 1]
|
||||
color_endbanner_bluedark = [0.130, 0.254, 0.407, 1]
|
||||
color_endbanner_bluelight = (0.361, 0.527, 0.716, 1)
|
||||
color_endbanner_bluedark = (0.130, 0.254, 0.407, 1)
|
||||
|
||||
color_text = [0, 0, 0, 1] # Noir
|
||||
color_text_red = [0.799, 0.031, 0.038, 1]
|
||||
color_text = (0, 0, 0, 1) # Noir
|
||||
color_text_red = (0.799, 0.031, 0.038, 1)
|
||||
color_text_orange = (0.799, 0.176, 0.054, 1)
|
||||
color_text_yellow = (0.799, 0.617, 0.021, 1)
|
||||
|
||||
color_cmd = [0.8, 0.8, 0.8, 1] # blanc
|
||||
color_cmd_hl = [0.8, 0.619, 0.021, 1] # jaune
|
||||
color_link = [0.024, 0.006, 0.8, 1] # bleu
|
||||
color_link_hl = [0.8, 0.005, 0.315, 1] # majenta
|
||||
color_cmd = (0.8, 0.8, 0.8, 1) # blanc
|
||||
color_cmd_hl = (0.8, 0.619, 0.021, 1) # jaune
|
||||
color_link = (0.024, 0.006, 0.8, 1) # bleu
|
||||
color_link_hl = (0.8, 0.005, 0.315, 1) # majenta
|
||||
|
||||
# Sounds
|
||||
audiodev = aud.Device()
|
||||
@ -126,12 +133,31 @@ def text_info (text):
|
||||
|
||||
# Mise à jour de l'affichage des compteurs
|
||||
def points_maj (cont):
|
||||
|
||||
# Texte
|
||||
scene.objects['Lifes_text']['Text']=str(scene.objects['Points']['lifes'])+"/"+str(scene.objects['Points']['lifes_max'])
|
||||
scene.objects['Coins_text']['Text']=str(scene.objects['Points']['coins'])
|
||||
scene.objects['Level_text']['Text']=str(scene.objects['Points']['level'])+"/"+str(scene.objects['Points']['level_max'])
|
||||
scene.objects['Minions_text']['Text']=str(scene.objects['Points']['minions'])
|
||||
scene.objects['Points']['tics'] +=1
|
||||
|
||||
# Texte de la vague
|
||||
if scene.objects['Map_text']['anim']:
|
||||
if scene.objects['Map_text']['timer']>0:
|
||||
scene.objects['Map_text'].worldPosition.x = scene.objects['Map_text']['position_init'][0]+(scene.objects['Map_text']['position_end'][0]-scene.objects['Map_text']['position_init'][0])*(scene.objects['Map_text']['timer']/120)
|
||||
scene.objects['Map_text'].worldPosition.y = scene.objects['Map_text']['position_init'][1]+(scene.objects['Map_text']['position_end'][1]-scene.objects['Map_text']['position_init'][1])*(scene.objects['Map_text']['timer']/120)
|
||||
scene.objects['Map_text'].worldPosition.z = scene.objects['Map_text']['position_init'][2]+(scene.objects['Map_text']['position_end'][2]-scene.objects['Map_text']['position_init'][2])*(scene.objects['Map_text']['timer']/120)
|
||||
scene.objects['Map_text']['timer']-=1
|
||||
if scene.objects['Map_text']['timer']==0:
|
||||
scene.objects['Map_text'].color = color_text
|
||||
scene.objects['Map_text'].worldPosition= scene.objects['Map_text']['position_end']
|
||||
scene.objects['Map_text']['anim']=False
|
||||
|
||||
# Gestion du FPS
|
||||
# if scene.objects['Points']['tics']%60 ==0: # Toutes les 60 tics
|
||||
# print (time.localtime().tm_sec-fps_time)
|
||||
# fps_time = time.localtime().tm_sec
|
||||
|
||||
# Augmentation d'un niveau
|
||||
if scene.objects['Points']['coins']>=100:
|
||||
scene.objects['Points']['level_max'] +=1
|
||||
@ -140,7 +166,9 @@ def points_maj (cont):
|
||||
# Level trop élevé
|
||||
if scene.objects['Points']['level'] > scene.objects['Points']['level_max'] :
|
||||
scene.objects['Level_text'].color = color_text_red
|
||||
if scene.objects['Points']['level'] <= scene.objects['Points']['level_max']:
|
||||
if scene.objects['Points']['level'] < scene.objects['Points']['level_max'] :
|
||||
scene.objects['Level_text'].color = color_text_yellow
|
||||
if scene.objects['Points']['level'] == scene.objects['Points']['level_max']:
|
||||
scene.objects['Level_text'].color = color_text
|
||||
|
||||
# Ramasse minions perdues
|
||||
@ -163,6 +191,7 @@ def points_maj (cont):
|
||||
if scene.objects['Points']['lifes'] == 0 or scene.objects['Points']['wave'] == scene.objects['Terrain']['nb_waves'] :
|
||||
terrain_end ()
|
||||
else:
|
||||
scene.objects['Points']['minions']=0
|
||||
scene.objects['Points']['wave'] +=1
|
||||
ct_map.start(scene.objects['Points']['wave']) # Lancement du script de la vague
|
||||
|
||||
@ -281,8 +310,9 @@ def terrain_run ():
|
||||
scene.objects['Terrain']['thread_run']=True
|
||||
scene.objects['Points']['time_begin']=time.localtime()
|
||||
if scene.objects['Terrain']['debug_flag']==False: # Lecture dynamique du script python (risque de Segfault de Blender)
|
||||
importlib.reload(ct_cmd)
|
||||
# importlib.reload(ct_map)
|
||||
importlib.reload(ct_cmd)
|
||||
# imp.reload(ct_cmd) # Avec la bibliotèque imp
|
||||
# importlib.reload(ct_map) # Waves script
|
||||
ct_cmd.start() # Execution du script utilisateur
|
||||
ct_map.start(1) # Lancement du script de la permière vague
|
||||
|
||||
@ -340,21 +370,23 @@ def terrain_end ():
|
||||
if maptime_sec<0:
|
||||
maptime_mn-=1
|
||||
maptime_sec+=60
|
||||
scene.objects['Endbanner_wave_text']['Text']="Wave \n"+str(scene.objects['Points']['wave'])
|
||||
scene.objects['Endbanner_wave']['Text']="Wave \n"+str(scene.objects['Points']['wave'])
|
||||
if maptime_mn<=99:
|
||||
scene.objects['Endbanner_points_text']['Text']="Level "+str(scene.objects['Points']['level_max'])+"\n Time "+ str(maptime_mn)+"'"+ str(maptime_sec)+"\""
|
||||
scene.objects['Endbanner_points']['Text']="Level "+str(scene.objects['Points']['level_max'])+"\n Time "+ str(maptime_mn)+"'"+ str(maptime_sec)+"\""
|
||||
else:
|
||||
scene.objects['Endbanner_points_text']['Text']="Level "+str(scene.objects['Points']['level_max'])+"\n Time "+ str(maptime_mn)+"'"
|
||||
scene.objects['Endbanner_points']['Text']="Level "+str(scene.objects['Points']['level_max'])+"\n Time "+ str(maptime_mn)+"'"
|
||||
scene.objects['Endbanner'].color = color_endbanner_bluelight
|
||||
scene.objects['Endbanner_wave_text'].color = color_black
|
||||
scene.objects['Endbanner_points_text'].color = color_black
|
||||
scene.objects['Endbanner_ok_text'].color = color_black
|
||||
scene.objects['Endbanner_wave'].color = color_black
|
||||
scene.objects['Endbanner_points'].color = color_black
|
||||
scene.objects['Endbanner_ok'].color = color_black
|
||||
scene.objects['End'].setVisible(True,True)
|
||||
scene.objects['End']['init_localPosition']= [scene.objects['End'].localPosition.x, scene.objects['End'].localPosition.y, scene.objects['End'].localPosition.z]
|
||||
scene.objects['End'].worldPosition = [0, 1.53623, -0.892838]
|
||||
# scene.objects['End']['position_init']= scene.objects['End'].localPosition
|
||||
# scene.objects['End']['position_init']= [scene.objects['End'].localPosition.x, scene.objects['End'].localPosition.y, scene.objects['End'].localPosition.z]
|
||||
pas=0.5
|
||||
scene.objects['End'].localPosition.y=scene.objects['End'].localPosition.y-1*pas
|
||||
scene.objects['End'].localPosition.z=scene.objects['End'].localPosition.z+0.85*pas
|
||||
scene.objects['End']['timer']=scene.objects['End']['timer']+1
|
||||
scene.objects['End']['timer']+=1
|
||||
if scene.objects['End']['timer']== 40:
|
||||
scene.objects['Terrain']['map_run'] = False
|
||||
|
||||
@ -392,30 +424,28 @@ def terrain_speed (obj):
|
||||
with open("ct_config.xml", "wb") as f:
|
||||
f.write(buffer_xml)
|
||||
|
||||
# Fermer la page de fin
|
||||
# Page de fin
|
||||
def endbanner_hl(cont):
|
||||
if cont.sensors['MO'].status == JUST_ACTIVATED:
|
||||
scene.objects['Endbanner'].color = color_white
|
||||
scene.objects['Endbanner_wave_text'].color = color_white
|
||||
scene.objects['Endbanner_points_text'].color = color_white
|
||||
scene.objects['Endbanner_ok_text'].color = color_white
|
||||
scene.objects['Endbanner_wave'].color = color_white
|
||||
scene.objects['Endbanner_points'].color = color_white
|
||||
scene.objects['Endbanner_ok'].color = color_white
|
||||
if cont.sensors['MO'].status == JUST_RELEASED:
|
||||
scene.objects['Endbanner'].color = color_endbanner_bluelight
|
||||
scene.objects['Endbanner_wave_text'].color = color_black
|
||||
scene.objects['Endbanner_points_text'].color = color_black
|
||||
scene.objects['Endbanner_ok_text'].color = color_black
|
||||
scene.objects['Endbanner_wave'].color = color_black
|
||||
scene.objects['Endbanner_points'].color = color_black
|
||||
scene.objects['Endbanner_ok'].color = color_black
|
||||
|
||||
def endbanner_close(cont):
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
audiodev.play(sndbuff_click)
|
||||
scene.objects['Terrain']['manip_mode']=0
|
||||
scene.objects['End'].localPosition.y=scene.objects['End']['init_localPosition'][0]
|
||||
scene.objects['End'].localPosition.y=scene.objects['End']['init_localPosition'][1]
|
||||
scene.objects['End'].localPosition.z=scene.objects['End']['init_localPosition'][2]
|
||||
scene.objects['End'].setVisible(False,True)
|
||||
scene.objects['End'].worldPosition = [20, 1.53623, -0.892838]
|
||||
scene.objects['Endbanner'].color = [0.592, 0.68, 0.407, 1]
|
||||
scene.objects['Endbanner_wave_text'].color = color_black
|
||||
scene.objects['Endbanner_points_text'].color = color_black
|
||||
scene.objects['Endbanner_wave'].color = color_black
|
||||
scene.objects['Endbanner_points'].color = color_black
|
||||
scene.objects['End']['timer']= 0
|
||||
|
||||
###############################################################################
|
||||
@ -454,7 +484,7 @@ def cmd_hl(cont):
|
||||
|
||||
# Activation
|
||||
if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['Terrain']['manip_mode']==0:
|
||||
if obj.name!="Run" and obj.name!="Pause" and obj.name!="Run-Hl" and obj.name!="Pause-Hl" and obj.name!="Stop" and obj.name!="Stop-Hl":
|
||||
if obj.name!="Run" and obj.name!="Pause" and obj.name!="Run-Hl" and obj.name!="Pause-Hl" and obj.name!="Stop" and obj.name!="Stop-Hl" and obj.name!="About-cmd":
|
||||
obj.setVisible(False,True)
|
||||
scene.objects[obj.name+'-Hl'].setVisible(True,True)
|
||||
|
||||
@ -475,7 +505,7 @@ def cmd_hl(cont):
|
||||
|
||||
# Désactivation
|
||||
if cont.sensors['MO'].status == JUST_RELEASED and scene.objects['Terrain']['manip_mode']==0:
|
||||
if obj.name!="Run" and obj.name!="Pause" and obj.name!="Run-Hl" and obj.name!="Pause-Hl" and obj.name!="Stop" and obj.name!="Stop-Hl":
|
||||
if obj.name!="Run" and obj.name!="Pause" and obj.name!="Run-Hl" and obj.name!="Pause-Hl" and obj.name!="Stop" and obj.name!="Stop-Hl" and obj.name!="About-cmd":
|
||||
scene.objects[obj.name+'-Hl'].setVisible(False,True)
|
||||
obj.setVisible(True,True)
|
||||
|
||||
@ -504,6 +534,8 @@ def cmd_click (cont):
|
||||
terrain_stop ()
|
||||
if obj.name=="Speed_up" or obj.name=="Speed_down":
|
||||
terrain_speed (obj)
|
||||
if obj.name=="About-cmd":
|
||||
about_open ()
|
||||
|
||||
###############################################################################
|
||||
# Gestion du clavier
|
||||
@ -559,6 +591,12 @@ def mode(cont):
|
||||
if scene.objects['Terrain']['thread_run']==True:
|
||||
terrain_stop ()
|
||||
|
||||
# Touche +/- du pad -> Vitesse + ou /
|
||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.PADPLUSKEY].queue:
|
||||
terrain_speed (scene.objects['Speed_up'])
|
||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.PADMINUS].queue:
|
||||
terrain_speed (scene.objects['Speed_down'])
|
||||
|
||||
###############################################################################
|
||||
# Manipulation 3D de la scène
|
||||
###############################################################################
|
||||
@ -654,52 +692,75 @@ def manip_wheel(cont):
|
||||
scene.objects['Camera'].applyMovement((0, 0, sensibilite_wheel), True)
|
||||
|
||||
###############################################################################
|
||||
# Aide
|
||||
# About
|
||||
###############################################################################
|
||||
|
||||
# # Ouvrir la page d'aide
|
||||
# def aide(cont):
|
||||
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
# # scene.replace('Scene-Aide') # Bug Eevee -> même scene mais camera différente
|
||||
# scene.active_camera=scene.objects['Aide-Camera']
|
||||
# scene.objects['Apropos-Lien_projet'].color= color_link
|
||||
# scene.objects['Apropos-Lien_maquette'].color= color_link
|
||||
# scene.objects['Apropos-Lien_a4'].color= color_link
|
||||
# scene.objects['Apropos-Lien_blender'].color= color_link
|
||||
# scene.objects['Apropos-Lien_upbge'].color= color_link
|
||||
# scene.objects['Apropos-Lien_cc'].color= color_link
|
||||
# scene.objects['Apropos-Lien_gpl'].color= color_link
|
||||
def about_open():
|
||||
scene.objects['Aboutbanner_title'].color = color_black
|
||||
scene.objects['Aboutbanner_text'].color = color_black
|
||||
scene.objects['About_link_git'].color= color_link
|
||||
scene.objects['About_link_gpl'].color= color_link
|
||||
scene.objects['About_link_blender'].color= color_link
|
||||
scene.objects['About_link_upbge'].color= color_link
|
||||
scene.objects['About_link_kay'].color= color_link
|
||||
scene.objects['About_link_kenney'].color= color_link
|
||||
scene.objects['About'].setVisible(True,True)
|
||||
scene.objects['About'].worldPosition = [0, 1.53623, -0.892838]
|
||||
scene.objects['About']['timer'] = 0
|
||||
scene.objects['About']['anim'] = True
|
||||
|
||||
# # Fermer la page d'aide
|
||||
# def aide_fermer(cont):
|
||||
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
# # bge.logic.addScene('Scene') # Bug Eevee -> même scene mais camera différente
|
||||
# scene.active_camera=scene.objects['Camera']
|
||||
def about_open_anim():
|
||||
pas=0.5
|
||||
scene.objects['About'].localPosition.y=scene.objects['About'].localPosition.y-1*pas
|
||||
scene.objects['About'].localPosition.z=scene.objects['About'].localPosition.z+0.85*pas
|
||||
scene.objects['About']['timer']+=1
|
||||
if scene.objects['About']['timer']== 40:
|
||||
scene.objects['About']['anim'] = False
|
||||
|
||||
# # Aller sur les liens
|
||||
# def aide_apropos(cont):
|
||||
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
# obj = cont.owner
|
||||
# if obj.name == "Apropos-Lien_maquette" :
|
||||
# webbrowser.open('https://www.a4.fr/wiki/')
|
||||
# if obj.name == "Apropos-Lien_projet" :
|
||||
# webbrowser.open('https://gitlab.com/blender-edutech')
|
||||
# if obj.name == "Apropos-Lien_a4" :
|
||||
# webbrowser.open('https://www.a4.fr')
|
||||
# if obj.name == "Apropos-Lien_blender" :
|
||||
# webbrowser.open('https://blender.org')
|
||||
# if obj.name == "Apropos-Lien_upbge" :
|
||||
# webbrowser.open('https://upbge.org')
|
||||
# if obj.name == "Apropos-Lien_cc" :
|
||||
# webbrowser.open('https://creativecommons.org/licenses/by-sa/4.0/')
|
||||
# if obj.name == "Apropos-Lien_gpl" :
|
||||
# webbrowser.open('https://www.gnu.org/licenses/gpl-3.0.html')
|
||||
def about_hl(cont):
|
||||
if cont.sensors['MO'].status == JUST_ACTIVATED:
|
||||
scene.objects['Aboutbanner'].color = color_white
|
||||
scene.objects['Aboutbanner_ok'].color = color_white
|
||||
scene.objects['Aboutbanner_title'].color = color_white
|
||||
if cont.sensors['MO'].status == JUST_RELEASED:
|
||||
scene.objects['Aboutbanner'].color = color_endbanner_bluelight
|
||||
scene.objects['Aboutbanner_ok'].color = color_black
|
||||
scene.objects['Aboutbanner_title'].color = color_black
|
||||
|
||||
def about_close(cont):
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
audiodev.play(sndbuff_click)
|
||||
scene.objects['Terrain']['manip_mode']=0
|
||||
scene.objects['About'].setVisible(False,True)
|
||||
scene.objects['About'].worldPosition = [22, 1.53623, -0.892838]
|
||||
scene.objects['Aboutbanner'].color = [0.592, 0.68, 0.407, 1]
|
||||
scene.objects['About']['timer']= 0
|
||||
|
||||
def about_link(cont):
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
||||
obj = cont.owner
|
||||
if obj.name == "About_link_git-colbox" :
|
||||
webbrowser.open('https://gitlab.com/phroy/codetower')
|
||||
if obj.name == "About_link_gpl-colbox" :
|
||||
webbrowser.open('https://www.gnu.org/licenses/gpl-3.0.html')
|
||||
if obj.name == "About_link_blender-colbox" :
|
||||
webbrowser.open('https://www.blender.org')
|
||||
if obj.name == "About_link_upbge-colbox" :
|
||||
webbrowser.open('https://www.upbge.org')
|
||||
if obj.name == "About_link_kay-colbox" :
|
||||
webbrowser.open('https://www.kaylousberg.com')
|
||||
if obj.name == "About_link_kenney-colbox" :
|
||||
webbrowser.open('https://www.kenney.nl')
|
||||
if obj.name == "About_link_blender-colbox" :
|
||||
webbrowser.open('https://www.blender.org')
|
||||
|
||||
def about_link_hl(cont):
|
||||
if cont.sensors['MO'].status == JUST_ACTIVATED :
|
||||
obj = cont.owner
|
||||
name=obj.name[:-7]
|
||||
scene.objects[name].color = color_link_hl
|
||||
if cont.sensors['MO'].status == JUST_RELEASED :
|
||||
obj = cont.owner
|
||||
name=obj.name[:-7]
|
||||
scene.objects[name].color = color_link
|
||||
|
||||
# # Le highlight des liens
|
||||
# def aide_apropos_hl(cont):
|
||||
# if cont.sensors['MO'].status == JUST_ACTIVATED :
|
||||
# obj = cont.owner
|
||||
# obj.color = color_link_hl
|
||||
# if cont.sensors['MO'].status == JUST_RELEASED :
|
||||
# obj = cont.owner
|
||||
# obj.color = color_link
|
||||
|
25
ct_cmd.py
25
ct_cmd.py
@ -15,14 +15,14 @@ from ct_lib import * # Bibliothèque CodeTower
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
purple = [0.202, 0.114, 0.521,1]
|
||||
turquoise = [0.051, 0.270, 0.279,1]
|
||||
magenta = [0.799, 0.005, 0.314,1]
|
||||
orange = [0.799, 0.130, 0.063,1]
|
||||
yellow = [0.799, 0.617, 0.021, 1]
|
||||
green = [0.246, 0.687, 0.078, 1]
|
||||
red = [0.799, 0.031, 0.038, 1]
|
||||
blue = [0.127, 0.456, 1.000, 1]
|
||||
purple = (0.202, 0.114, 0.521,1)
|
||||
turquoise = (0.051, 0.270, 0.279,1)
|
||||
magenta = (0.799, 0.005, 0.314,1)
|
||||
orange = (0.799, 0.130, 0.063,1)
|
||||
yellow = (0.799, 0.617, 0.021, 1)
|
||||
green = (0.246, 0.687, 0.078, 1)
|
||||
red = (0.799, 0.031, 0.038, 1)
|
||||
blue = (0.127, 0.456, 1.000, 1)
|
||||
|
||||
###############################################################################
|
||||
# En: Threads management << DONT CHANGE THIS SECTION >>
|
||||
@ -76,14 +76,13 @@ def commands():
|
||||
|
||||
while True:
|
||||
|
||||
if ct_level()==1:
|
||||
if ct_level() == 1:
|
||||
ct_build(4,5, "Archer tower", "Tower #1", blue, "square-A")
|
||||
|
||||
if ct_level()==1:
|
||||
|
||||
if ct_level()==3:
|
||||
ct_build(4,-2, "Archer tower", "Tower #2", blue, "square-A")
|
||||
|
||||
if ct_level()==3:
|
||||
if ct_level()==2:
|
||||
ct_build(5,5, "Mage tower", "Tower #3", magenta, "square-B")
|
||||
|
||||
|
||||
end() # End of cycle << DONT CHANGE THIS LINE >>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<data>
|
||||
<config>
|
||||
<speed>4.0</speed>
|
||||
<speed>2.0</speed>
|
||||
</config>
|
||||
</data>
|
114
ct_lib.py
114
ct_lib.py
@ -30,21 +30,26 @@ import random
|
||||
scene = bge.logic.getCurrentScene()
|
||||
|
||||
# Colors
|
||||
tower_purple = [0.202, 0.114, 0.521,1]
|
||||
tower_turquoise = [0.051, 0.270, 0.279,1]
|
||||
tower_magenta = [0.799, 0.005, 0.314,1]
|
||||
tower_orange = [0.799, 0.130, 0.063,1]
|
||||
tower_yellow = [0.799, 0.617, 0.021, 1]
|
||||
tower_green = [0.246, 0.687, 0.078, 1]
|
||||
tower_red = [0.799, 0.031, 0.038, 1]
|
||||
tower_blue = [0.127, 0.456, 1.000, 1]
|
||||
tower_black = [0, 0, 0, 1]
|
||||
tower_purple = (0.202, 0.114, 0.521,1)
|
||||
tower_turquoise = (0.051, 0.270, 0.279,1)
|
||||
tower_magenta = (0.799, 0.005, 0.314,1)
|
||||
tower_orange = (0.799, 0.130, 0.063,1)
|
||||
tower_yellow = (0.799, 0.617, 0.021, 1)
|
||||
tower_green = (0.246, 0.687, 0.078, 1)
|
||||
tower_red = (0.799, 0.031, 0.038, 1)
|
||||
tower_blue = (0.127, 0.456, 1.000, 1)
|
||||
tower_black = (0, 0, 0, 1)
|
||||
|
||||
ray_yellow = [0.799, 0.617, 0.021, 1] # [0.8, 0.619, 0.021])
|
||||
ray_blue = [0.127, 0.456, 1.000, 1]
|
||||
ray_black = [0, 0, 0, 1]
|
||||
color_text = (0, 0, 0, 1) # Noir
|
||||
color_text_red = (0.799, 0.031, 0.038, 1)
|
||||
color_text_orange = (0.799, 0.176, 0.054, 1)
|
||||
color_text_yellow = (0.799, 0.617, 0.021, 1)
|
||||
|
||||
color_kaykit_black = [0.019, 0.032, 0.037, 1]
|
||||
ray_yellow = (0.799, 0.617, 0.021, 1) # [0.8, 0.619, 0.021])
|
||||
ray_blue = (0.127, 0.456, 1.000, 1)
|
||||
ray_black = (0, 0, 0, 1)
|
||||
|
||||
color_kaykit_black = (0.019, 0.032, 0.037, 1)
|
||||
|
||||
# Sounds
|
||||
audiodev = aud.Device()
|
||||
@ -163,6 +168,9 @@ def ct_minion_details(x,y,cat,level,body="Knight_m_A_common"):
|
||||
minion.name="wm("+str(scene.objects['Terrain']['idm'])+")" # Wave minion (wm), identifier minion (idm)
|
||||
scene.objects['Points']['minions'] +=1
|
||||
scene.objects['Points']['minions_run'] +=1
|
||||
minion['dist']=0.0
|
||||
minion['dist_last_x']=x
|
||||
minion['dist_last_y']=y
|
||||
|
||||
# Caracteristics
|
||||
minion_carac= scene.objects['Terrain']['minion_carac']
|
||||
@ -193,7 +201,7 @@ def scn_minion_dead(cont):
|
||||
obj.endObject()
|
||||
|
||||
###############################################################################
|
||||
# Spells
|
||||
# Spells / Casts
|
||||
###############################################################################
|
||||
|
||||
# Buff/debuff Minion
|
||||
@ -202,6 +210,11 @@ def scn_minion_affect(cont):
|
||||
# print (obj.name, obj['buff'])
|
||||
slow_state=False
|
||||
|
||||
# Distance parcourue
|
||||
obj['dist']=obj['dist']+ math.sqrt((obj.worldPosition.x-obj['dist_last_x'])**2+(obj.worldPosition.y-obj['dist_last_y'])**2)
|
||||
obj['dist_last_x']=obj.worldPosition.x
|
||||
obj['dist_last_y']=obj.worldPosition.y
|
||||
|
||||
# Etats actif
|
||||
for debuff_i in obj['buff']:
|
||||
if debuff_i[1] <= 0:
|
||||
@ -277,6 +290,8 @@ def ct_build_details(x,y, cat='Archer tower', tower_name="Tower", color=tower_pu
|
||||
tour['techno']=[]
|
||||
tour['cast']="slow"
|
||||
tour['cast_duration']=2
|
||||
tour['target']=[]
|
||||
tour['target_past']=[]
|
||||
|
||||
# Capteur Near
|
||||
tour.sensors['Near'].distance=tour['range']
|
||||
@ -298,9 +313,57 @@ def scn_tower_near(cont):
|
||||
sensor = obj.sensors['Near']
|
||||
|
||||
# Tir
|
||||
# FIXME: tir sur le plus avancé
|
||||
if sensor.positive and len(sensor.hitObjectList)>0 and scene.objects['Terrain']['run']==True :
|
||||
|
||||
# Tir sur le plus avancé basé sur les distances parcourues
|
||||
target=sensor.hitObjectList[0]
|
||||
target_dist = target['dist']
|
||||
for obj_i in sensor.hitObjectList:
|
||||
if obj_i['dist']> target_dist:
|
||||
target=obj_i
|
||||
target_dist = target['dist']
|
||||
|
||||
# Tir sur le plus avancé basé sur l'ordre de passage
|
||||
# target=sensor.hitObjectList[0]
|
||||
# target_id = target['navPosition']
|
||||
# for obj_i in sensor.hitObjectList:
|
||||
# if obj_i['navPosition']< target_id:
|
||||
# target=obj_i
|
||||
# target_id = target['navPosition']
|
||||
|
||||
# Tir sur le plus avancé basé sur les distances par rapport à la tour -> ne marche pas
|
||||
# target=sensor.hitObjectList[0]
|
||||
# if len(sensor.hitObjectList)>1:
|
||||
# target_eloignement = False
|
||||
# target_distance_eloignement = 0
|
||||
# target_distance_approche = 100
|
||||
# print ("detection:",sensor.hitObjectList)
|
||||
# for obj_i in sensor.hitObjectList:
|
||||
# for obj_j in obj['target_past']:
|
||||
# if obj_j[0]==obj_i.name:
|
||||
# print ("name :", obj_j[0], "distance :", obj.getDistanceTo(obj_i), "distance old :", obj_j[1], "ecart :", obj.getDistanceTo(obj_i) - obj_j[1])
|
||||
# # Éloignement
|
||||
# if obj.getDistanceTo(obj_i) - obj_j[1] > 0: # Ecart de distance
|
||||
# target_eloignement = True
|
||||
# if obj.getDistanceTo(obj_i) > target_distance_eloignement:
|
||||
# target=obj_i
|
||||
# target_distance_eloignement = obj.getDistanceTo(obj_i)
|
||||
# # Approche
|
||||
# else:
|
||||
# if target_eloignement == False:
|
||||
# if obj.getDistanceTo(obj_i) < target_distance_approche:
|
||||
# target=obj_i
|
||||
# target_distance_approche = obj.getDistanceTo(obj_i)
|
||||
# if target_eloignement == True:
|
||||
# print ("Eloignement : target:", target.name, "distance :", obj.getDistanceTo(target))
|
||||
# print ("")
|
||||
# else:
|
||||
# print ("Approche : target:", target.name, "distance :", obj.getDistanceTo(target))
|
||||
# print ("")
|
||||
# obj['target_past']=[]
|
||||
# for obj_i in sensor.hitObjectList:
|
||||
# obj['target_past'].append([obj_i.name, obj.getDistanceTo(obj_i)])
|
||||
|
||||
|
||||
# Orientation du tower minion
|
||||
towerminion="tm("+str(round(obj.worldPosition.x))+','+str(round(obj.worldPosition.y))+")"
|
||||
@ -365,6 +428,22 @@ def scn_tower_near(cont):
|
||||
# Carte
|
||||
###############################################################################
|
||||
|
||||
# Texte de carte
|
||||
def ct_map_text_wave(wave):
|
||||
scene.objects['Map_text']['Text']=("Wave " + str(wave))
|
||||
scene.objects['Map_text'].setVisible(True,False)
|
||||
scene.objects['Map_text'].color = color_text_yellow
|
||||
scene.objects['Map_text']['timer']=120
|
||||
scene.objects['Map_text']['position_init']=[8.22904, -2.86185, 6.07395]
|
||||
scene.objects['Map_text']['position_end']=[11.1751, 5.99318, 0.480557]
|
||||
scene.objects['Map_text'].worldPosition= scene.objects['Map_text']['position_init']
|
||||
scene.objects['Map_text']['anim']=True
|
||||
|
||||
# Texte de carte
|
||||
def ct_map_text(text):
|
||||
scene.objects['Map_text']['Text']=text
|
||||
scene.objects['Map_text'].setVisible(True,False)
|
||||
|
||||
# Fin
|
||||
def ct_map_end(x,y):
|
||||
mapend= scene.addObject("Map_end", scene.objects['Terrain'])
|
||||
@ -446,11 +525,6 @@ def ct_print (text):
|
||||
scene.objects['Text_info-1']['Text']=lines_txt[0]+"\n"+lines_txt[1]+"\n"+lines_txt[2]
|
||||
scene.objects['Text_info-2']['Text']=lines_txt[3]+"\n"+lines_txt[4]+"\n"+lines_txt[5]
|
||||
|
||||
# Texte de carte
|
||||
def ct_map_text(text):
|
||||
scene.objects['Map_text']['Text']=text
|
||||
scene.objects['Map_text'].setVisible(True,False)
|
||||
|
||||
###############################################################################
|
||||
# Dessin bas niveau (bge.render.drawLine)
|
||||
###############################################################################
|
||||
|
28
ct_map1.py
28
ct_map1.py
@ -1,5 +1,7 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
import bpy # Blender
|
||||
from ct_lib import * # Bibliothèque CodeTower
|
||||
import os
|
||||
|
||||
###############################################################################
|
||||
# ct_map1.py
|
||||
@ -119,25 +121,28 @@ def minion_definition():
|
||||
|
||||
# Wave 1
|
||||
def wave1():
|
||||
ct_map_text("Wave 1")
|
||||
ct_map_text_wave(1)
|
||||
for i in range (15):
|
||||
ct_minion_details(14,3,"Orc",1, "Orc_A_common")
|
||||
ct_minion(14,3,"Orc",1)
|
||||
# ct_minion_details(14,3,"Orc",1, "Orc_A_common")
|
||||
ct_sleep (2)
|
||||
end()
|
||||
|
||||
# Wave 2
|
||||
def wave2():
|
||||
ct_map_text("Wave 2")
|
||||
ct_map_text_wave(2)
|
||||
for i in range (20):
|
||||
ct_minion_details(14,3,"Orc",1, "Orc_A_common")
|
||||
ct_minion(14,3,"Orc",1)
|
||||
# ct_minion_details(14,3,"Orc",1, "Orc_A_common")
|
||||
ct_sleep (1)
|
||||
end()
|
||||
|
||||
# Wave 3
|
||||
def wave3():
|
||||
ct_map_text("Wave 3")
|
||||
ct_map_text_wave(3)
|
||||
for i in range (30):
|
||||
ct_minion_details(14,3,"Orc",1, "Orc_A_common")
|
||||
ct_minion(14,3,"Orc",1)
|
||||
# ct_minion_details(14,3,"Orc",1, "Orc_A_common")
|
||||
# ct_minion(14,3,"Knight",1)
|
||||
ct_sleep (1)
|
||||
end()
|
||||
@ -172,12 +177,23 @@ def tower_definition():
|
||||
|
||||
# Initialization
|
||||
def map_init():
|
||||
|
||||
# Base
|
||||
scene.objects['Terrain']['size'] = [-15,15,-10,10] # Map size
|
||||
scene.objects['Terrain']['navmesh'] = "Navmesh.004" # Navmesh
|
||||
minion_definition()
|
||||
tower_definition()
|
||||
scene.objects['Terrain']['nb_waves'] = 3 # Number of waves
|
||||
|
||||
# Landscape
|
||||
file_path = 'asset/map/map1-landscape.blend'
|
||||
inner_path = 'Object'
|
||||
object_name = 'Landscape'
|
||||
bpy.ops.wm.append(
|
||||
filepath=os.path.join(file_path, inner_path, object_name),
|
||||
directory=os.path.join(file_path, inner_path),
|
||||
filename=object_name)
|
||||
|
||||
# Ajout des sorties
|
||||
scene.objects['Terrain']['endtile'] = "tile_straight.036"
|
||||
ct_map_end(1,-10)
|
||||
|
Loading…
Reference in New Issue
Block a user