Hello again, I have been experimentating on splitting my game code into several separated .py files, after a lot of research I managed to learn part of the process, but what happens now is the following:
import direct.directbase.DirectStart from direct.gui.OnscreenImage import OnscreenImage from pandac.PandaModules import PandaNode, LightNode, TextNode, NodePath, Camera from pandac.PandaModules import Filename from pandac.PandaModules import PointLight, AmbientLight from pandac.PandaModules import LightRampAttrib, AuxBitplaneAttrib from pandac.PandaModules import CardMaker from pandac.PandaModules import Shader, Texture from pandac.PandaModules import Point3,Vec2,Vec3,Vec4,BitMask32 from pandac.PandaModules import * from direct.task import Task from direct.actor import Actor from direct.interval.IntervalGlobal import * from direct.showbase.DirectObject import DirectObject from direct.filter.CommonFilters import CommonFilters from direct.gui.OnscreenText import OnscreenText import random, sys, os, math ... from graphics import * ... MYDIR=os.path.abspath(sys.path) MYDIR=Filename.fromOsSpecific(MYDIR).getFullpath() ... #GraphicsManager() is a class from graphics.py g = GraphicsManager() ... run()
The above code is from the main file(main.py), in the same folder, the module graphics.py can be found, I have managed to acess this module with from graphics import*, but then I get when running the code the following:
NameError: global name 'Actor' is not defined
I find it strange, as I have already imported all necessary things in main.py, anyway I have even added from direct.actor import Actor again in graphics.py but to no use, any help is welcome. Below are parts of graphics.py
Class which manages Graphics class GraphicsManager(): def __init__(self): self.loadActor() def loadActor(self): self.player = render.attachNewNode("player") self.playerActor = Actor.Actor(MYDIR+"/data/graphics/3D/player/player") self.playerActor.reparentTo(self.player) self.playerActor.setY(self.player.getY()-0.5) self.player.setPos( -1.4,0,-1.1 ) self.playerActor.loop("still")
Hey, and thanks for all the help you all gave me before, you´re truly patient.