Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[pyrecious @ Arch-1:inform@tiker.net--2004-public%pyrecious--mainline…
…--1.0--patch-1]

fix for non-working music, removed spaces in parentheses.
  • Loading branch information
inducer committed Nov 5, 2004
1 parent 026fba5 commit ad9e5fd
Show file tree
Hide file tree
Showing 9 changed files with 538 additions and 538 deletions.
272 changes: 136 additions & 136 deletions field.py

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions game_globals.py
Expand Up @@ -6,32 +6,32 @@
STONE_IMAGES = { }
LIT_STONE_IMAGES = { }

SYSTEM_FONT_SMALL = tReference( None )
SYSTEM_FONT_BIG = tReference( None )
SYSTEM_FONT_SMALL = tReference(None)
SYSTEM_FONT_BIG = tReference(None)

SOUND_INVALID = tReference( None )
SOUND_DROP = tReference( None )
SOUND_DESTROY = tReference( None )
SOUND_HINT = tReference( None )
SOUND_OPPONENT = tReference( None )
SOUND_EXCELLENT = tReference( None )
SOUND_GAME_OVER = tReference( None )
SOUNDMGR_DESTROY = tReference( None )
SOUNDMGR_DROP = tReference( None )
SOUND_INVALID = tReference(None)
SOUND_DROP = tReference(None)
SOUND_DESTROY = tReference(None)
SOUND_HINT = tReference(None)
SOUND_OPPONENT = tReference(None)
SOUND_EXCELLENT = tReference(None)
SOUND_GAME_OVER = tReference(None)
SOUNDMGR_DESTROY = tReference(None)
SOUNDMGR_DROP = tReference(None)

SOUND_MANAGERS = []




# Initialization --------------------------------------------------------------
def loadPictureList( basename ):
def loadPictureList(basename):
images = [ ]
i = 0
try:
while 1:
name = "%s-%03d.png" % ( basename, i )
images.append( loadImage( name ) );
name = "%s-%03d.png" % (basename, i)
images.append(loadImage(name));
i = i + 1
except:
pass
Expand All @@ -40,30 +40,30 @@ def loadPictureList( basename ):

def loadStones():
for color in COLORS:
STONE_IMAGES[ color ] = loadPictureList(
os.path.join( "gems", color ) )
LIT_STONE_IMAGES[ color ] = loadPictureList(
os.path.join( "gems", color + "-lit" ) )
STONE_IMAGES[ color ] = loadPictureList(
os.path.join("gems", color))
LIT_STONE_IMAGES[ color ] = loadPictureList(
os.path.join("gems", color + "-lit"))

def loadSounds():
SOUND_INVALID.set( loadSound( 'invalid.wav' ) )
SOUND_DESTROY.set( loadSound( 'destroy.wav' ) )
SOUND_DROP.set( loadSound( 'drop.wav' ) )
SOUND_HINT.set( loadSound( 'hint.wav' ) )
SOUND_OPPONENT.set( loadSound( 'opponent.wav' ) )
SOUND_EXCELLENT.set( loadSound( 'excellent.wav' ) )
SOUND_GAME_OVER.set( loadSound( 'game_over.wav' ) )
SOUND_INVALID.set(loadSound('invalid.wav'))
SOUND_DESTROY.set(loadSound('destroy.wav'))
SOUND_DROP.set(loadSound('drop.wav'))
SOUND_HINT.set(loadSound('hint.wav'))
SOUND_OPPONENT.set(loadSound('opponent.wav'))
SOUND_EXCELLENT.set(loadSound('excellent.wav'))
SOUND_GAME_OVER.set(loadSound('game_over.wav'))

SOUNDMGR_DESTROY.set( tOnceSoundManager( SOUND_DESTROY.get() ) )
SOUNDMGR_DROP.set( tOnceSoundManager( SOUND_DROP.get() ) )
SOUNDMGR_DESTROY.set(tOnceSoundManager(SOUND_DESTROY.get()))
SOUNDMGR_DROP.set(tOnceSoundManager(SOUND_DROP.get()))

SOUND_MANAGERS.append( SOUNDMGR_DESTROY.get() )
SOUND_MANAGERS.append( SOUNDMGR_DROP.get() )
SOUND_MANAGERS.append(SOUNDMGR_DESTROY.get())
SOUND_MANAGERS.append(SOUNDMGR_DROP.get())

def loadFonts():
SYSTEM_FONT_SMALL.set( pygame.font.Font(
os.path.join( "fonts", "verdanab.ttf" ) , 15 ) )
SYSTEM_FONT_BIG.set( pygame.font.Font(
os.path.join( "fonts", "verdanab.ttf" ), 30 ) )
SYSTEM_FONT_SMALL.set(pygame.font.Font(
os.path.join("fonts", "verdanab.ttf") , 15))
SYSTEM_FONT_BIG.set(pygame.font.Font(
os.path.join("fonts", "verdanab.ttf"), 30))


