« Soya/Python game skel-2 » : différence entre les versions
Contenu supprimé Contenu ajouté
Création : <pre># -*- indent-tabs-mode: t -*- #! /usr/bin/python -O # Game Skeleton # Copyright (C) 2003-2004 Jean-Baptiste LAMY # # This program is free software; you can redistribute it and/or ... |
m Robot : Changement de type cosmétique |
||
Ligne 13 :
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# Soya gaming tutorial, lesson 2
Ligne 48 :
# Les actions disponibles
# Pour plus d'actions complexe, vous devez faire une sous classe "Action".
ACTION_WAIT
ACTION_ADVANCE
ACTION_ADVANCE_LEFT
ACTION_ADVANCE_RIGHT = 3
ACTION_TURN_LEFT
ACTION_TURN_RIGHT
ACTION_GO_BACK
ACTION_GO_BACK_LEFT
ACTION_GO_BACK_RIGHT = 8
Ligne 68 :
"""Retourne l'action suivante"""
for event in soya.process_event():
if
if
sys.exit() # Quit the game
elif event[1] == sdlconst.K_LEFT:
elif event[1] == sdlconst.K_RIGHT: self.right_key_down = 1
elif event[1] == sdlconst.K_UP:
elif event[1] == sdlconst.K_DOWN:
elif event[0] == sdlconst.KEYUP:
if
elif event[1] == sdlconst.K_RIGHT: self.right_key_down = 0
elif event[1] == sdlconst.K_UP:
elif event[1] == sdlconst.K_DOWN:
# Les gens disent que Python n'a pas de switch/select case et c'est faux !
Ligne 128 :
def begin_round(self):
"""Cette méthode est appellée par la MainLoop chaque fois qu'un round commence. Soya
Actuellement, tous les round ne durent pas exactement 30ms, mais il retourne True à un point global de la vue. Exemple, 1000 rounds feront 1000 * 30ms."""
# Appel d'une nouvelle action venant d'un controlleur, et la commence.
Ligne 147 :
# Determination de la rotation du personnage
if
self.rotation_speed = 5.0
elif action.action in (ACTION_TURN_RIGHT, ACTION_ADVANCE_RIGHT, ACTION_GO_BACK_RIGHT):
Ligne 153 :
# Determination de la vitesse du personnage
if
self.speed.z = -0.35
elif action.action in (ACTION_GO_BACK, ACTION_GO_BACK_LEFT, ACTION_GO_BACK_RIGHT):
|