A variation on the Stars and Stripes American Flag for Independence Day. It’s an exercise in the use of transparency in Pygame. The stripes are made transparent so the stars image behind shows through.

'''     Stars and Stripes
    Just a little July 4th exercise...
    Authour: Alan Richmond, Python3.Codes
import pygame as p

w,h = 1000,624                      # Flag size
y = h/13                            # width of a stripe

d = p.display.set_mode((w,h))

img = p.image.load("stars.jpg").convert()

s = p.Surface((w,y))

rd = p.Color(255,0,0)
wt = p.Color(255,255,255)
c = rd

for i in range(13):

    d.blit(s, (0,y*i))
    if c==rd:   c=wt
    else:       c=rd


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.