Panda Beginer Questions

I’ve just getting started with panda.
@Panda team: thanks for the excellent documentation,i have never seen good doc for any egnine like this,not even irrlicht and for soft app like visula studio.

But i want to create 2D game at first.I m at beginer level with python,i know C++ very well…&

I have these few questions:

1.Is it possible to create 2D game in panda with particle,render effects for game like:bomberman.
2. is it possible to load the gif & jpeg images in panda for the 2d game?
3.How to use the spriters with panda?
4.How to handle the sprite tranceparency as sprite might have color background?
5. Is there any tutorial which has covers such questions?

please do guide for the learning Panda3D.

---- Panda3D user since january 2008-------

Hi,

Yes, its’s possible. Though Panda3D is mainly focused at 3D, and not much 2d games for panda exist, it’s quite possible. But if you’re really into a 2D game, you’d better try a 2d game engine like pygame.

Yes, it is, together with a lot more image formats. Panda3D also comes with a CardMaker class which can convert an image into a textured plane.
For example, to load an image and put it on the 2d screen, it would be something like this: (assuming you use Python, but in C++ it works practically the same)

from pandac.PandaModules import CardMaker,Point2
cm=CardMaker("give-it-a-nice-name")
cm.setUvRange(Point2(0,0),Point2(1,1))
np=render2d.attachNewNode(cm.generate())
np.setTexture(loader.loadTexture("yourfile.gif"))
np.setPos(0,0,0) #center of the 2d screen
np.setScale(0.3) #make it smaller
#the next call is optional, if it has an alpha channel:
np.setTransparency(True) #if it has transparency,enable it

Well, I’d suggest adding an alpha channel for transparency in your image editor, and then calling setTransparency(True) on the nodepath. Though, if you can’t for some reason, Panda3D comes with a PNMImage class which can also pretty easily convert a certain color to transparency.

I have no clue. Actually, I don’t think there is a tutorial which discusses 2d game, though it should work pretty much the same. Please note that you will need to work with render2d or aspect2d instead of render and you have to interpret the Z position of objects as Y on the screen.

thanks for answering questions. :slight_smile:

you said pygame is option for 2d game but is 2D gaming not allowed or suppported with panda or not recommended.I heard with pygame it is huge learning curve than panda3D.

One more questions in case of movements,particles & collision detection,where to look for python calls,in manual or class reference file etc.?(This is 2D specific Q,is it work for both 2D&3D)

What you think?

Panda3D is possible with 2d, but AFAIK not much people use panda with 2d.
But if you want to go with Panda3D anyway, that’s fine.

Most stuff you’ll be able to find in the manual, if you can’t find it there, in the API Class Reference.
Collision Detection in 2D will be tricky. Panda3D does as far as I know not provide collision of 2d items, since they are infinitely thin. You could either implement your own sprite collision system, but there is also a different way, you can do it in a hidden scenegraph with 3d objects… but still tricky to implement.

Again, 2D libraries (pygame for python or SDL for c++ or a similar library) have better support for such things like 2d collision detection.

by 2d libraries like pygame are slow. Recommand pyglet for 2d but that just a wrapper on top of openGL. I am sure you can cook up some sprite code to work for you. If i wanted to do 2d i would choose panda3d because other libs are quite slow and limited.