Skip to content

Instantly share code, notes, and snippets.

Created March 22, 2014 11:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wkta/9705514 to your computer and use it in GitHub Desktop.
#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
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!')
while interp_value<=1.0: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
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 ),
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