import pygame
from pygame import *
pygame.init()
fps = 60
fpsClock = pygame.time.Clock()
icon = pygame.image.load('resource/h-2.JPG')
love = pygame.image.load('resource/爱心.png')
font01 = pygame.font.Font('resource/繁星糖果.ttf',80)
font02 = pygame.font.Font('resource/繁星糖果.ttf',50)
screen = pygame.display.set_mode((1000,600))
pygame.display.set_caption('八里公路')
pygame.display.set_icon(icon)
class LoveStar(object):
def __init__(self,x,y):
self.x = x
self.y = y
def move(self):
if self.y < -50:
self.y = 600
else:
self.y -= 1
def display(self):
screen.blit(love,(self.x,self.y))
class Goddess(object):
def __init__(self):
self.text01 = '女神'
self.text02 = '每'
self.text03 = '天'
self.text04 = '都'
self.text05 = '有'
self.text06 = '喜'
self.text07 = '欢'
self.text08 = '你'
self.text09 = '哦'
self.text010 = '做我女朋友好吗'
self.x01, self.y01 = 425, 150
self.x02, self.y02 = 150, 250
self.x03, self.y03 = 200, 300
self.x04, self.y04 = 250, 350
self.x05, self.y05 = 300, 400
self.x06, self.y06 = 800, 250
self.x07, self.y07 = 750, 300
self.x08, self.y08 = 700, 350
self.x09, self.y09 = 650, 400
self.x010, self.y010 = 325, 600
self.render01 = font01.render(self.text01, True, (128, 0, 0))
self.render02 = font02.render(self.text02, True, (128, 128, 0))
self.render03 = font02.render(self.text03, True, (128, 0, 128))
self.render04 = font02.render(self.text04, True, (0, 128, 128))
self.render05 = font02.render(self.text05, True, (0, 0, 128))
self.render06 = font02.render(self.text06, True, (128, 128, 0))
self.render07 = font02.render(self.text07, True, (128, 0, 128))
self.render08 = font02.render(self.text08, True, (0, 128, 128))
self.render09 = font02.render(self.text09, True, (0, 0, 128))
self.render010 = font02.render(self.text010, True, (128, 128, 0))
def move(self):
if self.y01 < -50:
self.y01 = 600
else:
self.y01 -= 1
if self.y02 < -50:
self.y02 = 600
else:
self.y02 -= 1
if self.y03 < -50:
self.y03 = 600
else:
self.y03 -= 1
if self.y04 < -50:
self.y04 = 600
else:
self.y04 -= 1
if self.y05 < -50:
self.y05 = 600
else:
self.y05 -= 1
if self.y06 < -50:
self.y06 = 600
else:
self.y06 -= 1
if self.y07 < -50:
self.y07 = 600
else:
self.y07 -= 1
if self.y08 < -50:
self.y08 = 600
else:
self.y08 -= 1
if self.y09 < -50:
self.y09 = 600
else:
self.y09 -= 1
if self.y010 < -50:
self.y010 = 600
else:
self.y010 -= 1
def display(self):
screen.blit(self.render01, (self.x01, self.y01))
screen.blit(self.render02, (self.x02, self.y02))
screen.blit(self.render03, (self.x03, self.y03))
screen.blit(self.render04, (self.x04, self.y04))
screen.blit(self.render05, (self.x05, self.y05))
screen.blit(self.render06, (self.x06, self.y06))
screen.blit(self.render07, (self.x07, self.y07))
screen.blit(self.render08, (self.x08, self.y08))
screen.blit(self.render09, (self.x09, self.y09))
screen.blit(self.render010, (self.x010, self.y010))
goddess = Goddess()
lovestars = []
lovestars.append(LoveStar(475,100))
lovestars.append(LoveStar(425,75))
lovestars.append(LoveStar(375,100))
lovestars.append(LoveStar(525,75))
lovestars.append(LoveStar(575,100))
lovestars.append(LoveStar(350,150))
lovestars.append(LoveStar(600,150))
lovestars.append(LoveStar(370,200))
lovestars.append(LoveStar(580,200))
lovestars.append(LoveStar(400,250))
lovestars.append(LoveStar(550,250))
lovestars.append(LoveStar(435,300))
lovestars.append(LoveStar(515,300))
lovestars.append(LoveStar(475,340))
lovestars.append(LoveStar(100,400))
lovestars.append(LoveStar(100,500))
lovestars.append(LoveStar(900,400))
lovestars.append(LoveStar(900,500))
lovestars.append(LoveStar(100,600))
lovestars.append(LoveStar(100,700))
lovestars.append(LoveStar(900,600))
lovestars.append(LoveStar(900,700))
running = True
r,g,b = 0,0,0
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
screen.fill((r,g,b))
if r >= 255:
b += 5
r = 0
if g >= 255:
r += 5
g = 0
if b >= 125:
b = 0
g += 5
for lovestar in lovestars:
lovestar.display()
lovestar.move()
goddess.display()
goddess.move()
fpsClock.tick(fps)
pygame.display.update()