gameplay.py 2.3 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. import json
  11. # GTK module ( Graphical interface
  12. import gi
  13. gi.require_version('Gtk', '3.0')
  14. from gi.repository import Gtk
  15. import cairo
  16. from modules import ui
  17. from modules import world
  18. def layer(game):
  19. # Setting up a cairo layer
  20. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
  21. game.current['w'],
  22. game.current['h'])
  23. layer = cairo.Context(surface)
  24. layer.set_antialias(cairo.ANTIALIAS_NONE) # Disable AA to prevent blured pixels
  25. # Prepare the layer for gameplay and do not draw the editor grid.
  26. world.draw(game, layer, 0, 0,
  27. game.current["w"],
  28. game.current["h"], grid=False)
  29. # Moving 79th around the map
  30. col = game.current["state"]["4211D79"]["colision"]
  31. # LEFT
  32. if 65361 in game.current["keys"]:
  33. if col and col[0] > game.current["state"]["4211D79"]["xyz"][0]\
  34. or not col:
  35. game.current["state"]["4211D79"]["xyz"][0] -= 3
  36. # RIGHT
  37. if 65363 in game.current["keys"]:
  38. if col and col[0] < game.current["state"]["4211D79"]["xyz"][0]\
  39. or not col:
  40. game.current["state"]["4211D79"]["xyz"][0] += 3
  41. # UP
  42. if 65362 in game.current["keys"]:
  43. if col and col[1] > game.current["state"]["4211D79"]["xyz"][1]\
  44. or not col:
  45. game.current["state"]["4211D79"]["xyz"][1] -= 2
  46. # DOWN
  47. if 65364 in game.current["keys"]:
  48. if col and col[1] < game.current["state"]["4211D79"]["xyz"][1]\
  49. or not col:
  50. game.current["state"]["4211D79"]["xyz"][1] += 2
  51. # Camera binding
  52. game.current["camera"][0] = 0 - game.previous["state"]["4211D79"]["xyz"][0] + (game.current["w"] / 2)
  53. game.current["camera"][1] = 0 - game.previous["state"]["4211D79"]["xyz"][1] + (game.current["h"] / 2)
  54. return surface