import pygame
from locale import *
pygame.init()
pygame.mixer.init()
screen=pygame.display.set_mode((700,500))
pygame.display.set_caption("木鱼功德")
img1=pygame.image.load("images/muyuluck1.jpg")
# img2=pygame.image.load("images/muyulucky2.png")
img2=pygame.image.load("images/zan.jpg")
img3=pygame.image.load("images/qw.png")
rect1=img1.get_rect()
muyulucky = pygame.mixer.Sound('sound/muyu.WAV')
muyulucky.set_volume(0.4)
if pygame.mouse.get_focused():
# 获取光标位置,2个值
ball_x, ball_y = pygame.mouse.get_pos()
screen.blit(img1, (-180, -100))
count=0
f = pygame.font.SysFont('华文楷体',50)
f1 = pygame.font.SysFont('华文楷体',30)
# 生成文本信息,第一个参数文本内容;第二个参数,字体是否平滑;
# 第三个参数,RGB模式的字体颜色;第四个参数,RGB模式字体背景颜色;
# text = f.render("功德+1",True,(255,0,0),(0,0,0))
# text1=f1.render("今日积累功德"+str(count)+"次",True,(255,0,0),(0,0,0))
#获得显示对象的rect区域坐标
# textRect =text.get_rect()
# text1Rect =text1.get_rect()
# 设置显示对象居中
# textRect.topleft = (30,30)
# text1Rect.topleft = (450,30)
flag = False
while True:
for event in pygame.event.get():
if pygame.Rect.collidepoint(rect1, (ball_x, ball_y)) and event.type==pygame.MOUSEBUTTONDOWN:
muyulucky.play()
flag=True
count = count + 1
text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
textRect = text.get_rect()
textRect.topleft = (30, 30)
text1 = f1.render("今日积累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
text1Rect = text1.get_rect()
text1Rect.topleft = (450, 30)
screen.blit(text1, text1Rect)
screen.blit(text,textRect)
if count==8:
f2 = pygame.font.Font("font/rough.ttf", 25)
text2 = f2.render("今日积累功德8次,去表白应该不会被拒绝太难堪哦", True, (255, 0, 20))
text2Rect = text2.get_rect()
text2Rect.topleft = (60, 150)
screen.blit(text2, text2Rect)
if count==10:
text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
textRect = text.get_rect()
textRect.topleft = (30, 30)
text1 = f1.render("今日积累功德" + str(count) + "次", True, (255, 0, 0))
text1Rect = text1.get_rect()
text1Rect.topleft = (450, 30)
screen.blit(img1, (-180, -100))
screen.blit(text1, text1Rect)
screen.blit(text, textRect)
if count==20:
f2 = pygame.font.SysFont("华文楷体", 25)
text3 = f2.render("手速这么快干嘛,这是敲木鱼积功德,不是你dfj", True, (230, 90, 80))
text3Rect = text.get_rect()
text3Rect.topleft = (60, 150)
screen.blit(text3, text3Rect)
if count==22:
text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
textRect = text.get_rect()
textRect.topleft = (30, 30)
text1 = f1.render("今日积累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
text1Rect = text1.get_rect()
text1Rect.topleft = (450, 30)
screen.blit(img1, (-180, -100))
screen.blit(text1, text1Rect)
screen.blit(text, textRect)
if count==28:
f2 = pygame.font.SysFont("华文楷体", 25)
text3 = f2.render("tmd,我看你不是敲木鱼,是泄火吧", True, (255, 200, 20))
text3Rect = text.get_rect()
text3Rect.topleft = (60, 150)
screen.blit(text3, text3Rect)
if count==30:
text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
textRect = text.get_rect()
textRect.topleft = (30, 30)
text1 = f1.render("今日积累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
text1Rect = text1.get_rect()
text1Rect.topleft = (450, 30)
screen.blit(img1, (-180, -100))
screen.blit(text1, text1Rect)
screen.blit(text, textRect)
if count==40:
screen.blit(img2, (-210,10))
if count==41:
text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
textRect = text.get_rect()
textRect.topleft = (30, 30)
text1 = f1.render("今日积累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
text1Rect = text1.get_rect()
text1Rect.topleft = (450, 30)
screen.blit(img1, (-180, -100))
screen.blit(text1, text1Rect)
screen.blit(text, textRect)
if count==50:
f2 = pygame.font.SysFont("华文楷体", 25)
text3 = f2.render("今日功德累计50次了,小熊后台奖励你一只女朋友!", True, (255, 0, 0))
text3Rect = text.get_rect()
text3Rect.topleft = (60, 150)
screen.blit(text3, text3Rect)
screen.blit(img3, (-300, 0))
if count==51:
text = f.render("功德+1", True, (255, 0, 0), (0, 0, 0))
textRect = text.get_rect()
textRect.topleft = (30, 30)
text1 = f1.render("今日积累功德" + str(count) + "次", True, (255, 0, 0), (0, 0, 0))
text1Rect = text1.get_rect()
text1Rect.topleft = (450, 30)
screen.blit(img1, (-180, -100))
screen.blit(text1, text1Rect)
screen.blit(text, textRect)
pygame.display.flip()
if pygame.Rect.collidepoint(rect1, (ball_x, ball_y)) and event.type==pygame.MOUSEBUTTONUP:
flag = False
text = f.render("功德+1", True, (0, 0, 0), (0, 0, 0))
textRect = text.get_rect()
textRect.topleft = (30, 30)
screen.blit(text, textRect)
if count==40:
screen.blit(img2, (-210, 10))
if count==50:
f2 = pygame.font.SysFont("华文楷体", 25)
text3 = f2.render("功德积累是好事,凡事有个度!", True, (255, 0, 0))
text4 = f2.render("小熊后台检测到你今日功德累计50次,看张照片放松一下吧!!", True, (255, 0, 0))
text3Rect = text.get_rect()
text4Rect = text.get_rect()
text3Rect.topleft = (60, 150)
text4Rect.topleft = (0, 180)
screen.blit(img3, (-300, 0))
screen.blit(text3, text3Rect)
screen.blit(text4, text4Rect)
pygame.display.flip()
if event.type==pygame.QUIT:
import mouse
pygame.quit()
pygame.display.flip()