Stars and Stripes

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


[welcomewikilite wikiurl=”” sections=”Short description” settings=””]

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

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