Advertisement
fnadalt

Untitled

Jan 18th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. from direct.showbase.ShowBase import ShowBase
  2. from gameplay import Gameplay
  3.  
  4. class Game(ShowBase):
  5.    
  6.     def __init__(self):
  7.         ShowBase.__init__(self)
  8.         #
  9.         self.disableMouse()
  10.         self.render.setShaderAuto()
  11.         #
  12.         gameplay=Gameplay(self)
  13.         gameplay.start()
  14.  
  15. class Gameplay:
  16.  
  17.     def __init__(self, base):
  18.         self.base=base
  19.        
  20.     def start(self):
  21.         # meshes
  22.         self.terrain=Terrain(self.base)
  23.         self.player=Player(self.base)
  24.         # camera
  25.         #self.base.camera.setPos(1, -39, 1)
  26.         self.base.camera.setPos(0, -5, 1)
  27.    
  28.     def stop(self):
  29.         self.terrain=None
  30.  
  31. from panda3d.core import Vec2, Vec4
  32. from panda3d.core import AmbientLight, DirectionalLight
  33.  
  34. class Terrain:
  35.  
  36.     def __init__(self, base):
  37.         self.base=base
  38.         # model
  39.         self.model=self.base.loader.loadModel("models/terrain")
  40.         self.model.reparentTo(self.base.render)
  41.         # lights
  42.         #   ambient
  43.         alight=AmbientLight("alight")
  44.         alight.setColor(Vec4(0.4, 0.4, 0.4, 1))
  45.         alightP=self.base.render.attachNewNode(alight)
  46.         self.base.render.setLight(alightP)
  47.         #   directional
  48.         sun=DirectionalLight("sun")
  49.         sun.setColor(Vec4(1, 0.973, 0.491, 1))
  50.         sun.setShadowCaster(True, 4096, 4096)
  51.         sun.getLens().setFilmSize(Vec2(30, 30))
  52.         sun.getLens().setNearFar(10, 100)
  53.         sun.getLens().setFov(100)
  54.         sunP=self.base.render.attachNewNode(sun)
  55.         sunP.setHpr(10, -60, 10)
  56.         self.base.render.setLight(sunP)
  57.  
  58. class Player:
  59.    
  60.         def __init__(self, base):
  61.             self.base=base
  62.             #
  63.             self.model=self.base.loader.loadModel("models/player")
  64.             self.model.reparentTo(self.base.render)
  65.             #self.model.setPos(0, -31.1, 0.2)
  66.            
  67. if __name__=="__main__":
  68.     g=Game()
  69.     g.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement