Permalink
Browse files

ai poller and cars' preloader

  • Loading branch information...
cflavio committed Sep 27, 2017
1 parent 493dd12 commit 73287d3d8de8e76ba7e909812a95a3c8f6bb1946
Showing with 36 additions and 14 deletions.
  1. +22 −0 yorg/fsm.py
  2. +1 −12 yorg/logic.py
  3. +12 −1 yorg/yorg.py
  4. +1 −1 yyagl
View
@@ -1,4 +1,5 @@
from sys import exit as sys_exit
from os.path import exists
from yyagl.gameobject import Fsm
from yyagl.racing.car.audio import CarSounds
from yyagl.racing.car.event import Keys
@@ -43,11 +44,32 @@ def enterMenu(self):
if self.mdt.logic.season:
self.mdt.logic.season.detach_obs(self.mdt.event.on_season_end)
self.mdt.logic.season.detach_obs(self.mdt.event.on_season_cont)
self.models = []
for car in self.mdt.gameprops.cars_names:
self.models += [self.mdt.gameprops.damage_paths.low % car]
self.models += [self.mdt.gameprops.damage_paths.hi % car]
self.models += [self.mdt.gameprops.model_name % car]
fpath = self.mdt.gameprops.wheel_gfx_names.front % car
rpath = self.mdt.gameprops.wheel_gfx_names.rear % car
m_exists = lambda path: exists(path + '.egg') or exists(path + '.bam')
b_path = self.mdt.gameprops.wheel_gfx_names.both % car
front_path = fpath if m_exists(fpath) else b_path
rear_path = rpath if m_exists(rpath) else b_path
self.models += [front_path]
self.models += [rear_path]
self.load_models(None)
def load_models(self, model):
if not self.models: return
model = self.models.pop(0)
self.loader_tsk = loader.loadModel(model, callback=self.load_models)
def exitMenu(self):
self.eng.log_mgr.log('exiting Menu state')
self.__menu.destroy()
self.mdt.audio.menu_music.stop()
loader.cancelRequest(self.loader_tsk)
def enterRace(self, track_path='', car_path='', drivers='', ranking=None):
self.eng.log_mgr.log('entering Race state')
View
@@ -182,13 +182,6 @@ def build_race_props(self, drivers, track_name, keys, joystick,
# names for both wheels
WheelNames = namedtuple('WheelNames', 'frontrear both')
wheel_names = WheelNames(frwheels, bwheels)
wheel_gfx_names = ['wheelfront', 'wheelrear', 'wheel']
wheel_gfx_names = [
self.eng.curr_path + 'assets/models/cars/%s/' + wname
for wname in wheel_gfx_names]
WheelGfxNames = namedtuple('WheelGfxNames', 'front rear both')
wheel_gfx_names = WheelGfxNames(*wheel_gfx_names)
track_fpath = 'assets/models/tracks/%s/track.yml' % track_name
with open(self.eng.curr_path + track_fpath) as ftrack:
music_name = load(ftrack)['music']
@@ -206,9 +199,6 @@ def build_race_props(self, drivers, track_name, keys, joystick,
laps_num = track_cfg['laps']
WPInfo = namedtuple('WPInfo', 'root_name wp_name prev_name')
WeaponInfo = namedtuple('WeaponInfo', 'root_name weap_name')
DamageInfo = namedtuple('DamageInfo', 'low hi')
damage_info = DamageInfo('assets/models/cars/%s/cardamage1',
'assets/models/cars/%s/cardamage2')
share_urls = [
'https://www.facebook.com/sharer/sharer.php?u=ya2.it/yorg',
'https://twitter.com/share?text=I%27ve%20achieved%20{time}'
@@ -222,8 +212,7 @@ def build_race_props(self, drivers, track_name, keys, joystick,
race_props = RaceProps(
self.season.props, keys, joystick, sounds,
'assets/models/cars/%s/capsule', 'Capsule', 'assets/models/cars',
wheel_names, 'Road', 'assets/models/cars/%s/car',
damage_info, wheel_gfx_names,
wheel_names, 'Road',
'assets/particles/sparks.ptf', drivers,
self.mdt.options['development']['shaders_dev'],
self.mdt.options['settings']['shaders'], music_fpath,
View
@@ -93,7 +93,16 @@ def __init__(self):
cars_names = ['themis', 'kronos', 'diones', 'iapeto', 'phoibe', 'rea',
'iperion', 'teia']
DriverPaths = namedtuple('DriverPaths', 'path path_sel')
DamageInfo = namedtuple('DamageInfo', 'low hi')
damage_info = DamageInfo('assets/models/cars/%s/cardamage1',
'assets/models/cars/%s/cardamage2')
Game.__init__(self, init_lst, conf)
wheel_gfx_names = ['wheelfront', 'wheelrear', 'wheel']
wheel_gfx_names = [
self.eng.curr_path + 'assets/models/cars/%s/' + wname
for wname in wheel_gfx_names]
WheelGfxNames = namedtuple('WheelGfxNames', 'front rear both')
wheel_gfx_names = WheelGfxNames(*wheel_gfx_names)
self.gameprops = GameProps(
menu_args, cars_names, self.drivers(),
['desert', 'mountain', 'amusement', 'countryside'],
@@ -105,7 +114,9 @@ def __init__(self):
'assets/images/drivers/driver%s_sel.png'),
'assets/images/cars/%s_sel.png',
'assets/images/cars/%s.png',
self.eng.curr_path + 'assets/models/cars/%s/phys.yml')
self.eng.curr_path + 'assets/models/cars/%s/phys.yml',
'assets/models/cars/%s/car',
damage_info, wheel_gfx_names,)
@staticmethod
def drivers():

0 comments on commit 73287d3

Please sign in to comment.