Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. import pygame, sys, time, random
  2. from pygame.locals import *
  3. WINDOWWIDTH = 600
  4. WINDOWHEIGHT = 500
  5. WHITE = (255, 255, 255)
  6.  
  7. StateWorldMap = 0
  8. StateBattleGaren = 1
  9.  
  10. GameState = 0
  11.  
  12. GarenAlive = True
  13.  
  14.  
  15. def GarenEncounter():
  16. if GarenAlive:
  17. pygame.display.update()
  18. textbox = pygame.Rect(0, 300, 1, 1)
  19. textboxload = pygame.image.load('snak.png')
  20. textboxStretchedImage = pygame.transform.scale(textboxload, (600, 200))
  21. GarenProfile = pygame.image.load('BigGaren.jpg')
  22. GarenStretched = pygame.transform.scale(GarenProfile, (40, 60))
  23. screen.blit(textboxStretchedImage, textbox)
  24.  
  25.  
  26. # set up pygame
  27. pygame.init()
  28. mainClock = pygame.time.Clock()
  29. score = 0
  30. font = pygame.font.SysFont(None, 48)
  31. smallfont = pygame.font.SysFont(None, 24)
  32.  
  33. # set up the window
  34. screen = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
  35. pygame.display.set_caption('RPG Game')
  36. backgrounimage = pygame.Rect(0, 0, 10, 60)
  37. background_image = pygame.image.load("background.png")
  38. BackgroundImage = pygame.transform.scale(background_image, (600, 500))
  39.  
  40. # set up the block data structure
  41. player = pygame.Rect(20, 20,40, 60)
  42. playerImage = pygame.image.load('Ashe.png')
  43. playerStretchedImage = pygame.transform.scale(playerImage, (50, 50))
  44. Garen= pygame.Rect(80, 220, 25, 20)
  45. GarenImage = pygame.image.load('Garen.png')
  46. GarenStretchedImage = pygame.transform.scale(GarenImage, (50, 50))
  47.  
  48. # set up keyboard variables
  49. moveLeft = False
  50. moveRight = False
  51. moveUp = False
  52. moveDown = False
  53.  
  54. MOVESPEED = 2
  55.  
  56. # run the game loop
  57. while True:
  58. if GameState == StateWorldMap:
  59. # check for the QUIT event
  60. for event in pygame.event.get():
  61. if event.type == QUIT:
  62. pygame.quit()
  63. sys.exit()
  64. if event.type == KEYDOWN:
  65. # change the keyboard variables
  66. if event.key == K_LEFT or event.key == ord('a'):
  67. moveRight = False
  68. moveLeft = True
  69. if event.key == K_RIGHT or event.key == ord('d'):
  70. moveLeft = False
  71. moveRight = True
  72. if event.key == K_UP or event.key == ord('w'):
  73. moveDown = False
  74. moveUp = True
  75. if event.key == K_DOWN or event.key == ord('s'):
  76. moveUp = False
  77. moveDown = True
  78. if event.type == KEYUP:
  79. if event.key == K_ESCAPE:
  80. pygame.quit()
  81. sys.exit()
  82. if event.key == K_LEFT or event.key == ord('a'):
  83. moveLeft = False
  84. if event.key == K_RIGHT or event.key == ord('d'):
  85. moveRight = False
  86. if event.key == K_UP or event.key == ord('w'):
  87. moveUp = False
  88. if event.key == K_DOWN or event.key == ord('s'):
  89. moveDown = False
  90.  
  91. # draw the background onto the surface
  92. screen.fill(WHITE)
  93.  
  94. # move the player
  95. if moveDown and player.bottom < WINDOWHEIGHT:
  96. player.top += MOVESPEED
  97. if moveUp and player.top > 0:
  98. player.top -= MOVESPEED
  99. if moveLeft and player.left > 0:
  100. player.left -= MOVESPEED
  101. if moveRight and player.right < WINDOWWIDTH:
  102. player.right += MOVESPEED
  103.  
  104. # draw the block onto the surface
  105. screen.blit(BackgroundImage, backgrounimage)
  106. screen.blit(playerStretchedImage, player)
  107. screen.blit(GarenStretchedImage, Garen)
  108.  
  109. # check if the block has intersected with any food squares.
  110. if player.colliderect(Garen):
  111. GarenEncounter()
  112.  
  113.  
  114. # draw the window onto the screen
  115. pygame.display.update()
  116. mainClock.tick(40)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement