codetower/ct_waves.py

88 lines
2.6 KiB
Python

import bge # Bibliothèque Blender Game Engine (UPBGE)
from ct_lib import * # Bibliothèque CodeTower
###############################################################################
# ct_waves.py
# @title: Waves for the CodeTower game
# @project: CodeTower
# @lang: fr,en
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2022 Philippe Roy
# @license: GNU GPL
#
# This game is a tower defense coding game. The towers are driven with Python code.
#
# The file is the the waves definition
#
###############################################################################
###############################################################################
# En: Threads management << DONT CHANGE THIS SECTION >>
# Fr: Gestion des tâches (threads) << NE PAS MODIFIER CETTE SECTION >>
###############################################################################
threads=[]
scene = bge.logic.getCurrentScene()
def start():
scene.objects['Terrain']['thread_wave']=True
thread_start(threads, "waves", waves)
def stop():
thread_stop(threads, "waves")
###############################################################################
# En: Waves commands
# Fr: Commandes des vagues
#
# Spawn a minion : ct_minion (x, y, cat, level)
# - x spwan position (integer)
# - y spwan position (integer)
# - cat : minion class (string) :
# - Knight
# - Barbarian
# - Warrior
# - Mage
# - Rogue
# - Orc
# - Squelette
# - level (1, 2 or 3)
#
# Time management (temporization) : ct_tempo(delay)
# - delay : delay in seconds (integer)
#
# UI management : ct_map_text(text)
# - text for the wave label
#
#
###############################################################################
# Minion caracteristics : category (class), level, hp, speed, armor, bounty, lifes_damage
# carac_minion={
# 'Knight-lv1' : ["Knight", 1 , 2.0, 1.0, 0.0, 5,1],
# 'Knight-lv2' : ["Knight", 2, 4.0, 1.0, 1.0, 20,1],
# 'Knight-lv3' : ["Knight", 3, 8.0, 1.0, 2.0, 80,1]}
def waves():
# Wave 1
ct_map_text("Wave 1")
for i in range (15):
ct_minion(14,3,"Knight",1)
# ct_tempo_wave (1)
ct_sleep (1)
ct_tempo_wave (20)
# # Wave 2
ct_map_text("Wave 2")
for i in range (20):
ct_minion(14,3,"Knight",1)
ct_sleep (1)
ct_sleep (2)
# ct_tempo_wave (2)
print ("Threads waves #", len(threads)-1, "are arrived -> close them.") # Thread closed << DONT CHANGE THIS LINE >>
scene.objects['Terrain']['thread_wave']=False # End of cycle << DONT CHANGE THIS LINE >>