Hello
I am trying to make a method that uses PosInterval to move an object randomly from the top of the screen to the bottom of the screen. It was suggested to me that i use this new method with the Func command which creates the loop so that a random new position can be chosen after the sequence has stopped playing. Then call that method in the init to make it work, I have tried to do this however i am doing something wrong because the error I get in my terminal is this
DirectStart: Starting the game.
Known pipe types:
glxGraphicsPipe
(all display modules loaded.)
:display:glxdisplay(warning): No suitable FBConfig contexts available; using XVisual only.
depth_bits=24 color_bits=24 alpha_bits=8 stencil_bits=8 back_buffers=1 force_hardware=1
Traceback (most recent call last):
File "ball02.py", line 80, in <module>
w = world()
TypeError: __init__() takes exactly 2 arguments (1 given)
and here is the actual code
from direct.showbase.DirectObject import DirectObject
import direct.directbase.DirectStart
from random import choice
from direct.interval.IntervalGlobal import Sequence,Func
from panda3d.core import Point3
from direct.showbase.ShowBase import ShowBase
from direct.showbase import Audio3DManager
class world(DirectObject):
def __init__ (self, balloop):
base.setBackgroundColor(0, 0, 0) #Set the background to black
base.disableMouse()
camera.setPos (0, 0, 45) #Set the camera position (X, Y, Z)
camera.setHpr (0, -90, 0) #Set the camera orientation
#load the model and render it to the screen
self.sun = loader.loadModel("models/planet_sphere")
self.sun.reparentTo(render)
self.box = loader.loadModel("models/box")
self.box.reparentTo(render)
self.box.setPos(0, 0, 0)
self.audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], self.box)
self.audio3d.attachListener(self.box)
self.loop = self.audio3d.loadSfx("SFXmusic/sonicballs1.wav")
self.loop.setLoop(True)
self.audio3d.attachSoundToObject(self.loop, self.sun)
self.loop.play()
self.audio3d.setSoundVelocityAuto("SFXmusic/sonicballs1.wav")
#list of positions at the top of the screen
toppos = [ (-10, 20, 0),
(-8, 20, 0),
(-6, 20, 0),
(-4, 20, 0),
(-2, 20, 0),
(0, 20, 0),
(2, 20, 0),
(4, 20, 0),
(6, 20, 0),
(8, 20, 0),
(10, 20, 0) ]
bottompos = [ (-10, -20, 0),
(-8, -20, 0),
(-6, -20, 0),
(-4, -20, 0),
(-2, -20, 0),
(0, -20, 0),
(2, -20, 0),
(4, -20, 0),
(6, -20, 0),
(8, -20, 0),
(10, -20, 0)]
def balloop(self):
sunPosInterval1 = self.sun.posInterval(5,
Point3 (choice(bottompos)),
startPos=Point3 (choice(toppos)),
blendType=("easeIn"))
self.ball = Sequence(sunPosInterval1,
Func(self.balloop))
self.ball.loop()
w = world()
run()
So i know it has something to do with the init so am I not calling the method correctly can anyone suggest a solution to this problem
thanks