2

Basically, I am experimenting using Panda3D 1.9.2, Python 2.7.12 and pygame 1.9.1, and I'm experimenting by putting together Toontown Rewritten and Disney's Toontown Online assets in an attempt to create something random and see where I can get with it. I am brand new to coding in Python w/ Panda3D & pygame so I'm not sure at all what I am doing wrong. My code is:

from direct.actor.Actor import Actor
from pandac.PandaModules import *
from direct.task import Task
import math
from math import pi, sin, cos
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.interval.IntervalGlobal import Sequence
from pandac.PandaModules import Point3
from pandac.PandaModules import *
from panda3d.core import loadPrcFile

loadPrcFile("config.prc")

import direct.directbase.DirectStart
from panda3d.core import CollisionTraverser,CollisionNode
from panda3d.core import CollisionHandlerQueue,CollisionRay
from panda3d.core import Filename,AmbientLight,DirectionalLight
from panda3d.core import PandaNode, NodePath, Camera, TextNode
from panda3d.core import Vec3,Vec4,BitMask32
from direct.gui.OnscreenText import OnscreenText
from direct.actor.Actor import Actor
from direct.showbase.DirectObject import DirectObject
import pygame
pygame.init()
pygame.mixer.music.load('bgm.ogg')
pygame.mixer.music.play(-1, 0.0)
while pygame.mixer.music.get_busy() == True:
    continue

cog = Actor ('phase_3.5/models/char/suitA-mod.bam', {'action':'phase_4/models/char/suitA-neutral.bam'})
cog.loop('action')
cog.reparentTo(render)
cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1.0)
#SELLBOT cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1.0)
#CASHBOT cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1.0)
#LAWBOT cog.find('**/hands').setColor(0.75, 0.75, 0.95, 1.0)
#BOSSBOT cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1.0)
cog.setPos(0, 20, 0)

myTex = loader.loadTexture('phase_3.5/maps/c_blazer.jpg')
cog.findAllMatches('**/torso').setTexture(myTex, 1)
myTex2 = loader.loadTexture('phase_3.5/maps/c_leg.jpg')
cog.findAllMatches('**/legs').setTexture(myTex2, 1)
myTex3 = loader.loadTexture('phase_3.5/maps/c_sleeve.jpg')
cog.findAllMatches('**/arms').setTexture(myTex3, 1)

coghead = loader.loadModel('phase_4/models/char/suitA-heads.bam').find('**/yesman')
coghead.reparentTo(cog.find('**/joint_head'))

camera.hide()
base.oobe()
base.run()

This code just creates this mess: http://prntscr.com/bnvvae

I did not create the entire code, but rather modified someone's example that was posted online. It was only until I implemented the OGG file that it stopped working properly. I must also add that the music file plays perfectly fine, despite the program "not responding".

I'm not sure what I'm doing wrong. Can somebody help me please?

CoffeetipM8
  • 85
  • 1
  • 7
  • I don't think I see what's going wrong here. You're loading a music file and then playing it infinitely, then entering a while loop that exits only when it isn't playing the music anymore. But you're playing the music infinitely? So either I'm completely missing something or it's just not responding because of that while loop. – Spooky Jul 03 '16 at 21:40
  • The game without the music file code runs fine, but when I enter the music code in, it plays infinitely but the game stops responding while the music still plays. It loops fine, but the game doesn't work itself. – CoffeetipM8 Jul 07 '16 at 16:56
  • `while pygame.mixer.music.get_busy() == True: continue` is an infinite loop. The game becomes non-responsive because it's stuck in an infinite loop that does nothing. – Spooky Jul 08 '16 at 18:05
  • Try adding a `print("test")` statement after the while loop. If I'm right, it will never reach that point. – Spooky Jul 08 '16 at 18:06

1 Answers1

0

You don't need the while loop remove this code:

while pygame.mixer.music.get_busy() == True:
    continue
mgracer
  • 175
  • 1
  • 11