Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#MonthOfCode day 15 - yellow
import pygame
from pygame.locals import *
import sys
from time import sleep
# init. pygame libr; create the screen and diplays a help message in the console
pygame.init()
DISPLAYSURF = pygame.display.set_mode((640, 480))
src_color = pygame.Color('antiquewhite3')
targ_color = pygame.Color('yellow')
#draw it to the screen
pygame.display.set_caption('from white to yellow!')
interp_value=0.0
while interp_value<=1.0: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
src_triplet =( src_color.r, src_color.g, src_color.b )
targ_triplet =( targ_color.r, targ_color.g, targ_color.b )
interp_value +=0.01
interp_triplet = map(
lambda a,b: int( (1.0-interp_value) * a + interp_value* b ),
src_triplet,
targ_triplet )
current_color = pygame.Color( *interp_triplet)
sleep(0.1 )
DISPLAYSURF.fill( current_color )
pygame.display.update() #Q: whats the difference between update n flip?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment