Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. # Pygame Development 1
  2. # Start the basic game set up
  3. # Set up the display
  4.  
  5. # Call the pygame library
  6. import pygame
  7.  
  8. # screen properties
  9. SCREEN_TITLE = 'Crossy RPG'
  10. SCREEN_WIDTH = 800
  11. SCREEN_HEIGHT = 800
  12.  
  13. WHITE_COLOR = (255, 255, 255)
  14. BLACK_COLOR = (0, 0, 0)
  15.  
  16. clock = pygame.time.Clock()
  17.  
  18. class Game:
  19.  
  20.     TICK_RATE = 60
  21.  
  22.     def __init__(self, title, width, height):
  23.         self.title = title
  24.         self.width = width
  25.         self.height = height
  26.  
  27.         game_screen = pygame.display.set_mode((width, height))
  28.         game_screen.fill(WHITE_COLOR)
  29.         pygame.display.set_caption(title)
  30.  
  31.     def run_game_loop(self):
  32.         is_game_over = False
  33.  
  34.         while not is_game_over:
  35.  
  36.             for event in pygame.event.get():
  37.                 if event.type == pygame.QUIT:
  38.                     is_game_over = True
  39.  
  40.                 print(event)
  41.  
  42.         # pygame.draw.rect(game_screen, BLACK_COLOR, [350, 350, 100, 100])
  43.         # pygame.draw.circle(game_screen, BLACK_COLOR, (400, 300), 50)
  44.  
  45.             # game_screen.blit(player_image, (375, 375))
  46.            
  47.             pygame.display.update()
  48.             clock.tick(self.TICK_RATE)
  49.  
  50. class GameObject:
  51.  
  52.     def __init__(self, image_path, x, y, width, height):
  53.  
  54.         object_image = pygame.image.load(image_path)
  55.         self.image = pygame.transform.scale(object_image, (width, height))
  56.        
  57.         self.x_pos = x
  58.         self.y_pos = y
  59.  
  60. # initialize pygame
  61. pygame.init()
  62.  
  63. new_game = Game(SCREEN_TITLE, SCREEN_WIDTH, SCREEN_HEIGHT)
  64. new_game.run_game_loop()
  65.  
  66. # player_image = pygame.image.load('images/player.png')
  67. # player_image = pygame.transform.scale(player_image, (50, 50))
  68.  
  69.  
  70. pygame.quit()
  71. quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement