def explode(self): self.ignoreAll() self.cNode.setIntoCollideMask(BitMask32.allOff()) taskMgr.remove(self.moveTask) taskMgr.remove(self.mouseTask) taskMgr.remove(self.zoomTaskPointer) self.moveTask = 0 self.mouseTask = 0 if self.contrail != 0: self.contrail.cleanup() self.modelNode.hide() self.contrail = ParticleEffect() self.contrail.loadConfig('media/explosion.ptf') self.contrail.start(self.node) self.contrail.setLightOff() self.contrail2.cleanup() #add explosion sound #------------------------------------------------------------------------------ self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], base.camera) self.audio3d.setDropOffFactor(0.2) self.Sound = self.audio3d.loadSfx('explosion.mp3') self.audio3d.detachSound(self.Sound) self.audio3d.attachSoundToObject(self.Sound, self.node) #self.Sound.play() #------------------------------------------------------------------------------ self.deleteTask = taskMgr.doMethodLater(4, self.deleteTask, 'delete task')
def __init__(self, inputManager, hud, cursor): self.inputManager = inputManager #gets a reference to the inputManager to pass on to the player cycle self.cycles = [] # creates a list to store cycles self.track = None # creates a variable to store the track. self.hud = hud # stores a reference to the HUD. self.cursor = cursor # stores a reference to the custom mouse cursor self.amList = [] self.a3DList = [] for N in range(4): self.amList.append(AudioManager.createAudioManager()) base.addSfxManager(self.amList[N]) self.a3DList.append(Audio3DManager.Audio3DManager( base.sfxManagerList[N + 1], camera)) self.a3DList[N].setDropOffFactor(.1)
def __init__(self): ShowBase.__init__(self) self.game_config = Config() self.labels = getattr( __import__("languages." + self.game_config.language), self.game_config.language, ) self._win_prors = self._configure_window() if not os.path.exists("saves"): os.mkdir("saves") self.main_font = self.loader.loadFont("arial.ttf") self.cursive_font = self.loader.loadFont("caveat.ttf") self.setBackgroundColor(0.1, 0.17, 0.1) self.sound_mgr = Audio3DManager.Audio3DManager(self.sfxManagerList[0], self.cam) self.sound_mgr.setDropOffFactor(5) self.effects_mgr = EffectsManager() self._dollars = 0 self._resources = { "medicine_boxes": 0, "smoke_filters": 0, "stimulators": 0, } self._heads = {} self._cur_mouse_pointer = "normal" self.helped_children = False self.decisions = {} self.main_menu = MainMenu()
def load_sound(self): base.cTrav = CollisionTraverser() # only used for 3d audio self.sounds3d = {} self.sounds2d = {} try: self.audio3d = Audio3DManager.Audio3DManager( base.sfxManagerList[0], base.player.node) self.audio3d.setListenerVelocityAuto() sfx_files = [ "roam_filter", "roam_normal", "scream_normal", "scream_filter", "loud_scream", "door_open", "door_closed" ] for sfx_file in sfx_files: sfx_path = "sfx/{}.wav".format(sfx_file) self.sounds3d[sfx_file] = self.audio3d.load_sfx(sfx_path) self.audio3d.setSoundVelocityAuto(self.sounds3d[sfx_file]) except AttributeError: pass for sfx_file in [ "key", "end", "walk", "scream_normal", "loud_scream", "beat" ]: sfx_path = "sfx/{}.wav".format(sfx_file) self.sounds2d[sfx_file] = loader.load_sfx(sfx_path) self.sounds2d["walk"].set_loop(True) self.sounds2d["walk"].set_volume(0) self.sounds2d["walk"].play() self.sounds2d["beat"].set_loop(True) self.sounds2d["beat"].set_volume(0) self.sounds2d["beat"].play() self.beating = False
def __init__(self): # The basics ShowBase.__init__(self) base.disableMouse() # Camera / Audio listener node self.cam_node = self.render.attachNewNode("Camera node") self.camera.reparentTo(self.cam_node) self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], self.camera) self.cam_node.set_pos(0, -10, 0) # Add the model self.m = self.loader.loadModel("models/smiley") self.m.reparentTo(self.render) self.m.setPos(0, 0, 0) s = self.audio3d.loadSfx('knocking.ogg') s.setLoop(True) s.play() self.audio3d.attachSoundToObject(s, self.m) # Bookkeeping for the rotation around the model self.angle = 0.0 self.adjust_angle = 0 # Initial camera setup self.camera.look_at(self.m) # Key events and camera movement task self.accept("arrow_left", self.adjust_turning, [-1.0]) self.accept("arrow_left-up", self.adjust_turning, [1.0]) self.accept("arrow_right", self.adjust_turning, [1.0]) self.accept("arrow_right-up", self.adjust_turning, [-1.0]) self.accept("escape", sys.exit) self.taskMgr.add(self.update_camera, 'adjust camera', sort = 10)
def _initSound(self, x, y, h): audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera) #base = ShowBase() self._sound = audio3d.loadSfx( "../data/sounds/A-Tone-His_Self-1266414414.mp3") #self._sound.set3dAttributes(x, y, h/2.0, 0, 0, 0) audio3d.attachSoundToObject(self._sound, self._modulo_node) self._sound.set3dMinDistance(0) self._sound.set3dMaxDistance(50)
def startAudioManager(self): # Create an audio manager. This is attached to the camera for # player 1, so sounds close to other players might not be very # loud self.audioManager = Audio3DManager.Audio3DManager( base.sfxManagerList[0], base.camera) # Distance should be in m, not feet self.audioManager.setDistanceFactor(3.28084)
def __init__(self): ShowBase.__init__(self) self.filters = CommonFilters(self.win, self.cam) self.render.setShaderAuto() self.initP3D() self.audio3d = Audio3DManager.Audio3DManager(self.sfxManagerList[0], self.cam) self.audio3d.setDopplerFactor(.7) self.splash = Splash(base, self, sys.argv[1] if len(sys.argv) > 1 else False )
def enable(self): if not self.enabled: base.enableAllAudio() base.enableMusic(True) #bEnableMusic) base.enableSoundEffects(True) #bEnableSoundEffects) self.sound3dListener = NodePath('3dSoundListener') self.sound3dListener.reparentTo(render) self.sound3d = Audio3DManager.Audio3DManager( base.sfxManagerList[0], self.sound3dListener) self.enabled = True
def sounds(self): self.audio3d = Audio3DManager.Audio3DManager(self.sfxManagerList[0], self.camera) self.audio3d.setListenerVelocityAuto() self.snd_space = self.loader.loadSfx("./snd/space.flac") self.snd_space.setLoop(True) self.snd_thrust = self.loader.loadSfx("./snd/thrust.flac") self.snd_thrust.setLoop(True) self.snd_roller = self.loader.loadSfx("./snd/roller.flac") self.snd_roller.setLoop(True) self.snd_launch = self.loader.loadSfx("./snd/launch.flac") self.snd_lock = self.loader.loadSfx("./snd/lock.flac") self.snd_space.play()
def loadAudio(self): audio3d = Audio3DManager.Audio3DManager( base.sfxManagerList[0], base.camera ) Obj3D.audio3d = audio3d self.audio = {} # Bg audio bgAudio = base.loader.loadSfx("audio/purple_passion.mp3") bgAudio.setLoop(True) bgAudio.setVolume(0.05) bgAudio.play() self.audio["bg"] = bgAudio
def initSounds(self): self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], self.camera) self.flyingSound = self.audio3d.loadSfx( "./sounds/great fox flying.mp3") self.flyingSound.setLoop(True) self.audio3d.attachSoundToObject(self.flyingSound, self.player) self.audio3d.setSoundVelocityAuto(self.flyingSound) self.audio3d.setListenerVelocityAuto() #self.audio3d.setDistanceFactor(100) self.audio3d.setDropOffFactor(0) self.fireSound = self.audio3d.loadSfx( "./sounds/arwing double laser one shot.mp3") self.crashSound = self.audio3d.loadSfx("./sounds/break.mp3")
def createSillyMeter(self): ropes = loader.loadModel('phase_4/models/modules/tt_m_ara_int_ropes') ropes.reparentTo(self.interior) self.sillyMeter = Actor.Actor('phase_4/models/props/tt_a_ara_ttc_sillyMeter_default', {'arrowTube': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid', 'phaseOne': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseOne', 'phaseTwo': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseTwo', 'phaseThree': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseThree', 'phaseFour': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFour', 'phaseFourToFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive', 'phaseFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive'}) self.sillyMeter.reparentTo(self.interior) self.smPhase1 = self.sillyMeter.find('**/stage1') self.smPhase2 = self.sillyMeter.find('**/stage2') self.smPhase3 = self.sillyMeter.find('**/stage3') self.smPhase4 = self.sillyMeter.find('**/stage4') self.smPhase2.hide() self.smPhase3.hide() self.smPhase4.hide() thermometerLocator = self.sillyMeter.findAllMatches('**/uvj_progressBar')[1] thermometerMesh = self.sillyMeter.find('**/tube') thermometerMesh.setTexProjector(thermometerMesh.findTextureStage('default'), thermometerLocator, self.sillyMeter) self.sillyMeter.flattenMedium() self.sillyMeter.makeSubpart('arrow', ['uvj_progressBar*', 'def_springA']) self.sillyMeter.makeSubpart('meter', ['def_pivot'], ['uvj_progressBar*', 'def_springA']) self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera) self.phase1Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseOne.ogg') self.phase1Sfx.setLoop(True) self.phase2Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseTwo.ogg') self.phase2Sfx.setLoop(True) self.phase3Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseThree.ogg') self.phase3Sfx.setLoop(True) self.phase4Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFour.ogg') self.phase4Sfx.setLoop(True) self.phase4To5Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFourToFive.ogg') self.phase4To5Sfx.setLoop(False) self.phase5Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFive.ogg') self.phase5Sfx.setLoop(True) self.arrowSfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.ogg') self.arrowSfx.setLoop(False) self.audio3d.setDropOffFactor(0.1) self.startSillyMeter(config.GetInt('silly-meter-phase', 12))
def attachAudio(self, audioName, loop=False, volume=1, dropOffFactor=1): audioFile = audioName audio3d = Audio3DManager.Audio3DManager( base.sfxManagerList[0], base.camera) if Obj3D.audio3d == None else Obj3D.audio3d try: audio = audio3d.loadSfx(audioFile) except: raise Exception(f"Audio {audio} cannot be loaded") audio.setLoop(loop) audio.setVolume(volume) audio3d.attachSoundToObject(audio, self.model) audio3d.setDropOffFactor(dropOffFactor) # jesnk : audio print("audio ", audioName, " is Loaded") self.audio[audioName] = audio
def beatLevel(self): #Function that control the explosion of the airplane self.ignoreAll() self.cNode.setIntoCollideMask(BitMask32.allOff()) taskMgr.remove(self.moveTask) taskMgr.remove(self.mouseTask) taskMgr.remove(self.zoomTaskPointer) self.moveTask = 0 self.mouseTask = 0 self.MusicSound.stop() #Add end of level music self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], base.camera) self.audio3d.setDropOffFactor(0.2) self.Sound = self.audio3d.loadSfx('FF7Fanfare.mp3') self.audio3d.detachSound(self.Sound) self.audio3d.attachSoundToObject(self.Sound, self.node) self.Sound.play() messenger.send('game-levelwin') self.deleteTask = taskMgr.doMethodLater(4, self.deleteTask, 'delete task')
def _present(self, message): if message[-4] == '.': # sound file name if self.surround: if self.audio3d is None: self.audio3d = Audio3DManager.Audio3DManager( base.sfxManagerList[0], camera) mysound = self.audio3d.loadSfx(message) mysound.set3dAttributes(1 * math.sin(self.direction), 1 * math.cos(self.direction), 0.0, 0.0, 0.0, 0.0) mysound.setVolume(self.volume) else: mysound = loader.loadSfx(message) mysound.setVolume(self.volume) mysound.setBalance(self.direction) if self.looping: mysound.setLoop(True) if self.loopcount is not None: mysound.setLoopCount(self.loopcount) if self.timeoffset > 0.0: mysound.setTime(self.timeoffset) mysound.setPlayRate(self.playrate) mysound.play() self.marker(221) else: # actual text (note: no directionality supported yet) try: if self.speak is None: self.speak = win32com.client.Dispatch('Sapi.SpVoice') self.speak.Volume = self.volume * 100.0 self.speak.Rate = -1 threading.Thread(target=self.do_speak, args=[message]).start() self.marker(221) except: print "Error initializing speech output."
def addSound(self): self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], base.camera) self.audio3d.setDropOffFactor(0.2) self.Sound = self.audio3d.loadSfx('missile.mp3') self.audio3d.attachSoundToObject( self.Sound, self.node ) self.Sound.play()
def enterSetup(self): ropes = loader.loadModel('phase_4/models/modules/tt_m_ara_int_ropes') ropes.reparentTo(self.interior) self.sillyMeter = Actor.Actor( 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_default', { 'arrowTube': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid', 'phaseOne': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseOne', 'phaseTwo': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseTwo', 'phaseThree': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseThree', 'phaseFour': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFour', 'phaseFourToFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive', 'phaseFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive' }) self.sillyMeter.reparentTo(self.interior) self.flatSillyMeter = loader.loadModel( 'phase_3.5/models/modules/tt_m_ara_int_sillyMeterFlat') self.flatSillyMeter.reparentTo(self.interior) self.flatSillyMeter.hide() self.flatDuck = loader.loadModel( 'phase_3.5/models/modules/tt_m_ara_int_scientistDuckFlat') loc1 = self.interior.find('**/npc_origin_1') if loc1: self.flatDuck.reparentTo(loc1) self.flatDuck.hide() self.flatMonkey = loader.loadModel( 'phase_3.5/models/modules/tt_m_ara_int_scientistMonkeyFlat') loc1 = self.interior.find('**/npc_origin_2') if loc1: self.flatMonkey.reparentTo(loc1) self.flatMonkey.hide() self.flatHorse = loader.loadModel( 'phase_3.5/models/modules/tt_m_ara_int_scientistHorseFlat') loc1 = self.interior.find('**/npc_origin_3') if loc1: self.flatHorse.reparentTo(loc1) self.flatHorse.hide() self.smPhase1 = self.sillyMeter.find('**/stage1') self.smPhase2 = self.sillyMeter.find('**/stage2') self.smPhase3 = self.sillyMeter.find('**/stage3') self.smPhase4 = self.sillyMeter.find('**/stage4') self.smPhase2.hide() self.smPhase3.hide() self.smPhase4.hide() thermometerLocator = self.sillyMeter.findAllMatches( '**/uvj_progressBar')[1] thermometerMesh = self.sillyMeter.find('**/tube') thermometerMesh.setTexProjector( thermometerMesh.findTextureStage('default'), thermometerLocator, self.sillyMeter) self.sillyMeter.flattenMedium() self.sillyMeter.makeSubpart('arrow', ['uvj_progressBar*', 'def_springA']) self.sillyMeter.makeSubpart('meter', ['def_pivot'], ['uvj_progressBar*', 'def_springA']) self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera) self.phase1Sfx = self.audio3d.loadSfx( 'phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseOne.mp3') self.phase1Sfx.setLoop(True) self.phase2Sfx = self.audio3d.loadSfx( 'phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseTwo.mp3') self.phase2Sfx.setLoop(True) self.phase3Sfx = self.audio3d.loadSfx( 'phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseThree.mp3') self.phase3Sfx.setLoop(True) self.phase4Sfx = self.audio3d.loadSfx( 'phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFour.mp3') self.phase4Sfx.setLoop(True) self.phase4To5Sfx = self.audio3d.loadSfx( 'phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFourToFive.mp3') self.phase4To5Sfx.setLoop(False) self.phase5Sfx = self.audio3d.loadSfx( 'phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFive.mp3') self.phase5Sfx.setLoop(True) self.arrowSfx = self.audio3d.loadSfx( 'phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.mp3') self.arrowSfx.setLoop(False) self.audio3d.setDropOffFactor(0.10000000000000001) self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterIsRunning', self.sillyMeterIsRunning) self.startIfNeeded()
from lib.coginvasion.suit import Suit from direct.distributed.DistributedSmoothNode import DistributedSmoothNode from direct.showbase.ShadowPlacer import ShadowPlacer from lib.coginvasion.toon import ParticleLoader from direct.showbase.DirectObject import * from direct.actor.Actor import * from direct.gui.DirectGui import * from panda3d.core import * from pandac.PandaModules import * from direct.gui.DirectGui import * from direct.showbase import Audio3DManager import random notify = DirectNotify().newCategory("DistributedSuit") audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera) audio3d.setDistanceFactor(25) class DistributedSuit(Suit.Suit, DistributedSmoothNode): def __init__(self, cr): try: self.DistributedSuit_initialized return except: self.DistributedSuit_initialized = 1 Suit.Suit.__init__(self) DistributedSmoothNode.__init__(self, cr) self.name = "" self.anim = "neutral" self.state = "alive"
def initialize(self): self.audio3d = Audio3DManager.Audio3DManager( base.sfxManagerList[0], self.game.getView().getCamera())
def __init__(self): # Sound self.collectSoundEffect = loader.loadMusic("sounds/item_collect.mp3") self.footstepSound = loader.loadMusic("sounds/footsteps.mp3") self.footstepSound.setLoop(1); audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], base.camera) self.musicend = loader.loadMusic("sounds/Enchanted-Woods.mp3") # Sky Box starTexture = loader.loadTexture("models/stars.jpg") self.sky = loader.loadModel("models/box.egg") self.sky.setScale(300) self.sky.setPos(-200,-150,0) self.sky.setBin('background', 0) self.sky.setDepthWrite(0) self.sky.setTwoSided(True) self.sky.setTexture(starTexture, 1) self.sky.reparentTo(render) self.sky.set_compass() # allow transparency render.setTransparency(TransparencyAttrib.MAlpha) self.pieCount = 0 self.pieDisplay = grabPie(self.pieCount) self.keyMap = {"left":0, "right":0, "forward":0, "cam-left":0, "cam-right":0, "run":0, "reset":0} base.win.setClearColor(Vec4(0,0,0,1)) self.environ = loader.loadModel("models/world") self.environ.reparentTo(render) self.environ.setPos(0,0,0) # Create the main character eveStartPos = self.environ.find("**/start_point").getPos() self.eve = Actor("models/eve", {"run":"models/eve_run", "walk":"models/eve_walk"}) print(eveStartPos) self.gameOver = 0 self.eve.reparentTo(render) self.eve.setScale(.2) #self.eve.setShear(.5, .5, .5) self.eve.setPos(eveStartPos) self.eateve = Actor("models/eve") self.eateve.reparentTo(render) self.eateve.setScale(.2) self.eateve.setPos(eveStartPos) self.eateve.hide() self.pie = loader.loadModel("models/fruit-pie-slice") self.pie.reparentTo(render) self.pie.setScale(.5) self.pie.setPos(Vec3(-50, -30, 10)) #self.pie.setP(20) self.rand = Actor("models/eve") self.rand.reparentTo(render) self.rand.setScale(.2) self.rand.setPos(Vec3(-70, -5, eveStartPos.getZ() + 5)) self.rand.hide() self.rand2 = Actor("models/eve") self.rand2.reparentTo(render) self.rand2.setScale(.2) self.rand2.setPos(Vec3(-70, -5, eveStartPos.getZ() + 10)) self.rand2.hide() # print(eveStartPos) # Blue Dragon self.character3=Actor('models/nik-dragon') #self.character3.loadModel('models/nik-dragon') self.character3.reparentTo(render) self.character3.loadAnims({'win': 'models/nik-dragon'}) self.character3.loop('win') self.character3.setPlayRate(.5,'win') self.character3.setScale(.23) self.character3.setTransparency(1) #self.character3.setColorScale(0.4,0.2,.4,.7) self.character3.setColorScale(9,9,9,.3) self.character3.setPos(-114,11,1.9) self.blueDragonSound = audio3d.loadSfx("sounds/Snoring Giant.mp3") audio3d.attachSoundToObject(self.blueDragonSound, self.character3) self.blueDragonSound.setLoop(True) self.blueDragonSound.play() # Red Dragon self.character2=Actor() self.character2.loadModel('models/nik-dragon') self.character2.reparentTo(render) self.character2.loadAnims({'win': 'models/nik-dragon'}) self.character2.loop('win') self.character2.setPlayRate(1.5,'win') self.character2.setScale(.06) self.character2.setColorScale(6,0.2,0.2,50) self.character2.setPos(-108,11,.3) self.redDragonStartPos = self.character2.getPos() self.redDragonCollideCount = 0 self.redDragonSound = audio3d.loadSfx("sounds/Velociraptor Call.mp3") audio3d.attachSoundToObject(self.redDragonSound, self.character3) self.redDragonSound.setLoop(True) self.redDragonSound.play() # Green Dragon self.character=Actor() self.character.loadModel('models/nik-dragon') self.character.reparentTo(render) self.character.loadAnims({'win': 'models/nik-dragon'}) self.character.loop('win') self.character.setScale(.1) self.character.setPos(-118,21,0) self.greenDragonSound = audio3d.loadSfx("sounds/Raptor Call.mp3") audio3d.attachSoundToObject(self.greenDragonSound, self.character3) self.greenDragonSound.setLoop(True) self.greenDragonSound.play() self.dragonStartPos = self.character.getPos() self.dragonCollideCount = 0 self.AIworld = AIWorld(render) #self.AIworld.addObstacle(self.environ) self.dragonAI = AICharacter("character", self.character, 100, 0.05, 5) self.AIworld.addAiChar(self.dragonAI) self.AIbehaviors = self.dragonAI.getAiBehaviors() #self.AIbehaviors.seek(self.character2) #self.AIbehaviors.wander(2, 0, 5, .5) self.AIbehaviors.pursue(self.eateve, 1) #self.AIbehaviors.wander(5,0,10,.5) #self.AIbehaviors.evade(self.character3, 10, 20, 300) #self.AIbehaviors.seek(self.eve, .5) #self.AIbehaviors.obstacleAvoidance(1) self.randomChase = AICharacter("rand", self.rand, 50, 20, 20) self.AIworld.addAiChar(self.randomChase) self.AIbehaviorsRand = self.randomChase.getAiBehaviors() self.AIbehaviorsRand.wander(10,0,47,.5) self.randomChase2 = AICharacter("rand2", self.rand2, 50, 20, 20) self.AIworld.addAiChar(self.randomChase2) self.AIbehaviorsRand2 = self.randomChase2.getAiBehaviors() self.AIbehaviorsRand2.wander(10,0,47,.5) self.ghostDragonAI = AICharacter("character3", self.character3, 250, .05, 5) self.AIworld.addAiChar(self.ghostDragonAI) self.AIbehaviors3 = self.ghostDragonAI.getAiBehaviors() self.AIbehaviors3.pursue(self.rand, 1) #self.AIbehaviors3.wander(5,0,10,.5) self.redDragonChasingEve = 0 self.redDragonAI = AICharacter("character2", self.character2, 100, .05, 7) self.AIworld.addAiChar(self.redDragonAI) self.AIbehaviors2 = self.redDragonAI.getAiBehaviors() self.AIbehaviors2.pursue(self.rand2, 1) taskMgr.add(self.AIUpdate, "AIUpdate") # Create a floater object to use for camera management self.floater = NodePath(PandaNode("floater")) self.floater.reparentTo(render) # Enable Particles base.enableParticles() # Accept the control keys for movement and rotation self.accept("escape", sys.exit) self.accept("arrow_left", self.setKey, ["left",1]) self.accept("arrow_right", self.setKey, ["right",1]) self.accept("arrow_up", self.setKey, ["forward",1]) self.accept("space", self.setKey, ["run",1]) self.accept("a", self.setKey, ["cam-left",1]) self.accept("s", self.setKey, ["cam-right",1]) self.accept("r", self.setKey, ["reset",1]) self.accept("arrow_left-up", self.setKey, ["left",0]) self.accept("arrow_right-up", self.setKey, ["right",0]) self.accept("arrow_up-up", self.setKey, ["forward",0]) self.accept("space-up", self.setKey, ["run",0]) self.accept("a-up", self.setKey, ["cam-left",0]) self.accept("s-up", self.setKey, ["cam-right",0]) self.accept("r-up", self.setKey, ["reset",0]) taskMgr.add(self.move,"moveTask") # Game state variables self.isMoving = False self.isRunning = False self.isWalking = False # Set up the camera base.disableMouse() base.camera.setPos(self.eve.getX(),self.eve.getY()+10,2) # Collision detection for eve against the ground and against objects # We will detect the height of the terrain by creating a collision # ray and casting it downward toward the terrain. One ray will # start above eve's head, and the other will start above the camera. # A ray may hit the terrain, or it may hit a rock or a tree. If it # hits the terrain, we can detect the height. If it hits anything # else, we rule that the move is illegal. self.cTrav = CollisionTraverser() self.eveGroundRay = CollisionRay() self.eveGroundRay.setOrigin(0,0,4.5) self.eveGroundRay.setDirection(0,0,-1) self.eveGroundCol = CollisionNode('eveRay') self.eveGroundCol.addSolid(self.eveGroundRay) self.eveGroundCol.setFromCollideMask(BitMask32.bit(0)) self.eveGroundCol.setIntoCollideMask(BitMask32.allOff()) self.eveGroundColNp = self.eve.attachNewNode(self.eveGroundCol) self.eveGroundHandler = CollisionHandlerQueue() self.cTrav.addCollider(self.eveGroundColNp, self.eveGroundHandler) self.dragonGroundRay = CollisionRay() self.dragonGroundRay.setOrigin(0,0,10) self.dragonGroundRay.setDirection(0,0,-1) self.dragonGroundCol = CollisionNode('dragonRay') self.dragonGroundCol.addSolid(self.dragonGroundRay) self.dragonGroundCol.setFromCollideMask(BitMask32.bit(0)) self.dragonGroundCol.setIntoCollideMask(BitMask32.allOff()) self.dragonGroundColNp = self.character.attachNewNode(self.dragonGroundCol) self.dragonGroundHandler = CollisionHandlerQueue() self.cTrav.addCollider(self.dragonGroundColNp, self.dragonGroundHandler) self.ghostDragonGroundRay = CollisionRay() self.ghostDragonGroundRay.setOrigin(0,0,25) self.ghostDragonGroundRay.setDirection(0,0,-1) self.ghostDragonGroundCol = CollisionNode('ghostDragonRay') self.ghostDragonGroundCol.addSolid(self.ghostDragonGroundRay) self.ghostDragonGroundCol.setFromCollideMask(BitMask32.bit(0)) self.ghostDragonGroundCol.setIntoCollideMask(BitMask32.allOff()) self.ghostDragonGroundColNp = self.character3.attachNewNode(self.ghostDragonGroundCol) self.ghostDragonGroundHandler = CollisionHandlerQueue() self.cTrav.addCollider(self.ghostDragonGroundColNp, self.ghostDragonGroundHandler) self.redDragonGroundRay = CollisionRay() self.redDragonGroundRay.setOrigin(0,0,5) self.redDragonGroundRay.setDirection(0,0,-1) self.redDragonGroundCol = CollisionNode('redDragonRay') self.redDragonGroundCol.addSolid(self.redDragonGroundRay) self.redDragonGroundCol.setFromCollideMask(BitMask32.bit(0)) self.redDragonGroundCol.setIntoCollideMask(BitMask32.allOff()) self.redDragonGroundColNp = self.character2.attachNewNode(self.ghostDragonGroundCol) self.redDragonGroundHandler = CollisionHandlerQueue() self.cTrav.addCollider(self.redDragonGroundColNp, self.redDragonGroundHandler) self.pieRay = CollisionRay() self.pieRay.setOrigin(0,0,10) self.pieRay.setDirection(0,0,-1) self.pieCol = CollisionNode('pieRay') self.pieCol.addSolid(self.pieRay) self.pieCol.setFromCollideMask(BitMask32.bit(0)) self.pieCol.setIntoCollideMask(BitMask32.allOff()) self.pieColNp = self.pie.attachNewNode(self.pieCol) self.pieHandler = CollisionHandlerQueue() self.cTrav.addCollider(self.pieColNp, self.pieHandler) self.camGroundRay = CollisionRay() self.camGroundRay.setOrigin(0,0,1000) self.camGroundRay.setDirection(0,0,-1) self.camGroundCol = CollisionNode('camRay') self.camGroundCol.addSolid(self.camGroundRay) self.camGroundCol.setFromCollideMask(BitMask32.bit(0)) self.camGroundCol.setIntoCollideMask(BitMask32.allOff()) self.camGroundColNp = base.camera.attachNewNode(self.camGroundCol) self.camGroundHandler = CollisionHandlerQueue() self.cTrav.addCollider(self.camGroundColNp, self.camGroundHandler) # Shows collision rays #self.eveGroundColNp.show() #self.camGroundColNp.show() # Shows collisions #self.cTrav.showCollisions(render) self.fixPieZ() # Create some lighting ambientLight = AmbientLight("ambientLight") ambientLight.setColor(Vec4(.3, .3, .3, 1)) directionalLight = DirectionalLight("directionalLight") directionalLight.setDirection(Vec3(-5, -5, -5)) directionalLight.setColor(Vec4(1, 1, 1, 1)) directionalLight.setSpecularColor(Vec4(1, 1, 1, 1)) #directionalLight.setShadowCaster(True, 512, 512) render.setLight(render.attachNewNode(ambientLight)) render.setLight(render.attachNewNode(directionalLight))
def enterSetup(self): """ The silly meter has three different phases, each with thier own animation. In addition one animation plays continuously """ ropes = loader.loadModel("phase_4/models/modules/tt_m_ara_int_ropes") ropes.reparentTo(self.interior) self.sillyMeter = Actor.Actor("phase_4/models/props/tt_a_ara_ttc_sillyMeter_default", \ { "arrowTube" : "phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid", "phaseOne" : "phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseOne", "phaseTwo" : "phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseTwo", "phaseThree" : "phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseThree", "phaseFour" : "phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFour", "phaseFourToFive" : "phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive", "phaseFive" : "phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive", }) self.sillyMeter.reparentTo(self.interior) self.flatSillyMeter = loader.loadModel( "phase_3.5/models/modules/tt_m_ara_int_sillyMeterFlat") self.flatSillyMeter.reparentTo(self.interior) self.flatSillyMeter.hide() self.flatDuck = loader.loadModel( "phase_3.5/models/modules/tt_m_ara_int_scientistDuckFlat") loc1 = self.interior.find("**/npc_origin_1") if loc1: self.flatDuck.reparentTo(loc1) self.flatDuck.hide() self.flatMonkey = loader.loadModel( "phase_3.5/models/modules/tt_m_ara_int_scientistMonkeyFlat") loc1 = self.interior.find("**/npc_origin_2") if loc1: self.flatMonkey.reparentTo(loc1) self.flatMonkey.hide() self.flatHorse = loader.loadModel( "phase_3.5/models/modules/tt_m_ara_int_scientistHorseFlat") loc1 = self.interior.find("**/npc_origin_3") if loc1: self.flatHorse.reparentTo(loc1) self.flatHorse.hide() self.smPhase1 = self.sillyMeter.find("**/stage1") self.smPhase2 = self.sillyMeter.find("**/stage2") self.smPhase3 = self.sillyMeter.find("**/stage3") self.smPhase4 = self.sillyMeter.find("**/stage4") self.smPhase2.hide() self.smPhase3.hide() self.smPhase4.hide() thermometerLocator = self.sillyMeter.findAllMatches( "**/uvj_progressBar")[1] thermometerMesh = self.sillyMeter.find("**/tube") thermometerMesh.setTexProjector( thermometerMesh.findTextureStage("default"), thermometerLocator, self.sillyMeter) self.sillyMeter.flattenMedium() self.sillyMeter.makeSubpart("arrow", ["uvj_progressBar*", "def_springA"]) self.sillyMeter.makeSubpart("meter", ["def_pivot"], ["uvj_progressBar*", "def_springA"]) # Load in the sounds self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera) self.phase1Sfx = self.audio3d.loadSfx( "phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseOne.mp3") self.phase1Sfx.setLoop(True) self.phase2Sfx = self.audio3d.loadSfx( "phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseTwo.mp3") self.phase2Sfx.setLoop(True) self.phase3Sfx = self.audio3d.loadSfx( "phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseThree.mp3") self.phase3Sfx.setLoop(True) self.phase4Sfx = self.audio3d.loadSfx( "phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFour.mp3") self.phase4Sfx.setLoop(True) self.phase4To5Sfx = self.audio3d.loadSfx( "phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFourToFive.mp3") self.phase4To5Sfx.setLoop(False) self.phase5Sfx = self.audio3d.loadSfx( "phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseFive.mp3") self.phase5Sfx.setLoop(True) self.arrowSfx = self.audio3d.loadSfx( "phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.mp3" ) # The arrow reaches its destination self.arrowSfx.setLoop(False) self.audio3d.setDropOffFactor(0.1) self.accept("SillyMeterPhase", self.selectPhase) self.startIfNeeded()
def __init__(self, loadscreen, root): self.loadscreen=loadscreen #base.openMainWindow() if not config_safemode.getValue(): render.setShaderAuto() base.disableMouse() #base.setBackgroundColor(0, 0, 0) if not config_safemode.getValue(): if config_aa.getValue()>0: render.setAntialias(AntialiasAttrib.MMultisample) base.camLens.setNearFar(3, 40) self.common={} self.common['root']=root self.common['safemode']=config_safemode.getValue() #print self.common['safemode'] #keys self.common['keymap']={} self.common['keymap']['key_menuitems']=config_menuitems.getValue() self.common['keymap']['key_useitem']=config_useitem.getValue() self.common['keymap']['key_nextitem']=config_nextitem.getValue() self.common['keymap']['key_forward']=config_forward.getValue().split('|') self.common['keymap']['key_back']=config_back.getValue().split('|') self.common['keymap']['key_left']=config_left.getValue().split('|') self.common['keymap']['key_right']=config_right.getValue().split('|') self.common['keymap']['key_cam_left']=config_camera_left.getValue().split('|') self.common['keymap']['key_cam_right']=config_camera_right.getValue().split('|') self.common['keymap']['key_action1']=config_action1.getValue().split('|') self.common['keymap']['key_action2']=config_action2.getValue().split('|') self.common['keymap']['key_zoomin']=config_zoomin.getValue().split('|') self.common['keymap']['key_zoomout']=config_zoomout.getValue().split('|') self.common['extra_ambient']=True self.common['path']=path self.common['max_level']=0 self.common["key_icon"]=DirectFrame(frameSize=(-64, 0, 0, 64), frameColor=(1, 1, 1, 1), frameTexture="icon/icon_key2.png", parent=pixel2d) self.common["key_icon"].setPos(64,0,-64) self.common["key_icon"].setTransparency(TransparencyAttrib.MDual) self.common["key_icon"].hide() if config_bloom.getValue(): self.common['extra_ambient']=False if config_safemode.getValue(): self.common['extra_ambient']=True #print "extra ambient:", self.common['extra_ambient'] #audio 3d self.common['audio3d']=Audio3DManager.Audio3DManager(base.sfxManagerList[0], base.camera) self.common['audio3d'].setListenerVelocityAuto() self.common['audio3d'].setDropOffFactor(0.2) self.common['soundPool']=SoundPool(self.common) base.sfxManagerList[0].setVolume(config_sfx.getValue()*0.01) self.common['click']=base.loader.loadSfx("sfx/click_stereo.ogg") self.common['click2']=base.loader.loadSfx("sfx/pen-click-1.wav") #base.cTrav = CollisionTraverser() self.common['monsterList']=[] self.common['spawner']=Spawner(self.common) self.common['levelLoader']=LevelLoader(self.common) #self.common['PC']=PC(self.common) #self.common['PC'].node.setPos(-12, 0, 0) #spawner #self.spawner=Spawner(self.common, monster_limit=5, tick=9.13) #music base.musicManager.setVolume(config_music.getValue()*0.01) self.common['musicVolume']=config_music.getValue() self.common['soundVolume']=config_sfx.getValue() #self.music = [ # base.loadMusic("sfx/LuridDeliusion.ogg"), # base.loadMusic("sfx/DefyingCommodus.ogg"), # base.loadMusic("sfx/DarkDescent.ogg") #base.loadMusic("sfx/DarkAmulet.ogg"), #base.loadMusic("sfx/WastelandShowdown.ogg"), #base.loadMusic("sfx/HeroicDemise.ogg") # ] #self.musicSequence=Sequence() #for music in self.music: # self.musicSequence.append(SoundInterval(music)) #self.musicSequence.loop() #Monster(data.monsters[2],self.common, self.testPC, (12, -4, 0)) #self.flask=Interactive(self.common, "flask", (-12, 4, 0), 0.15, "vfx/icon_flask.png", "heal") #self.health=Actor("models/health", {"anim":"models/health_anim"}) #self.health.loop("anim") #self.health.reparentTo(render) #self.health.setPos(-12, 4, 0) #self.health.setScale(0.2) #self.health.setLightOff() self.common['traverser']=CollisionTraverser("playerTrav") self.common['traverser'].setRespectPrevTransform(True) self.common['queue'] = CollisionHandlerQueue() self.common['CharGen']=CharGen(self.common) base.openMainWindow(props = wp) #bloom if not config_safemode.getValue(): if config_bloom.getValue(): self.bloomBuffer=base.win.makeTextureBuffer("bloom", buff_size.getValue(), buff_size.getValue()) self.bloomBuffer.setSort(-3) self.bloomBuffer.setClearColor(Vec4(0,0,0,1)) self.bloomCamera=base.makeCamera(self.bloomBuffer, lens=base.cam.node().getLens()) glowShader=loader.loadShader("shaders/glowShader.sha") tempnode = NodePath(PandaNode("temp node")) tempnode.setShader(glowShader) self.bloomCamera.node().setInitialState(tempnode.getState()) self.blurBuffer=self.makeFilterBuffer(self.bloomBuffer, "Blur X", -2, "shaders/blur.sha") self.finalcard = self.blurBuffer.getTextureCard() self.finalcard.reparentTo(render2d) self.finalcard.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) #shadow buffer self.shadowTexture=Texture() self.shadowTexture.setWrapU(Texture.WMBorderColor) self.shadowTexture.setWrapV(Texture.WMBorderColor) self.shadowTexture.setBorderColor(Vec4(1,1,1,1)) self.shadowBuffer = base.win.makeTextureBuffer("Shadow Buffer",buff_size.getValue(), buff_size.getValue(), self.shadowTexture) self.shadowBuffer.setClearColor((1,1,1,1)) self.shadowCamera = base.makeCamera(self.shadowBuffer) self.shadowNode = render.attachNewNode('shadowNode') self.shadowNode.setP(-90) #self.shadowNode.setZ(18) self.shadowCamera.reparentTo(self.shadowNode) #self.shadowCamera.node().showFrustum() self.shadow_lens = PerspectiveLens() self.shadow_lens.setFov(160) self.shadow_lens.setNearFar(0.01,4) self.shadowCamera.node().setLens(self.shadow_lens) self.shadowCamera.node().setCameraMask(BitMask32.bit(1)) self.initial = NodePath('initial') #self.initial.setTextureOff(2) #self.initial.setMaterialOff(2) self.initial.setLightOff(2) self.initial.setColor(0,0,0,1) self.shadowCamera.node().setInitialState(self.initial.getState()) shadow_manager = FilterManager(self.shadowBuffer, self.shadowCamera) sh_tex1 = Texture() quad = shadow_manager.renderSceneInto(colortex=sh_tex1) quad.setShader(Shader.load("shaders/shadow.sha")) quad.setShaderInput("tex1", sh_tex1) self.shadow_ts=TextureStage('shadow') self.common['shadowNode']=self.shadowNode self.common['shadow_ts']=self.shadow_ts self.common['shadowTexture']=self.shadowTexture self.common['shadowCamera']= self.shadowCamera taskMgr.add(self.hideLoadscreen, 'hideLoadscreenTask') self.accept("x", self.screenshot)
def __init__(self): self.keyMap = { "left": 0, "right": 0, "forward": 0, "cam-left": 0, "cam-right": 0 } base.win.setClearColor(Vec4(0, 0, 0, 1)) self.speed = 0 self.font_digital = loader.loadFont('font/SFDigitalReadout-Heavy.ttf') # Speedometer self.speed_img = OnscreenImage(image="models/speedometer.png", scale=.5, pos=(1.1, 0, -.95)) self.speed_img.setTransparency(TransparencyAttrib.MAlpha) OnscreenText(text="km\n/h", style=1, fg=(1, 1, 1, 1), font=self.font_digital, scale=.07, pos=(1.25, -.92)) # Display Speed self.display_speed = OnscreenText(text=str(self.speed), style=1, fg=(1, 1, 1, 1), pos=(1.3, -0.95), align=TextNode.ARight, scale=.07, font=self.font_digital) # Health Bar self.bars = {'H': 100, 'EH': 0, 'A': 0} # bk_text = "This is my Demo" # self.textObject = OnscreenText(text = bk_text, pos = (0.55,-0.05),scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1) self.Health_bar = DirectWaitBar(text="", value=100, pos=(0.280, 0, 0.475), barColor=(1, 0, 0, 1), frameSize=(0, .705, .3, .35)) self.EHealth_bar = DirectWaitBar(text="", value=0, pos=(1, 0, 0.475), barColor=(0, 1, 0, 1), frameSize=(0, .23, .3, .35), range=50) self.Armour_bar = DirectWaitBar(text="", value=0, pos=(.43, 0, .593), barColor=(159, 0, 255, 1), frameSize=(0, .8, .3, .35)) self.Health = DirectWaitBar(text="", value=100, barColor=(1, 0, 0, 1), frameSize=(-1, 1, .3, .5), scale=2) # create a frame # myFrame = DirectFrame(frameColor=(1, 0, 0, 1), # frameSize=(0, .8, 0, .2)) # self.bar = DirectWaitBar(text = "hi", # value = 0, # range = 500, # pos = ( 0,0,0), # barColor = (0.97,0,0,1), # frameSize = (-0.3,0.3,0.5,0.8), # text_mayChange = 1, # text_shadow =(0,0,0,0.8), # text_fg = (0.9,0.9,0.9,1), # text_scale = 0.025, # text_pos = (0,0.01,0)) def getHealthStatus(): return self.bars def displayBars(): health = getHealthStatus() self.Health_bar['value'] = health['H'] self.EHealth_bar['value'] = health['EH'] self.Armour_bar['value'] = health['A'] self.Health['value'] = health['H'] def armourPickup(): self.bars['A'] += 25 displayBars() def healthPickup(): self.bars['EH'] += 25 displayBars() def decHealth(): self.bars['H'] -= 10 displayBars() def initialiseSound(audioManager): """Start the engine sound and set collision sounds""" # Set sounds to play for collisions # self.collisionSound = CollisionSound( # nodePath=self.np, # sounds=["data/sounds/09.wav"], # thresholdForce=600.0, # maxForce=800000.0) # np - nodePath self.engineSound = audioManager.loadSfx("sound/engine.wav") audioManager.attachSoundToObject(self.engineSound, self.ralph) self.engineSound.setLoop(True) self.engineSound.setPlayRate(0.6) self.engineSound.play() # self.gearSpacing = (self.specs["sound"]["maxExpectedRotationRate"] / # self.specs["sound"]["numberOfGears"]) self.gearSpacing = (150 / 4) self.reversing = False # Post the instructions self.frame = OnscreenImage(image="models/gframe.png", pos=(0, 0, 0), scale=(1.25, 1, 1)) self.frame.setTransparency(TransparencyAttrib.MAlpha) # self.title = addTitle("Panda3D Tutorial: Roaming Ralph (Walking on the Moon)") self.inst1 = addInstructions(0.95, "[ESC]: Quit") self.inst2 = addInstructions(0.90, "[Left Arrow]: Rotate Ralph Left") self.inst3 = addInstructions(0.85, "[Right Arrow]: Rotate Ralph Right") self.inst4 = addInstructions(0.80, "[Up Arrow]: Run Ralph Forward") self.inst6 = addInstructions(0.70, "[A]: Rotate Camera Left") self.inst7 = addInstructions(0.65, "[S]: Rotate Camera Right") # Set up the environment # self.environ = loader.loadModel("models/square") self.environ.reparentTo(render) self.environ.setPos(0, 0, 0) self.environ.setScale(100, 100, 1) self.moon_tex = loader.loadTexture("models/moon_1k_tex.jpg") self.environ.setTexture(self.moon_tex, 1) # Create the main character, Ralph self.ralph = Actor("models/ralph", { "run": "models/ralph-run", "walk": "models/ralph-walk" }) self.ralph.reparentTo(render) self.ralph.setScale(.2) self.ralph.setPos(0, 0, 0) # # Load and place the model # self.eNode = render.attachNewNode('enemyBaseNode') # self.eNode.setPos( 0,0,0 ) # self.model = loader.loadModel( 'models/ralph' ) # self.model.reparentTo( self.eNode ) # # Setup the rest of what the enemy needs # self.setupHealthBar() # self.Health.setBillboardAxis() # self.Health.setBillboardPointWorld() # self.Health.setBillboardPointEye() # self.Health.setLightOff() self.Health.setPos(0, 0, 5) self.Health.setBillboardPointEye() self.Health.setBin('fixed', 0) self.Health.setDepthWrite(False) self.Health.reparentTo(self.ralph) # myFrame.setPos(0, 0, 8) # myFrame.setBillboardPointEye() # myFrame.reparentTo(self.ralph) # self.Health.clearBillboard() # Create a floater object. We use the "floater" as a temporary # variable in a variety of calculations. self.floater = NodePath(PandaNode("floater")) self.floater.reparentTo(render) # Accept the control keys for movement and rotation self.accept("escape", sys.exit) self.accept("arrow_left", self.setKey, ["left", 1]) self.accept("arrow_right", self.setKey, ["right", 1]) self.accept("arrow_up", self.setKey, ["forward", 1]) self.accept("a", self.setKey, ["cam-left", 1]) self.accept("s", self.setKey, ["cam-right", 1]) self.accept("arrow_left-up", self.setKey, ["left", 0]) self.accept("arrow_right-up", self.setKey, ["right", 0]) self.accept("arrow_up-up", self.setKey, ["forward", 0]) self.accept("a-up", self.setKey, ["cam-left", 0]) self.accept("s-up", self.setKey, ["cam-right", 0]) self.accept("h", decHealth) self.accept("j", healthPickup) self.accept("k", armourPickup) taskMgr.add(self.move, "moveTask") taskMgr.doMethodLater(.1, self.show_speed, 'updateSpeed') # Game state variables self.isMoving = False # Set up the camera base.disableMouse() base.camera.setPos(self.ralph.getX(), self.ralph.getY() + 10, 2) # Create some lighting ambientLight = AmbientLight("ambientLight") ambientLight.setColor(Vec4(.3, .3, .3, 1)) directionalLight = DirectionalLight("directionalLight") directionalLight.setDirection(Vec3(-5, -5, -5)) directionalLight.setColor(Vec4(1, 1, 1, 1)) directionalLight.setSpecularColor(Vec4(1, 1, 1, 1)) render.setLight(render.attachNewNode(ambientLight)) render.setLight(render.attachNewNode(directionalLight)) # Create an audio manager. This is attached to the camera for # player 1, so sounds close to other players might not be very # loud self.audioManager = Audio3DManager.Audio3DManager( base.sfxManagerList[0], base.camera) # Distance should be in m, not feet self.audioManager.setDistanceFactor(3.28084) initialiseSound(self.audioManager) displayBars()
def __init__(self, id, parent, type, pos): self.id = id self.parent = parent self.hp = 100 self.speed = 1 self.can_move = True if type == 'baby': self.node = Actor( 'models/baby', { 'walk': 'models/baby-walk', 'stand': 'models/baby-stand', 'idle': 'models/baby-idle', 'jump': 'models/baby-jump', 'bite1': 'models/baby-bite1', 'bite2': 'models/baby-bite2', 'head_attack': 'models/baby-head_attack', 'hit1': 'models/baby-hit1', 'hit2': 'models/baby-hit2', 'die': 'models/baby-die' }) self.head_node = self.node.exposeJoint(None, "modelRoot", "Bip01_Head") self.body_node = self.node.exposeJoint(None, "modelRoot", "Bip01_Pelvis") self.node.setH(180) self.node.setScale(0.03) self.node.flattenLight() self.zpos = 0 self.node.setPos(pos[0] * TILE_SIZE, pos[1] * TILE_SIZE, self.zpos) self.node.setTexture(loader.loadTexture('models/Zomby_D.png')) self.ts_normal = TextureStage('ts_normal') self.tex_normal = loader.loadTexture('models/Zomby_N.png') self.ts_normal.setMode(TextureStage.MNormal) self.node.setTexture(self.ts_normal, self.tex_normal) self.ts_gloss = TextureStage('ts_gloss') self.tex_gloss = loader.loadTexture('models/Zomby_S1.png') self.ts_gloss.setMode(TextureStage.MGloss) self.node.setTexture(self.ts_gloss, self.tex_gloss) self.ts_glow = TextureStage('ts_glow') self.tex_glow = loader.loadTexture('models/Zomby_I.png') self.ts_glow.setMode(TextureStage.MGlow) self.node.setTexture(self.ts_glow, self.tex_glow) self.node.reparentTo(render) self.node.loop('walk') elif type == 'nos': self.node = loader.loadModel('models/nos') self.zpos = 5 self.node.setPos(pos[0] * TILE_SIZE, pos[1] * TILE_SIZE, self.zpos) self.node.setScale(2) if self.id == 1: self.node.setColor(1, 0, 0) elif self.id == 2: self.node.setColor(0, 1, 0) elif self.id == 3: self.node.setColor(0, 0, 1) else: self.node.setColor(1, 1, 1) self.node.reparentTo(render) #self.patrol_points = [(1,1), (4,11), (12,20), (18,4), (19,17)] #initialize 3d sound self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], base.camera) self.shot_head = self.audio3d.loadSfx( 'audio/Zombie In Pain-SoundBible.com-134322253.wav') self.shot_body = self.audio3d.loadSfx( 'audio/Zombie Moan-SoundBible.com-565291980.wav') self.moan1 = self.audio3d.loadSfx( 'audio/Mindless Zombie Awakening-SoundBible.com-255444348.wav') self.moan2 = self.audio3d.loadSfx( 'audio/Zombie Brain Eater-SoundBible.com-1076387080.wav') self.aggro_sound = self.audio3d.loadSfx( 'audio/Mummy Zombie-SoundBible.com-1966938763.wav') self.attack_sound = self.audio3d.loadSfx( 'audio/Chopping Off Limb-SoundBible.com-884800545.wav') self.audio3d.attachSoundToObject(self.moan1, self.node) self.audio3d.attachSoundToObject(self.moan2, self.node) self.audio3d.attachSoundToObject(self.shot_head, self.node) self.audio3d.attachSoundToObject(self.shot_body, self.node) self.audio3d.attachSoundToObject(self.aggro_sound, self.node) self.audio3d.attachSoundToObject(self.attack_sound, self.node) delay0 = Wait(d(35)) delay1 = Wait(25 + d(35)) delay2 = Wait(25 + d(35)) self.moan_sequence = Sequence(delay0, SoundInterval(self.moan1), delay1, SoundInterval(self.moan2), delay2) self.moan_sequence.loop() self.parent.collision_manager.createMonsterCollision(self) self.aggro_sound_last_played = 0 #--------------------------brain------------------------- self.node.setH(160) self.pause = False self.action = ACTION_IDLE if percent(20): self.orders = ORDERS_PATROL else: self.orders = ORDERS_IDLE self.last_melee = 0 self.player_last_seen_abs = None self.idle_timer = time.time() self.idle_value = 1 self.current_waypoint = None #self.wait_until = None self.herding_timer = None self.path = None taskMgr.doMethodLater(1, self.behaviourTask, 'MonsterBehaviourTask' + str(self.id)) taskMgr.doMethodLater(1, self.debugMoveTask, 'MonsterMoveTask' + str(self.id))
def __init__(self): DirectObject.__init__(self) base.cr.DMENU_SCREEN = self self.seq = None self.isSeqPlaying = False # .isPlaying() doesnt want to work base.cr.avChoice = None fadeSequence = Sequence( Func(base.transitions.fadeOut, .001), Wait(.5), Func(base.transitions.fadeIn, .5), base.camera.posHprInterval(1, Point3(MAIN_POS), VBase3(MAIN_HPR), blendType = 'easeInOut')).start() if base.showDisclaimer: FeatureComingSoonDialog.FeatureComingSoonDialog(text = '\1textShadow\1Disclaimer:\2\nThis is an ALPHA build of Project Altis! Expect the server to restart a lot, and expect crashes and other bugs. Please report bugs to the team. Thanks, and enjoy Project Altis!') self.background2d = OnscreenImage(image = 'phase_3.5/maps/loading/toon.jpg', parent = aspect2d) self.background2d.setScale(2, 1, 1) self.background2d.setBin('background', 1) self.background2d.setTransparency(1) self.background2d.setColorScale(1, 1, 1, .2) self.background = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_toonhall') self.background.reparentTo(render) self.background.setPosHpr(-25, 0, 8.1, -95, 0, 0) ropes = loader.loadModel('phase_4/models/modules/tt_m_ara_int_ropes') ropes.reparentTo(self.background) self.sillyMeter = Actor.Actor('phase_4/models/props/tt_a_ara_ttc_sillyMeter_default', {'arrowTube': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid', 'phaseOne': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseOne', 'phaseTwo': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseTwo', 'phaseThree': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseThree', 'phaseFour': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFour', 'phaseFourToFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive', 'phaseFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive'}) self.sillyMeter.reparentTo(self.background) self.sillyMeter.makeSubpart('arrow', ['uvj_progressBar*', 'def_springA']) self.sillyMeter.makeSubpart('meter', ['def_pivot'], ['uvj_progressBar*', 'def_springA']) self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera) self.phase3Sfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterPhaseThree.ogg') self.phase3Sfx.setLoop(True) self.arrowSfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.ogg') self.arrowSfx.setLoop(False) self.phase3Sfx.setVolume(0.2) self.arrowSfx.setVolume(0.2) self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName = 'arrow', constrainedLoop = 0, startFrame = 236, endFrame = 247), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName = 'arrow', duration = 604800, constrainedLoop = 1, startFrame = 247, endFrame = 276), Sequence(Func(self.phase3Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase3Sfx, self.sillyMeter)))) self.animSeq.start() self.smPhase1 = self.sillyMeter.find('**/stage1') self.smPhase1.show() self.smPhase2 = self.sillyMeter.find('**/stage2') self.smPhase2.hide() self.smPhase3 = self.sillyMeter.find('**/stage3') self.smPhase3.hide() self.smPhase4 = self.sillyMeter.find('**/stage4') self.smPhase4.hide() thermometerLocator = self.sillyMeter.findAllMatches('**/uvj_progressBar')[1] thermometerMesh = self.sillyMeter.find('**/tube') thermometerMesh.setTexProjector(thermometerMesh.findTextureStage('default'), thermometerLocator, self.sillyMeter) self.sillyMeter.loop('phaseOne', partName = 'meter') self.sillyMeter.setBlend(frameBlend = base.wantSmoothAnims) self.surlee = Toon.Toon() self.surlee.setName('Doctor Surlee') self.surlee.setPickable(0) self.surlee.setPlayerType(CCNonPlayer) dna = ToonDNA.ToonDNA() dna.newToonFromProperties('pls', 'ls', 'l', 'm', 9, 0, 9, 9, 98, 27, 86, 27, 38, 27) self.surlee.setDNA(dna) self.surlee.loop('scientistGame') self.surlee.reparentTo(self.background) self.surlee.setPosHpr(13, 24, 0.025, -180, 0, 0) self.dimm = Toon.Toon() self.dimm.setName('Doctor Dimm') self.dimm.setPickable(0) self.dimm.setPlayerType(CCNonPlayer) dna = ToonDNA.ToonDNA() dna.newToonFromProperties('fll', 'ss', 's', 'm', 15, 0, 15, 15, 99, 27, 86, 27, 39, 27) self.dimm.setDNA(dna) self.dimm.loop('scientistGame') self.dimm.reparentTo(self.background) self.dimm.setPosHpr(16, 24, 0.025, -180, 0, 0) surleeHand = self.surlee.find('**/def_joint_right_hold') clipBoard = loader.loadModel('phase_4/models/props/tt_m_prp_acs_clipboard') surleeHandNode = surleeHand.attachNewNode('ClipBoard') clipBoard.instanceTo(surleeHandNode) surleeHandNode.setH(180) surleeHandNode.setScale(render, 1.0) surleeHandNode.setPos(0, 0, 0.1) dimmHand = self.dimm.find('**/def_joint_right_hold') sillyReader = loader.loadModel('phase_4/models/props/tt_m_prp_acs_sillyReader') dimHandNode = dimmHand.attachNewNode('SillyReader') sillyReader.instanceTo(dimHandNode) dimHandNode.setH(180) dimHandNode.setScale(render, 1.0) dimHandNode.setPos(0, 0, 0.1) self.banana = self.background.find('**/gagBanana') self.bananaClicker = CollisionTraverser() # self.bananaClicker.showCollisions(render) self.collHandlerQueue = CollisionHandlerQueue() self.bananaRayNode = CollisionNode('bananaMouseRay') self.bananaRayNP = base.camera.attachNewNode(self.bananaRayNode) self.bananaRayNode.setIntoCollideMask(BitMask32.bit(0)) self.bananaRayNode.setFromCollideMask(BitMask32.bit(1)) self.banana.setCollideMask(BitMask32.bit(1)) self.ray = CollisionRay() self.bananaRayNode.addSolid(self.ray) self.bananaClicker.addCollider(self.bananaRayNP, self.collHandlerQueue) self.accept('mouse1', self.slipAndSlideOnThisBananaPeelHaHaHa) for frame in render.findAllMatches('*/doorFrame*'): frame.removeNode() self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') SkyUtil.startCloudSky(self) base.camera.setPosHpr(MAIN_POS, MAIN_HPR) self.logo = OnscreenImage(image = GameLogo, scale = (.5, .5, .25)) self.logo.reparentTo(aspect2d) self.logo.setTransparency(TransparencyAttrib.MAlpha) scale = self.logo.getScale() self.logo.setPos(0, 0, .5) self.logo.setColorScale(Vec4(0, 0, 0, 0)) fadeInLogo = (LerpColorScaleInterval(self.logo, 1, Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 0))).start() self.createButtons() self.fadeOut = None self.optionsMgr = PickAToonOptions.NewPickAToonOptions() self.quitConfirmation = DMenuQuit.DMenuQuit() self.accept('doQuitGame', self.doQuitFunc) self.accept('doCancelQuitGame', self.doCancelQuitFunc) self.patNode = None if DMENU_GAME == 'Toontown': # TT: We need these to run the Pick A Toon screen self.patAvList = base.cr.PAT_AVLIST self.patFSM = base.cr.PAT_LOGINFSM self.patDoneEvent = base.cr.PAT_DONEEVENT
def initAudioManager(self): self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], self.camera)