30 changes: 15 additions & 15 deletions game_tools.py
Expand Up @@ -2,22 +2,22 @@

# Functions -------------------------------------------------------------------
def getTime():
return float( pygame.time.get_ticks() ) / 1000
return float(pygame.time.get_ticks()) / 1000





# Classes ---------------------------------------------------------------------
class tOnceSoundManager:
def __init__( self, sound ):
def __init__(self, sound):
self.Sound = sound
self.ShouldPlay = 0

def play( self ):
def play(self):
self.ShouldPlay = 1

def step( self, seconds ):
def step(self, seconds):
if self.ShouldPlay:
self.ShouldPlay = 0
self.Sound.play()
Expand All @@ -26,7 +26,7 @@ def step( self, seconds ):


class tAnimation:
def __init__( self, image_array, delay ):
def __init__(self, image_array, delay):
self.ImageArray = image_array
self.FrameDelay = delay
self.Time = 0
Expand All @@ -35,47 +35,47 @@ def __init__( self, image_array, delay ):
self.OneShot = 0
self.Quickly = 0

def step( self, seconds ):
def step(self, seconds):
if self.Active:
self.Time += seconds
delay = self.FrameDelay
if self.Quickly:
delay /= 2
while self.Time > delay:
self.FrameIndex = self.FrameIndex + 1
if self.FrameIndex >= len( self.ImageArray ):
if self.FrameIndex >= len(self.ImageArray):
self.FrameIndex = 0
if self.OneShot:
self.Active = 0
self.Quickly = 0
break
self.Time -= delay

def getCurrentFrame( self ):
def getCurrentFrame(self):
return self.ImageArray[ self.FrameIndex ]

def setImageArray( self, iarray ):
def setImageArray(self, iarray):
self.ImageArray = iarray
if self.FrameIndex >= len( self.ImageArray ):
if self.FrameIndex >= len(self.ImageArray):
self.FrameIndex = 0

def setActive( self, active ):
def setActive(self, active):
self.Active = active
self.OneShot = 0
self.Quickly = 0

def startOneShot( self ):
def startOneShot(self):
self.Active = 1
self.OneShot = 1

def finish( self ):
def finish(self):
self.OneShot = 1

def finishQuickly( self ):
def finishQuickly(self):
self.OneShot = 1
self.Quickly = 1

def reset( self ):
def reset(self):
self.FrameIndex = 0


Expand Down
2 changes: 1 addition & 1 deletion loaders.py
@@ -1,6 +1,6 @@
import pygame, pygame.mixer, os

def loadImage( name, colorkey = None ):
def loadImage(name, colorkey = None):
fullname = os.path.join('graphics', name)
try:
image = pygame.image.load(fullname)
Expand Down
14 changes: 7 additions & 7 deletions music.py
@@ -1,8 +1,8 @@
import pygame, pygame.mixer, os, random
import pygame, pygame.mixer, os, random, glob

EVENT_MUSIC_END = pygame.constants.USEREVENT

MUSIC_TUNES_LIST = os.listdir( "music" )
MUSIC_TUNES_LIST = glob.glob("music/*.xm") + glob.glob("music/*.it")
MUSIC_TUNES_INDEX = None
MUSIC_ENABLED = 0

Expand All @@ -16,17 +16,17 @@ def nextMusicTune():

global MUSIC_TUNES_LIST, MUSIC_TUNES_INDEX

MUSIC_TUNES_INDEX = random.randint( 0, len( MUSIC_TUNES_LIST ) - 1 )
MUSIC_TUNES_INDEX = random.randint(0, len(MUSIC_TUNES_LIST) - 1)

song_name = os.path.join( "music", MUSIC_TUNES_LIST[ MUSIC_TUNES_INDEX ] )
song_name = MUSIC_TUNES_LIST[MUSIC_TUNES_INDEX]

pygame.mixer.music.load( song_name );
pygame.mixer.music.load(song_name);
pygame.mixer.music.play()




def setMusicEnabled( enabled ):
def setMusicEnabled(enabled):
global MUSIC_ENABLED

if MUSIC_ENABLED == enabled:
Expand All @@ -37,4 +37,4 @@ def setMusicEnabled( enabled ):
if enabled:
nextMusicTune()
else:
pygame.mixer.music.fadeout( 100 )
pygame.mixer.music.fadeout(100)

0 comments on commit ad9e5fd

Please sign in to comment.