Advertisement
Guest User

newfile.py

a guest
Aug 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. from direct.showbase.ShowBase import ShowBase
  2. from panda3d.core import TextFont, TextNode
  3.  
  4. class MyApp(ShowBase):
  5.     def __init__(self):
  6.         ShowBase.__init__(self)
  7.  
  8.         # Make the background solid black (red, green, blue, alpha parameters)
  9.         self.setBackgroundColor(0, 0, 0, 1)
  10.  
  11.         # Define a solid (3D), high resolution font
  12.         font = loader.loadFont("ClearSans-Bold.ttf")
  13.         font.setRenderMode(TextFont.RMSolid)
  14.         font.setPixelsPerUnit(100)
  15.  
  16.         # Create some 3D text using the solid font
  17.         text = TextNode("")
  18.         text.setText("Hello World!")
  19.         text.setFont(font)
  20.         text.setAlign(TextNode.ACenter)
  21.  
  22.         # Add the 3D text to the renderer
  23.         textNP = render.attachNewNode(text)
  24.         textNP.setColor(0.5, 0.5, 1, 1)
  25.         textNP.setRenderModeWireframe()
  26.  
  27.         # Set Y position for the text, and allow the NodePath to be moved elsewhere
  28.         self.textY = 50
  29.         self.textNP = textNP
  30.         # Move the text every frame
  31.         self.taskMgr.add(self.moveTextTask, "moveTextTask")
  32.  
  33.     def moveTextTask(self, task):
  34.         # Move the text NodePath towards us by 0.1 units each frame
  35.         self.textNP.setPos(0, self.textY, -0.25)
  36.         self.textY -= 0.1
  37.  
  38.         # Quit if the text is moving behind the camera
  39.         if self.textY < -0.5:
  40.             self.userExit()
  41.  
  42.         # Continue with the task on the next frame
  43.         return task.cont
  44.  
  45. app = MyApp()
  46. app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement