mirror of
https://forge.apps.education.fr/phroy/codetower.git
synced 2024-01-27 11:35:17 +01:00
Bugfix : wave text animation
This commit is contained in:
parent
2e145dfd61
commit
ce25cd95ec
@ -46,4 +46,4 @@ The Python script is the file **ct_cmd.py** (in the game folder), you have to ed
|
||||
- Return your level (integer)
|
||||
|
||||
* **Time management (temporization) : ct_sleep (delay)**
|
||||
- delay : delay in seconds (float)
|
||||
- delay : duration in seconds (float)
|
||||
|
Binary file not shown.
45
ct.py
45
ct.py
@ -35,6 +35,11 @@ import ct_map1 as ct_map # waves script
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Debug flag
|
||||
scene = bge.logic.getCurrentScene()
|
||||
scene.objects['Commands']['debug_fps']=False
|
||||
|
||||
# Memory
|
||||
sys.setrecursionlimit(10**5) # Limite sur la récursivité (valeur par défaut : 1000) -> segfault de Blender
|
||||
|
||||
# Dynamic import user file
|
||||
@ -43,7 +48,6 @@ sys.setrecursionlimit(10**5) # Limite sur la récursivité (valeur par défaut
|
||||
# ct_cmd = importlib.import_module('ct_cmd') # User script (commands) -> segfault de Blender
|
||||
|
||||
# UPBGE scene
|
||||
scene = bge.logic.getCurrentScene()
|
||||
eevee = bpy.context.scene.eevee
|
||||
fps_time=0.0
|
||||
|
||||
@ -139,7 +143,7 @@ def points_maj (cont):
|
||||
|
||||
global fps_time
|
||||
|
||||
# Synchronisation des threads
|
||||
# Synchronisation des threads : attente dela création d'une tour ou de l'apparition d'un minion
|
||||
while scene.objects['Terrain']['thread_cmd_lock'] == True:
|
||||
# print ("UPBGE : thread_cmd_lock =True")
|
||||
time.sleep(0.01)
|
||||
@ -153,23 +157,33 @@ def points_maj (cont):
|
||||
|
||||
# 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:
|
||||
if scene.objects['Map_text']['timer']<120:
|
||||
scene.objects['Map_text'].worldPosition.x += scene.objects['Map_text']['position_delta'][0]
|
||||
scene.objects['Map_text'].worldPosition.y += scene.objects['Map_text']['position_delta'][1]
|
||||
scene.objects['Map_text'].worldPosition.z += scene.objects['Map_text']['position_delta'][2]
|
||||
# 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)
|
||||
print (scene.objects['Map_text']['position_init'])
|
||||
print (scene.objects['Map_text']['timer'])
|
||||
scene.objects['Map_text']['timer']+=1
|
||||
if int(scene.objects['Map_text']['timer'])>=120:
|
||||
scene.objects['Map_text'].color = color_text
|
||||
scene.objects['Map_text'].worldPosition= scene.objects['Map_text']['position_end']
|
||||
scene.objects['Map_text'].worldPosition= scene.objects['Map_text']['position_init']
|
||||
scene.objects['Map_text']['anim']=False
|
||||
print (scene.objects['Map_text']['position_init'])
|
||||
print (scene.objects['Map_text']['timer'])
|
||||
|
||||
# Gestion du FPS
|
||||
# Gestion du FPS - Tous les tics
|
||||
if scene.objects['Commands']['debug_fps']:
|
||||
if scene.objects['Points']['tics']%60 ==0: # Toutes les 60 tics
|
||||
milliseconds = int(time.time() * 1000)
|
||||
print (milliseconds-fps_time)
|
||||
print ("Tics/second, coins :", milliseconds-fps_time, str(scene.objects['Points']['coins']))
|
||||
fps_time = milliseconds
|
||||
# if scene.objects['Points']['tics']%60 ==0: # Toutes les 60 tics
|
||||
milliseconds = int(time.time() * 1000) # Tous les tics
|
||||
if milliseconds != fps_time:
|
||||
fps = int(1000/(milliseconds-fps_time))
|
||||
else:
|
||||
fps= "----"
|
||||
print ("Durée entre deux tics (16 ms), fps (60), coins :", milliseconds-fps_time, fps, str(scene.objects['Points']['coins']))
|
||||
fps_time = milliseconds
|
||||
|
||||
# Augmentation d'un niveau
|
||||
if scene.objects['Points']['coins']>=100:
|
||||
@ -851,7 +865,6 @@ def applyRotationTo(obj, rx=None, ry=None, rz=None, Local=True):
|
||||
|
||||
# Reset de la manipulation de la vue
|
||||
def manip_reset():
|
||||
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Terrain']['manip_mode']==0:
|
||||
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['init_lx']
|
||||
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['init_ly']
|
||||
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz']
|
||||
|
@ -1,6 +1,6 @@
|
||||
<data>
|
||||
<config>
|
||||
<speed>4.0</speed>
|
||||
<sound>True</sound>
|
||||
<speed>2.0</speed>
|
||||
<sound>False</sound>
|
||||
</config>
|
||||
</data>
|
45
ct_lib.py
45
ct_lib.py
@ -189,11 +189,14 @@ def ct_minion_details(x,y,cat,level,body="Knight_m_A_common"):
|
||||
while scene.objects['Terrain']['run'] == False:
|
||||
time.sleep(0.01)
|
||||
|
||||
# Synchronisation des threads
|
||||
# Synchronisation des threads : attente de la création d'une tour
|
||||
while scene.objects['Terrain']['thread_cmd_lock'] == True:
|
||||
# print ("ct_minion : thread_cmd_lock =True")
|
||||
time.sleep(0.01)
|
||||
|
||||
# Blocage des autres threads pendant l'apparition du minion
|
||||
scene.objects['Terrain']['thread_cmd_lock'] = True
|
||||
|
||||
# Object 3D
|
||||
minion= scene.addObject(body, scene.objects['Terrain'])
|
||||
minion.worldScale=[0.25,0.25,0.25]
|
||||
@ -231,6 +234,9 @@ def ct_minion_details(x,y,cat,level,body="Knight_m_A_common"):
|
||||
# minion.actuators['Steering'].distance=0.5
|
||||
minion.actuators['Steering'].velocity=minion['speed_base']*scene.objects['Terrain']['speed']
|
||||
|
||||
# Déblocage des autres threads après l'apparition du minion
|
||||
scene.objects['Terrain']['thread_cmd_lock'] = False
|
||||
|
||||
# Destruction d'un minion
|
||||
def scn_minion_dead(cont):
|
||||
obj = cont.owner
|
||||
@ -257,6 +263,9 @@ def scn_minion_affect(cont):
|
||||
obj['dist_last_x']=obj.worldPosition.x
|
||||
obj['dist_last_y']=obj.worldPosition.y
|
||||
|
||||
# Lod
|
||||
# print(obj.currentLodLevel)
|
||||
|
||||
# Etats actif
|
||||
for debuff_i in obj['buff']:
|
||||
if debuff_i[1] <= 0:
|
||||
@ -346,6 +355,7 @@ def ct_build_details(x,y, cat='Archer tower', tower_name="Tower", color=tower_pu
|
||||
tour.sensors['Near'].distance=tour['range']
|
||||
tour.sensors['Near'].skippedTicks =round(1/(tour['speed']*scene.objects['Terrain']['speed']))
|
||||
|
||||
# Déblocage des autres threads après la construction
|
||||
scene.objects['Terrain']['thread_cmd_lock'] = False
|
||||
return True
|
||||
|
||||
@ -484,11 +494,36 @@ 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.37716, -2.39401, 5.56759]
|
||||
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']['timer']=0
|
||||
# scene.objects['Map_text']['position_init']=[8.37716, -2.39401, 5.56759]
|
||||
# scene.objects['Map_text']['position_end']=[11.1751, 5.99318, 0.480557]
|
||||
scene.objects['Map_text']['position_init']=[0,0,0]
|
||||
scene.objects['Map_text']['position_init'][0]=scene.objects['Points'].worldPosition.x+(11.1751-11.5819)
|
||||
scene.objects['Map_text']['position_init'][1]=scene.objects['Points'].worldPosition.y+(5.99318-7.25838)
|
||||
scene.objects['Map_text']['position_init'][2]=scene.objects['Points'].worldPosition.z+(0.480557-1.23784)
|
||||
scene.objects['Map_text']['position_delta']=[-2.79794/120, -8.38719/120, 5.087033/120]
|
||||
|
||||
# 11.5819 m
|
||||
# 7.25838 m
|
||||
# 1.23784 m
|
||||
|
||||
# scene.objects['Map_text']['position_end']=scene.objects['Map_text'].worldPosition
|
||||
# scene.objects['Map_text']['position_init']=scene.objects['Map_text'].worldPosition
|
||||
# scene.objects['Map_text']['position_init'][0]=scene.objects['Map_text']['position_end'][0]-scene.objects['Map_text']['position_delta'][0]
|
||||
# scene.objects['Map_text']['position_init'][1]=scene.objects['Map_text']['position_end'][1]-scene.objects['Map_text']['position_delta'][1]
|
||||
# scene.objects['Map_text']['position_init'][2]=scene.objects['Map_text']['position_end'][2]-scene.objects['Map_text']['position_delta'][2]
|
||||
# scene.objects['Map_text'].worldPosition=scene.objects['Map_text']['position_init']
|
||||
scene.objects['Map_text']['anim']=True
|
||||
print (scene.objects['Map_text']['position_init'])
|
||||
print (scene.objects['Map_text']['timer'])
|
||||
|
||||
# scene.objects['Map_text']['position_end']=scene.objects['Map_text'].worldPosition
|
||||
# scene.objects['Map_text']['position_init']=[0,0,0]
|
||||
# scene.objects['Map_text']['position_init'][0]=scene.objects['Map_text']['position_end'][0]-scene.objects['Map_text']['position_delta'][0]
|
||||
# scene.objects['Map_text']['position_init'][1]=scene.objects['Map_text']['position_end'][1]-scene.objects['Map_text']['position_delta'][1]
|
||||
# scene.objects['Map_text']['position_init'][2]=scene.objects['Map_text']['position_end'][2]-scene.objects['Map_text']['position_delta'][2]
|
||||
# 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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user