« Soya/Python base 3 » : différence entre les versions

Contenu supprimé Contenu ajouté
Seb.bernery (discussion | contributions)
Aucun résumé des modifications
Seb.bernery (discussion | contributions)
Aucun résumé des modifications
Ligne 66 :
self.speed = soya.Vector(self, 0.0, 0.0, -0.2)
# TheLa currentvitesse de rotation speedactuelle (aroundsur Yl'axe axisY)
self.rotation_speed = 0.0
# LikeTel que advance_time, begin_round isest appellé calledpar byla theboucle main_loopprincipale.
# ButMais contrarycontrairement toà advance_time, begin_round isest calledappellé regularlyrégulièrement, atau thedébut beginningde ofchaque eachround
# round ; thuscelui itci receiverecoit no 'proportion'un argument non "proportionnel".
# DecisionLes processdécisions shoulddoivent occursêtre inprises dans le begin_round.
def begin_round(self):
# CallsAppel thede la super implementationimplémentation.
soya.Body.begin_round(self)
# ComputesCalcul thede newla nouvelle vitesse de rotation speed: a randomun angle betweenaléatoire entre -25.0 andet 25.0 degreesdegrés.
self.rotation_speed = random.uniform(-25.0, 25.0)
# TheLa speedvitesse vectordes doesnvecteurs n'ta needpas tobesoin bed'être recomputedrecalculée, sincetel itqu'il isest expressedexprimé indans thele Head
# système de coordonnées de Head
# CoordSyst.
# InDans advance_time, wenous makeallons thefaire un head advanceamélioré.
def advance_time(self, proportion):
soya.Body.advance_time(self, proportion)
# PerformsExecution thede la rotation, takingil intofaut accounttenir thecompte proportionde l'argument de proportion.
self.rotate_y(proportion * self.rotation_speed)
# MovesDéplaçons thele headHead accordinggrâce toau thevecteur speedde vectorvitesse.
# add_mul_vector isest identicalidentique to:à self.add_vector(proportion * self.speed), butmais fasterplus rapide.
# TheLe speedvecteur vectorde andvitesse theet le Head arene notsont inpas thedans samele coordinatemême system,système butde Soyacoordonnées, automaticallymais
# performsSoya thefait neededautomatiquement la conversion nécéssaire.
self.add_mul_vector(proportion, self.speed)
 
 
# CreatesCréation adu Head indans thela scenescène.
 
head = Head(scene)
 
# CreatesCréation ad'une lightlampe.
 
light = soya.Light(scene)