testing.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # THIS IS A SOURCE CODE FILE FROM I'M NOT EVEN HUMAN THE GAME.
  2. # IT COULD BE USED IN A DIFFERENT PIECE OF SOFTWARE ( LIKE A
  3. # DIFFERENT GAME ), BUT IT WAS ORIGINALLY WRITTEN FOR I'M NOT
  4. # EVEN HUMAN THE GAME.
  5. # THE DEVELOPERS OF THE GAME ARE : (C) J.Y.AMIHUD, AYYZEE AND
  6. # OTHER CONTRIBUTORS. THIS AND OTHER FILES IN THIS GAME,
  7. # UNLESS SPECIFICALLY NOTED, COULD BE USED UNDER THE TERMS OF
  8. # GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER VERSION.
  9. import os
  10. # GTK module ( Graphical interface
  11. import gi
  12. gi.require_version('Gtk', '3.0')
  13. from gi.repository import Gtk
  14. import cairo
  15. from modules import ui
  16. def layer(game):
  17. # Setting up a cairo layer
  18. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
  19. game.current['w'],
  20. game.current['h'])
  21. layer = cairo.Context(surface)
  22. layer.set_antialias(cairo.ANTIALIAS_NONE)
  23. # Text settings
  24. layer.select_font_face("Monospace",
  25. cairo.FONT_SLANT_NORMAL,
  26. cairo.FONT_WEIGHT_NORMAL)
  27. current_fontoption = layer.get_font_options()
  28. current_fontoption.set_antialias(cairo.ANTIALIAS_NONE)
  29. layer.set_font_options(current_fontoption)
  30. # The FPS meter
  31. ui.color(game, layer, "#FFFFFF")
  32. ui.text(game, layer, "FPS: "+str(game.FPS), 5, 5 )
  33. ui.text(game, layer, "AFPS: "+str(game.AFPS),
  34. game.current["w"]-5, 5, align="right")
  35. # The keys
  36. ui.text(game, layer, str(game.current["keys"]),
  37. int(game.current["w"]/2), game.current["h"] - 15,
  38. align="center")
  39. # Mouse Visualization thingy
  40. for n ,button in enumerate(["LMB", "MMB", "RMB"]):
  41. if game.current[button]:
  42. # Each mouse line it's own color
  43. ui.color(game, layer, "red")
  44. if button == "MMB":
  45. ui.color(game, layer, "green")
  46. elif button == "RMB":
  47. ui.color(game, layer, "bright_blue")
  48. layer.move_to(game.current[button][0],
  49. game.current[button][1])
  50. layer.line_to(game.current["mx"],
  51. game.current["my"])
  52. layer.stroke()
  53. return surface