Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- # Draw commands don't use alpha the same way as surfaces.
- def main(caption, size, flags=0):
- pygame.display.set_caption(caption)
- display = pygame.display.set_mode(size, flags)
- drect = display.get_rect()
- clock = pygame.time.Clock()
- running = True
- delta = 0
- fps = 60
- color = pygame.Color('green')
- color.a = 80
- rcolor = pygame.Color('red')
- rcolor.a = 150
- red_box = pygame.Surface((40, 40), pygame.SRCALPHA)
- red_box.fill(rcolor)
- green_box = pygame.Surface((700, 100), pygame.SRCALPHA)
- green_box.fill(color)
- pygame.draw.rect(green_box, rcolor, (10, 10, 40, 40))
- green_box.blit(red_box, (120, 10))
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- display.fill('black')
- pygame.draw.line(display, 'dodgerblue', (drect.centerx, 5), (drect.centerx, 400), 3)
- display.blit(green_box, (50, 150))
- pygame.draw.rect(display, color, (50, 20, 700, 100))
- pygame.display.flip()
- delta = clock.tick(fps)
- pygame.init()
- main('Testing', (800, 600))
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement