repl.it
@HappyFakeboulde/

dvd colour swap (copied)

Pygame

copied from @Russell23

fork
loading
Files
  • main.py
  • d
  • dvd blue white.png
  • DVD blue.png
  • dvd greenpng.png
  • DVD white.png
  • DVD_blue black 2.png
  • DVD_blue black.jpg
  • DVD_blue black.png
  • DVD_rainbow.png
  • DVD_white_png.png
  • DVD_yellow.png
  • nohup.out
  • time
  • uhiu
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pygame
import sys
import time

pygame.init()
  
speed = [1, 1]
size = width, height= 800, 600
screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()
logo = pygame.image.load("DVD blue.png")
rect = logo.get_rect()

fps = 60
while True:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      sys.exit()
  
  if rect.left < 0:
    speed[0] = -speed[0]
    logo = pygame.image.load("DVD_rainbow.png")
  
  if rect.right > width:
    speed[0] = -speed[0]
    logo = pygame.image.load("DVD_yellow.png")
  
  if rect.top < 0:
    speed[1] = -speed[1]
    logo = pygame.image.load("DVD white.png")
  
  if rect.bottom > height:
    speed[1] = -speed[1]
    logo = pygame.image.load("DVD_white_png.png")
  
  rect.left += speed[0]  
  rect.top += speed[1]
  screen.fill((0, 0, 0))
  screen.blit(logo, rect)
  pygame.display.update()
  clock.tick(fps)
  pygame.time.wait(10)