Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, sys, time, random
- from pygame.locals import *
- WINDOWWIDTH = 600
- WINDOWHEIGHT = 500
- WHITE = (255, 255, 255)
- StateWorldMap = 0
- StateBattleGaren = 1
- GameState = 0
- GarenAlive = True
- def GarenEncounter():
- if GarenAlive:
- pygame.display.update()
- textbox = pygame.Rect(0, 300, 1, 1)
- textboxload = pygame.image.load('snak.png')
- textboxStretchedImage = pygame.transform.scale(textboxload, (600, 200))
- GarenProfile = pygame.image.load('BigGaren.jpg')
- GarenStretched = pygame.transform.scale(GarenProfile, (40, 60))
- screen.blit(textboxStretchedImage, textbox)
- # set up pygame
- pygame.init()
- mainClock = pygame.time.Clock()
- score = 0
- font = pygame.font.SysFont(None, 48)
- smallfont = pygame.font.SysFont(None, 24)
- # set up the window
- screen = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
- pygame.display.set_caption('RPG Game')
- backgrounimage = pygame.Rect(0, 0, 10, 60)
- background_image = pygame.image.load("background.png")
- BackgroundImage = pygame.transform.scale(background_image, (600, 500))
- # set up the block data structure
- player = pygame.Rect(20, 20,40, 60)
- playerImage = pygame.image.load('Ashe.png')
- playerStretchedImage = pygame.transform.scale(playerImage, (50, 50))
- Garen= pygame.Rect(80, 220, 25, 20)
- GarenImage = pygame.image.load('Garen.png')
- GarenStretchedImage = pygame.transform.scale(GarenImage, (50, 50))
- # set up keyboard variables
- moveLeft = False
- moveRight = False
- moveUp = False
- moveDown = False
- MOVESPEED = 2
- # run the game loop
- while True:
- if GameState == StateWorldMap:
- # check for the QUIT event
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- if event.type == KEYDOWN:
- # change the keyboard variables
- if event.key == K_LEFT or event.key == ord('a'):
- moveRight = False
- moveLeft = True
- if event.key == K_RIGHT or event.key == ord('d'):
- moveLeft = False
- moveRight = True
- if event.key == K_UP or event.key == ord('w'):
- moveDown = False
- moveUp = True
- if event.key == K_DOWN or event.key == ord('s'):
- moveUp = False
- moveDown = True
- if event.type == KEYUP:
- if event.key == K_ESCAPE:
- pygame.quit()
- sys.exit()
- if event.key == K_LEFT or event.key == ord('a'):
- moveLeft = False
- if event.key == K_RIGHT or event.key == ord('d'):
- moveRight = False
- if event.key == K_UP or event.key == ord('w'):
- moveUp = False
- if event.key == K_DOWN or event.key == ord('s'):
- moveDown = False
- # draw the background onto the surface
- screen.fill(WHITE)
- # move the player
- if moveDown and player.bottom < WINDOWHEIGHT:
- player.top += MOVESPEED
- if moveUp and player.top > 0:
- player.top -= MOVESPEED
- if moveLeft and player.left > 0:
- player.left -= MOVESPEED
- if moveRight and player.right < WINDOWWIDTH:
- player.right += MOVESPEED
- # draw the block onto the surface
- screen.blit(BackgroundImage, backgrounimage)
- screen.blit(playerStretchedImage, player)
- screen.blit(GarenStretchedImage, Garen)
- # check if the block has intersected with any food squares.
- if player.colliderect(Garen):
- GarenEncounter()
- # draw the window onto the screen
- pygame.display.update()
- mainClock.tick(40)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement