Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- GAME_WIDTH = 1920
- GAME_HEIGHT = 1080
- pygame.init()
- window = pygame.display.set_mode((GAME_WIDTH,GAME_HEIGHT))
- FPS = pygame.time.Clock()
- pygame.display.set_caption("My game")
- x = 120
- y = 820
- vel_y = 20
- vel = 20
- a = False
- jump = False
- color = "Yellow"
- second_level = False
- square_width = 100
- square_place_y = 700
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- window.fill("Black")
- cyrcle = pygame.draw.circle(window,("White"),(int(x),int(y)),30)
- earth = pygame.draw.rect(window,(color),[0,850,2100,30])
- if jump is False and pygame.key.get_pressed()[pygame.K_SPACE]:
- jump = True
- if jump is True:
- y -= vel_y
- vel_y -= 1
- if vel_y < -20:
- jump = False
- vel_y = 20
- if pygame.key.get_pressed()[pygame.K_RIGHT]:
- b = True
- if b is True:
- x += 8
- if pygame.key.get_pressed()[pygame.K_LEFT]:
- x -= 8
- if x > 1920:
- second_level = True
- color = "Blue"
- x = 10
- if second_level is True:
- coin = pygame.draw.ellipse (window, ("Yellow"), [700, 400, 30, 60], 5)
- platform = pygame.draw.rect (window, ("Red"), [600, 500, 300, 100], 5)
- platform2 = pygame.draw.rect (window, ("Red"), [1200, square_place_y, square_width, 100], 5)
- # print(vel_y,cyrcle.x)
- FPS.tick(80)
- pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement