Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Although I am only 12 YEARS OlD(tomorrow i will be 13(30th SEP))
- I Made It On My Own
- Please Enjoy!!
- INSTAGRAM:- @ishaan_garud3097
- :-) :-) :-D :-D"""
- import sys
- import pygame
- import random
- from pygame.locals import *
- pygame.init()
- # Resolution is ignored on Android
- surface = pygame.display.set_mode((640, 480))
- clock = pygame.time.Clock()
- surfrect = surface.get_rect()
- rect = pygame.Rect((0, 0), (128, 128))
- rect.center = (surfrect.w / 2, surfrect.h / 2)
- #--------------RGB---------------
- r = (255,0,0)
- g = (0,255,0)
- b = (0,0,255)
- #--------------CYMO---------------
- c = (0,255,255)
- y = (255,255,0)
- m = (255,0,255)
- o = (255,150,75)
- #--------------Light--------------
- pnk = (255,150,150)
- l_g = (125,255,125)
- l_b = (100,200,255)
- colors = [r,g,b,c,y,m,o,pnk,l_g,l_b]
- touched = False
- while True:
- for ev in pygame.event.get():
- if ev.type == QUIT:
- pygame.quit()
- elif ev.type == pygame.MOUSEBUTTONDOWN:
- r_colors = random.choice(colors)
- if rect.collidepoint(ev.pos):
- touched = True
- # This is the starting point
- pygame.mouse.get_rel()
- elif ev.type == pygame.MOUSEBUTTONUP:
- touched = False
- clock.tick(60)
- surface.fill((0,0,0))
- if touched:
- rect.move_ip(pygame.mouse.get_rel())
- rect.clamp_ip(surfrect)
- surface.fill(r_colors)
- surface.fill((255, 255, 255), rect)
- pygame.display.flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement