Permalink
Browse files

Merge branch 'dev' of git@github.com:preble/pyprocgame into dev

  • Loading branch information...
preble committed Oct 31, 2010
2 parents e5c7e31 + 812b9d8 commit 8a769c077d1c184f5dcd76cfb0e1275318695095
Submodule jd updated from c7fa91 to f53f9b
View
@@ -23,12 +23,11 @@ class Attract(game.Mode):
"""docstring for AttractMode"""
def __init__(self, game):
super(Attract, self).__init__(game, 1)
self.press_start = dmd.TextLayer(128/2, 7, font_jazz18, "center").set_text("Press Start")
self.proc_banner = dmd.TextLayer(128/2, 7, font_jazz18, "center").set_text("pyprocgame")
self.game_title = dmd.TextLayer(128/2, 7, font_jazz18, "center").set_text("Starter")
self.press_start = dmd.TextLayer(128/2, 7, font_jazz18, "center", opaque=True).set_text("Press Start")
self.proc_banner = dmd.TextLayer(128/2, 7, font_jazz18, "center", opaque=True).set_text("pyprocgame")
self.game_title = dmd.TextLayer(128/2, 7, font_jazz18, "center", opaque=True).set_text("Starter")
self.splash = dmd.FrameLayer(opaque=True, frame=dmd.Animation().load(fonts_path+'Splash.dmd').frames[0])
self.layer = dmd.ScriptedLayer(128, 32, [{'seconds':2.0, 'layer':self.splash}, {'seconds':2.0, 'layer':self.proc_banner}, {'seconds':2.0, 'layer':self.game_title}, {'seconds':2.0, 'layer':self.press_start}, {'seconds':2.0, 'layer':None}])
self.layer.opaque = True
def mode_topmost(self):
pass
@@ -175,8 +174,8 @@ def sw_shooterR_open_for_1s(self,sw):
self.ball_starting = False
ball_save_time = 10
self.game.ball_save.start(num_balls_to_save=1, time=ball_save_time, now=True, allow_multiple_saves=False)
else:
self.game.ball_save.disable()
#else:
# self.game.ball_save.disable()
# Note: Game specific item
# Set the switch name to the launch button on your game.
View
@@ -424,7 +424,7 @@ def process_event(self, event):
def update_lamps(self):
for mode in reversed(self.modes.modes):
mode.update_lamps()
mode.update_lamps()
def end_run_loop(self):
"""Called by the programmer when he wants the run_loop to end"""
@@ -141,7 +141,7 @@ def letter_accept(self):
if letter == self.char_back:
if len(self.inits) > 0:
self.inits = self.inits[:-1]
elif letter == self.char_done:
elif letter == self.char_done or len(self.inits) > 10:
self.inits = self.inits[:-1] # Strip off the done character
if self.entered_handler != None:
self.entered_handler(mode=self, inits=self.inits)
@@ -87,7 +87,7 @@ def to_dict(self):
def __cmp__(self, other):
c = cmp(self.score, other.score)
if c == 0:
return cmp(self.date, other.date)
return cmp(other.date, self.date)
else:
return c
View
@@ -65,27 +65,25 @@ def disable(self):
def start(self, num_balls_to_save=1, time=12, now=True, allow_multiple_saves=False):
"""Activates the ball save logic."""
if self.trough_enable_ball_save:
self.trough_enable_ball_save(True)
self.allow_multiple_saves = allow_multiple_saves
self.num_balls_to_save = num_balls_to_save
self.timer = time
if time > self.timer: self.timer = time
self.update_lamps()
if now and self.timer <= 0:
if now:
self.cancel_delayed('ball_save_timer')
self.delay(name='ball_save_timer', event_type=None, delay=1, handler=self.timer_countdown)
if self.trough_enable_ball_save:
self.trough_enable_ball_save(True)
else:
self.mode_begin = 1
self.timer_hold = time
def timer_countdown(self):
self.timer -= 1
if self.timer < 1:
if self.trough_enable_ball_save:
self.trough_enable_ball_save(False)
if (self.timer >= 1):
self.delay(name='ball_save_timer', event_type=None, delay=1, handler=self.timer_countdown)
else:
self.disable()
self.update_lamps()
@@ -101,23 +99,13 @@ def saving_ball(self):
self.timer = 1
self.lamp.disable()
def eject(self):
if self.game.machine_type == 'wpc' or self.game.machine_type == 'wpc95' or self.game.machine_type == 'wpcAlphanumeric':
if self.game.switches.trough6.is_open():
self.game.coils.trough.pulse(20)
else:
self.delay(name='ball_save_eject', event_type=None, delay=1, handler=self.eject)
elif self.game.machine_type == 'sternWhitestar' or self.game.machine_type == 'sternSAM':
if self.game.switches.trough1.is_open():
self.game.coils.trough.pulse(20)
else:
self.delay(name='ball_save_eject', event_type=None, delay=1, handler=self.eject)
def delayed_start_handler(self, sw):
if self.mode_begin:
self.timer = self.timer_hold
self.mode_begin = 0
self.update_lamps()
self.cancel_delayed('ball_save_timer')
self.delay(name='ball_save_timer', event_type=None, delay=1, handler=self.timer_countdown)
if self.trough_enable_ball_save:
self.trough_enable_ball_save(True)
@@ -42,7 +42,15 @@ def reset(self,sw):
self.cancel_delayed
schedule_search = 1
for switch in self.stop_switches:
if self.game.switches[str(switch)].is_closed():
# Don't restart the search countdown if a ball
# is resting on a stop_switch. First,
# build the appropriate function call into
# the switch, and then call it using getattr()
sw = self.game.switches[str(switch)]
state_str = str(self.stop_switches[switch])
m = getattr(sw, 'is_%s' % (state_str))
if m():
schedule_search = 0
if schedule_search:
View
@@ -139,8 +139,6 @@ def check_switches(self):
if temp_num_balls == num_current_machine_balls or \
temp_num_balls == num_trough_balls_if_ball_ending:
#print "trough - trough full now"
#print "Ball Start time: % 10.3f" % self.ball_start_time
self.num_balls_in_play = 0
if self.drain_callback:
self.drain_callback()
@@ -150,8 +148,6 @@ def check_switches(self):
# fails, and those situations are still occuring.
elif temp_num_balls == \
num_trough_balls_if_multiball_ending:
print
print "trough - trough full now"
self.num_balls_in_play = 1
if self.drain_callback:
self.drain_callback()
View
@@ -1,4 +1,5 @@
import random
import time
try:
print("Initializing sound...")
@@ -25,6 +26,7 @@ def __init__(self, delegate):
self.music = {}
self.music_volume_offset = 0
self.set_volume(0.5)
self.voice_end_time = 0
def play_music(self, key, loops=0, start_time=0.0):
"""Start playing music at the given *key*."""
@@ -84,6 +86,26 @@ def play(self,key, loops=0, max_time=0, fade_ms=0):
if len(self.sounds[key]) > 0:
random.shuffle(self.sounds[key])
self.sounds[key][0].play(loops,max_time,fade_ms)
return self.sounds[key][0].get_length()
else:
return 0
def play_voice(self,key, loops=0, max_time=0, fade_ms=0):
""" """
if not self.enabled: return 0
current_time = time.time()
# Make sure previous voice call is finished.
if current_time < self.voice_end_time: return 0
if key in self.sounds:
if len(self.sounds[key]) > 0:
random.shuffle(self.sounds[key])
self.sounds[key][0].play(loops,max_time,fade_ms)
duration = self.sounds[key][0].get_length() * (loops+1)
self.voice_end_time = current_time + duration
return duration
else:
return 0
def stop(self,key, loops=0, max_time=0, fade_ms=0):
""" """
@@ -111,7 +133,8 @@ def set_volume(self, new_volume):
self.volume = new_volume
mixer.music.set_volume (new_volume + self.music_volume_offset)
for key in self.sounds:
self.sounds[key].set_volume(self.volume)
for sound in self.sounds[key]:
sound.set_volume(self.volume)
def beep(self):
if not self.enabled: return

0 comments on commit 8a769c0

Please sign in to comment.