def __init__(self, avatar): self.done = False self.avatar = avatar self.currentAnim = Anim('subWalkSquash', 5) #img = data.pngs['avatar.png'] pyglet.sprite.Sprite.__init__(self, self.currentAnim.animation, 0, 0) events.AddListener(self) self.blinkingCounter = 0.0 self.yoyo = yoyo.YoYo() self.shadow = ShadowSprite() self.shadow.scale = float(self.width)/self.shadow.width self.shadow.opacity = 128 self.on_key_press = window.window.event(self.on_key_press) self.on_key_release = window.window.event(self.on_key_release) self.mouseButton = None self.on_mouse_press = window.window.event(self.on_mouse_press) self.on_mouse_release = window.window.event(self.on_mouse_release) self.attackImgs = {Facing.left: data.pngs[self.avatar.attackImg +'_left'], Facing.right: data.pngs[self.avatar.attackImg]} self.deadImgs = {Facing.left: data.pngs[self.avatar.deadImg +'_left'], Facing.right: data.pngs[self.avatar.deadImg]}
def __init__(self, imgName, zone, x, y): self.zone = zone img = data.pngs[imgName] self.origX = x - img.width / 2 self.origY = y - img.height / 2 pyglet.sprite.Sprite.__init__(self, img, self.origX, self.origY) events.AddListener(self) self.state = 'normal'
def __init__(self, levelNum, sound=True): global soundtrack events.AddListener(self) self.done = False self.deathDelay = 0 self.levelNum = levelNum strLevelNum = '%02d' % levelNum triggers = data.levelTriggers['leveltriggers' + strLevelNum] if not levelNum % 2: # even levels are repeats of previous images strLevelNum = '%02d' % (levelNum - 1) self.walkMask = data.levelMasks[strLevelNum] filePath = os.path.join(data.data_dir, 'levelbg%s-?.png' % strLevelNum) self.sound = sound bgPngs = glob.glob(filePath) bgPngs.sort() self.bgImages = [data.pngs[png] for png in bgPngs] self.avatar = Avatar() self.avatar.strings = player.strings[:] self.visualEffects = visualeffects.EffectManager() self.miscSprites = [] healthFont = font.load('Oh Crud BB', 28) #self.healthText = font.Text(healthFont, x=10, y=25, text='Health:') self.healthBar = HeartMeter() self.energyBar = EnergyMeter((240, 5)) self.fpsText = font.Text(healthFont, x=650, y=25) self.triggerZones = [] for rect, clsName in triggers.items(): cls = globals().get(clsName) if not cls: if len(rect) == 4: print "ERROR: couldn't find", clsName continue zone = cls(rect, self) self.triggerZones.append(zone) if hasattr(zone, 'sprite'): self.miscSprites.append(zone.sprite) if DEBUG and hasattr(zone, 'debugSprite'): self.miscSprites.append(zone.debugSprite) self.enemySprites = {} self.startLoc = [ key for key, val in triggers.items() if val == 'start location' ][0] if levelNum == 1 and self.sound: soundtrack = \ queueSoundtrack('8bp077-01-nullsleep-her_lazer_light_eyes.mp3') soundtrack.play()
def __init__(self): events.AddListener(self) Walker.__init__(self) self.health = 10 self.energy = 1 self.xMax = 4 self.xMin = -4 self.yMax = 2 self.yMin = -2 self.state = State.fastWalking self.knownAvatars = [] self.xFightingReach = 10 self.yFightingReach = 4 self.attack = attacks.Hug() self.stunCounter = 0
def __init__(self, sound=True): events.AddListener(self) self.done = False self.bg = data.pngs['menu.png'] self.moving_bg = [ data.pngs['menu-bricks.png'], data.pngs['menu-bricks.png'] ] self.miscSprites = [ SimpleTextButton('Start!', 400, 200, True), ] self.keyPress = False self.mousePress = False self.on_key_press = window.window.event(self.on_key_press) self.on_key_release = window.window.event(self.on_key_release) self.on_mouse_press = window.window.event(self.on_mouse_press) self.on_mouse_release = window.window.event(self.on_mouse_release) self.sound = sound
def __init__(self, bgMangr, musicMangr): self.isDone = 0 self.replacementDisplayerClass= None self.bgMangr = bgMangr musicMangr.PlaySong( data.oggs['glarf_main'] ) #TODO: hack alert musicMangr.currentSong.set_volume( 0.5 ) self.charGroup = ScrollSpriteGroup(self.bgMangr) self.enemyGroup = ScrollSpriteGroup(self.bgMangr) self.neutralGroup = ScrollSpriteGroup(self.bgMangr) self.triggerGroup = ScrollSpriteGroup(self.bgMangr) self.effectGroup = ScrollSpriteGroup(self.bgMangr) self.idlers = IdlerSpriteGroup(self.bgMangr) self.hudGroupLow = pygame.sprite.RenderUpdates() self.hudGroupHi = pygame.sprite.RenderUpdates() self.effects = VisualEffectManager( self.effectGroup ) self.resurrect = 1 self.solids = Group() self.listenKeys = {} self.timeSinceDeath = -1 self.charactor = Charactor(self.bgMangr) self.charactor.SetLevel( self ) self.charGroup.add( self.charactor ) self.solids.add( self.charactor ) self.hudInfo = CharactorHUD( ) self.hudInfo.SetCharactor( self.charactor ) self.hudInfo.UpdateAll() self.hudGroupHi.add( self.hudInfo ) self.Load( os.curdir +'/data/level1/level.py' ) events.AddListener( self )
def __init__(self, cutsceneNum): events.AddListener(self) self.done = False self.cutsceneNum = cutsceneNum self.sound = False self.frameNum = 1 strCutsceneNum = '%02d' % self.cutsceneNum strFrameNum = '%02d' % self.frameNum self.bg = data.pngs['cutscene' + strCutsceneNum + strFrameNum + '.png'] self.moving_bg = None # this is a total hack. just passing these objects on to the next scene self.nextLevelNum = None self.avatar = None self.miscSprites = [] self.keyPress = False self.on_key_press = window.window.event(self.on_key_press) self.on_key_release = window.window.event(self.on_key_release)
def main(vsync=False, sound=True): global visualEffects if vsync: win = pyglet.window.Window(width=800, height=600) else: win = pyglet.window.Window(width=800, height=600, vsync=0) window.setWindow(win) menu = scene.Menu(sound) currentScene = menu #win.push_handlers(pyglet.window.event.WindowEventLogger()) soundEffects = soundeffects.EffectManager() while currentScene and not win.has_exit: currentScene = currentScene.run() if soundEffects not in events.__listeners: events.AddListener(soundEffects)
def __init__(self): Walker.__init__(self) events.AddListener(self) self.health = 3 self.state = State.normal self.upPressed = False self.rightPressed = False self.downPressed = False self.leftPressed = False self.xFriction = 1 self.yFriction = 2 self.xAccel = 1 self.yAccel = 1 self.xMax = 6 self.xMin = -6 self.yMax = 2 self.yMin = -2 self.stunCounter = 0 self.yoyo = LogicalYoyo() self.attacks = attacks.makeYoyoAttacks(self.yoyo) self.strings = [] self.selectedAttack = None
def __init__(self, enemy): self.enemy = enemy events.AddListener(self) self.currentAnim = Anim(self.imgPrefix + 'Walk', 5) #img = data.pngs['enemy.png'] pyglet.sprite.Sprite.__init__(self, self.currentAnim.animation, 0, 0) self.blinkingCounter = 0.0 self.shadow = ShadowSprite() self.shadow.scale = float(self.width) / self.shadow.width self.shadow.opacity = 100 self.hugImgs = { Facing.left: data.pngs[self.imgPrefix + 'Hug_left'], Facing.right: data.pngs[self.imgPrefix + 'Hug'] } self.stunImgs = { Facing.left: data.pngs[self.imgPrefix + 'Stun_left'], Facing.right: data.pngs[self.imgPrefix + 'Stun'] } self.idleImg = data.pngs[self.imgPrefix + 'Stand'] self.walkImg = self.currentAnim.animation
def __init__(self, screen): events.AddListener( self ) self.levelPaused = 0 self.dragging = 0 self.snapToGrid = True self.gridSize = [8,8] self.temporaryGroup = RenderUpdates() self.toggler = 0 self.mousePosAtSelect = [0,0] self.objPosAtSelect = [0,0] self.highlightedObj = None self.selectedSprite = None self.redRect = pygame.sprite.Sprite() self.greenRect = pygame.sprite.Sprite() self.editPanel = EditorPanel(screen) self.level = None self.bgMangr = None
def __init__(self, bgMangr, musicMangr): self.isDone = 0 self.replacementDisplayerClass= None self.levelDisplayer = None self.bgMangr = bgMangr self.dragging = 0 if self.activeLevel != None: self.levelDisplayer = self.activeLevel events.AddListener( self ) screen = self.bgMangr.screen self.edInterface = EditorInterface( screen ) fauxWidth = screen.get_width() fauxHeight = screen.get_height() - self.edInterface.editPanel.rect.height self.fauxScreen = Surface( (fauxWidth, fauxHeight) ) self.fauxBgMangr = SeamedBackgroundManager(self.fauxScreen) self.levelDisplayer.bgMangr = self.fauxBgMangr self.edInterface.SetLevel( self.levelDisplayer ) self.edInterface.SetBackgroundManager( self.bgMangr )
def __init__(self, bgImage, boundRect): self.isDone = 0 self.isDirty = 1 self.bgImage = bgImage self.boundRect = boundRect #print self.boundRect self.needsReBlit = True self.UIGroup = RenderUpdates() self.infoObj = None yPad = 4 #labels self.todLabel = LabelSprite("00:00") self.todLabel.rect.midbottom = self.boundRect.midbottom self.todLabel.rect.move_ip(-160, -90) self.UIGroup.add(self.todLabel) self.infoLabel = LabelSprite(" - ") self.infoLabel.rect.x = self.todLabel.rect.x self.infoLabel.rect.y = self.todLabel.rect.y + ascent + yPad self.UIGroup.add(self.infoLabel) self.fpsLabel = LabelSprite("FPS: 0") self.fpsLabel.rect.x = self.infoLabel.rect.x self.fpsLabel.rect.y = self.infoLabel.rect.y + ascent + yPad self.UIGroup.add(self.fpsLabel) #buttons self.pauseButton = ToggleButtonSprite("pause") self.pauseButton.onClickCallback = self.Pause self.pauseButton.rect.topleft = self.boundRect.topleft self.pauseButton.rect.move_ip(0, 10) self.UIGroup.add(self.pauseButton) self.rTogButton = ToggleButtonSprite("red") self.rTogButton.onClickCallback = self.ShowRed self.rTogButton.rect.x = self.boundRect.x self.rTogButton.rect.y = self.pauseButton.rect.bottom + yPad self.UIGroup.add(self.rTogButton) self.gTogButton = ToggleButtonSprite("green") self.gTogButton.onClickCallback = self.ShowGreen self.gTogButton.rect.x = self.boundRect.x self.gTogButton.rect.y = self.rTogButton.rect.bottom + yPad self.UIGroup.add(self.gTogButton) self.servButton = ToggleButtonSprite("server") self.servButton.onClickCallback = self.ShowServer self.servButton.rect.x = self.boundRect.x self.servButton.rect.y = self.gTogButton.rect.bottom + yPad self.UIGroup.add(self.servButton) self.device = DeviceSprite() self.device.rect.bottomright = self.boundRect.bottomright self.device.rect.move_ip(-170, -80) self.UIGroup.add(self.device) events.AddListener(self) events.AddEvent("Pause") events.AddEvent("ShowRed") events.AddEvent("ShowGreen") events.AddEvent("ShowServer")
def __init__(self): events.AddListener(self)
def __init__(self, pos): events.AddListener(self) self.pos = pos self.yoImg = YoyoHud() self.yoImgShake = [0, 0] self.pulse = 0
def __init__(self, enemy): self.enemy = enemy events.AddListener(self) img = data.pngs['enemy.png'] pyglet.sprite.Sprite.__init__(self, img, 0, 0) self.blinkingCounter = 0.0
def __init__(self): self.sprites = [] events.AddListener(self) self.speechBubbles = weakref.WeakKeyDictionary()