the way things work

Hello and thanks in advance for the help. I come from a C++ background and now want to try panda3d and Python. I have read and understand the basics of the manual, and somewhat can understand python with its data structures, though I don’t have any practice yet. That is the end of my understanding.

So if I wanted to create an asteroids clone with python and panda3d, my first idea would be to create classes for most if not every object within the game, including the player, asteroids, bullets, and other ships if I have aliens, powerups, etc… I know the player ship needs to inherit from the DirectObject class so I can recieve keyboard events.

For every object, am I going to need a task associated, or would it be more effecient to have one longer task that updates the items??

Also, if I define a task within a class for example for an asteroid, they are going to use the same name for the task no matter how many asteroids I have. The manual states that several tasks equally named are no problem, so I’m good there.

But each individual task will only affect the individual object/class instance it is defined in correct??

I apologize if my post is confusing, but I’m just trying to understand better how python and panda3d work. Thanks for the help.

That’s merely a matter of preference.
However, there’s a benefit to using more tasks - If you put stuff in separate tasks, PStats (pandas performance analyzing tool) can easily tell you which tasks are heavier.
Also, there are several other benefits, including the ability to run tasks in separate threads, I think.

So there isn’t any large overhead related with having multiple tasks?? That is great, because I think for organizational purposes it would be better that way. The PStats benefit is also an advantage.

What about my other question. If I have tasks created within several asteroid objects(class instances), they will only touch the instance in which they were created right??

Yeah, if you specified “self.myTaskMethod” instead of “someOtherAsteroidInstance.myTaskMethod” to the task manager, and your task itself isn’t touching other classes, it should work fine.

Keep in mind that if you have asteroids which you plan to destroy later, you’ll also want to destroy the task - and if you remove a task by its name, all tasks with that name will get deleted. So make sure you remove tasks by their task object (returned by taskMgr.add) instead if you’re dealing with multiple instances.

Great. I figured that was the case. I figure I would probably in this case end up removing the task from the task itself by returning task.done instead of task.cont. Nice, I think I can now proceed. Thanks for your help.