SHARE
TWEET

Untitled

a guest Oct 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pygame
  2. import random
  3. from vikingclasses import Main
  4.  
  5. pygame.init()
  6. pygame.display.set_caption("Viking Game")
  7.  
  8.  
  9. # colors
  10. WHITE = (255, 255, 255)
  11. BLACK = (0, 0, 0)
  12. GREY = (100, 100, 100)
  13. RED = (255, 0, 0)
  14. GREEN = (0, 255, 0)
  15. BLUE = (0, 0, 255)
  16.  
  17.  
  18. window = pygame.display.set_mode((600, 500))
  19.  
  20. # main class
  21. grid = Main(600, 500, 50, GREY, window)
  22. grid.draw_grid()
  23.  
  24.  
  25. # player size and coordinates
  26. playerx = 100
  27. playery = 100
  28.  
  29. # clock
  30. clock = pygame.time.Clock()
  31.  
  32.  
  33.  
  34.  
  35. run = True
  36.  
  37. # mainloop
  38. while run:
  39.     clock.tick(30)
  40.     for event in pygame.event.get():
  41.         # escape function
  42.         if event.type == pygame.K_ESCAPE:
  43.             run = False
  44.         if event.type == pygame.QUIT:
  45.             run = False
  46.         # movement input
  47.         if event.type == pygame.KEYDOWN:
  48.             if event.key == pygame.K_w:
  49.                 playery -= tilesize
  50.             if event.key == pygame.K_s:
  51.                 playery += tilesize
  52.             if event.key == pygame.K_a:
  53.                 playerx -= tilesize
  54.             if event.key == pygame.K_d:
  55.                 playerx += tilesize
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.     # window and background
  65.     window = pygame.display.set_mode((width, height))
  66.     window.fill(BLACK)
  67.     # player
  68.     pygame.draw.rect(window, (0,200,0), (playerx, playery, tilesize, tilesize))
  69.  
  70.     pygame.display.update()
  71.  
  72. pygame.quit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top