i’m sorry I really blank in panda
n’ i’m really sorry for my grammar
how to build a several world in a single game, I doesn’t have idea how to eksplained it but if you play a rpg game like oblivion. when our actor is outside he/she is at the world that contains only outside environment meshes rendered.
and when our actor is go inside a house the game load a world that contains only interior of the house and place our character in there.
what is the method ( or sample code will be appreciate ) to make our game can make it save game
Thank you so much
I really appreciate for the help ( sampel code in python really help me )
worldNodePath().hide()
houseNodePath().show()
#maybe reposition the user at the door
player.setPos(houseNodePath.find('door1').getPos())
this is an example of what i did, look up pickle.
def load(self,file):
""" very tiny fuctnions to load the entire game state """
data = cPickle.load(open(file,"rb"))
self.users,self.zones = data
def save(self,file):
""" very tiny fuctnions to save the entire game state """
data = [self.users, self.zones]
data = cPickle.dumps(data)
open(file,'w').write(data)
I believe you need to set up collision events near the entrance to the house, so that when your character gets to a door and presses a button (or you could make it work automatically) the worldNodePath becomes hidden and the houseNodePath is shown and visa-versa, at least that is what would make sense to me.
the code works because in treeform example, all the world is defined in two python object that are users and zones. (according to the name, they maybe list of other python objects created by treeform)
So saving this two objects and restoring them later is enough to recreate the world.
Now, in your game you may have to save a very different list of objects (
ex players,buildings,props,scores etc…)
It’s up to you to define the list of object that need to be stored /restored between saves.
Note that by default, nearly every python object can be saved by treeform method (cpickles) but Panda3D objects nodepath/ actors and so on are no picklable with defaut pickle (i dont know for cpickles).
Note finally that you should include some safety check in your load procedure if you use stnd pickle because std pickle allow to load “code” instead of simple object, which is a big risk
now my character can go from Yogyakarta( indonesia ) to Bali just by opening the door
rather unrealistik, I know
the second is still my problem
I have do that manakel, I think I do right, just problem with my eye irritating code I gezz
my bad I can show it right now, coz Im in the public internet ( my computer not connected to Internet and dont ask the reason why!)
so I have no access to my py file