client.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # all imports needed by the engine itself
  2. from direct.showbase.ShowBase import ShowBase
  3. # import our own repositories
  4. from ClientRepository import GameClientRepository
  5. # initialize the engine
  6. base = ShowBase()
  7. # initialize the client
  8. client = GameClientRepository()
  9. base.accept("escape", exit)
  10. from direct.gui.OnscreenText import OnscreenText
  11. from panda3d.core import TextNode
  12. # Function to put instructions on the screen.
  13. def addInstructions(pos, msg):
  14. return OnscreenText(text=msg, style=1, fg=(0, 0, 0, 1), shadow=(1, 1, 1, 1),
  15. parent=base.a2dTopLeft, align=TextNode.ALeft,
  16. pos=(0.08, -pos - 0.04), scale=.06)
  17. # Function to put title on the screen.
  18. def addTitle(text):
  19. return OnscreenText(text=text, style=1, pos=(-0.1, 0.09), scale=.08,
  20. parent=base.a2dBottomRight, align=TextNode.ARight,
  21. fg=(1, 1, 1, 1), shadow=(0, 0, 0, 1))
  22. title = addTitle("Panda3D: Tutorial - Distributed Network (NOT CONNECTED)")
  23. inst1 = addInstructions(0.06, "esc: Close the client")
  24. inst2 = addInstructions(0.12, "See console output")
  25. def setConnectedMessage():
  26. title["text"] = "Panda3D: Tutorial - Distributed Network (CONNECTED)"
  27. base.accept("client-joined", setConnectedMessage)
  28. # start the client
  29. base.run()