Need help translating Python to C++

entries = []
for i in range(g1_groundhandler.getNumEntries()):
      entry = g1_groundhandler.getEntry(i)
      entries.append(entry)
entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),x.getSurfacePoint(render).getZ()))
if (len(entries)>0):
          self.tire.setZ(entries[0].getSurfacePoint(render).getZ()+5)

I’m translating a small little project written in Python into C++ but I’m having a bit of trouble with the above snippet because it includes lists and ranges which are very different (and much more confusing) in C++ from Python.

Could anybody give me a hand?

Also, if the above snippet looks familiar, it probably is because it is mostly ripped out of the roaming ralph tutorial. :smiley:

What you are asking for is general C++ help, it’s way beyond the scope of this forum. And I don’t think you should be using Panda in C++ if you need help with this. Unless your primary aim is to learn, of course, but there are much better resources for that than the panda forum.

Having said that it seems you really want help with C++ vectors, maybe read some tutorial like this first?

codeguru.com/cpp/cpp/cpp_mfc … php/c4027/

You could try and post a C++ snippet when you hit a specific problem.

EDIT: Btw, there’s a roaming ralph in C++ which may help:
discourse.panda3d.org/viewtopic.php?t=3433

Oh, I didn’t know the roaming ralph tutorial was also available in C++. Thanks for the links.

You can take idea about roaming ralph from the Internet. There are lots of tutorials are available which give you idea on it. Then there is no problem in C++.