python抖音表白程序源代码
作者:black_hole6 发布时间:2021-01-29 17:12:38
标签:python,抖音,表白
本文实例为大家分享了python抖音表白程序的具体代码,供大家参考,具体内容如下
import sys
import random
import pygame
from pygame.locals import *
WIDTH, HEIGHT = 640, 480
BACKGROUND = (0, 191, 255)
# 按钮
def button(text, x, y, w, h, color, screen):
pygame.draw.rect(screen, color, (x, y, w, h))
font = pygame.font.Font('./font/simkai.ttf', 20)
textRender = font.render(text, True, (0, 0, 0))
textRect = textRender.get_rect()
textRect.center = ((x+w/2), (y+h/2))
screen.blit(textRender, textRect)
# 标题
def title(text, screen, scale, color=(255, 0, 0)):
font = pygame.font.Font('./font/simkai.ttf', WIDTH//(len(text)*2))
textRender = font.render(text, True, color)
textRect = textRender.get_rect()
textRect.midtop = (WIDTH/scale[0], HEIGHT/scale[1])
screen.blit(textRender, textRect)
# 生成随机的位置坐标
def get_random_pos():
x, y = random.randint(20, 620), random.randint(20, 460)
return x, y
# 点击喜欢按钮后显示的页面
def show_like_interface(text, screen, color=(255, 0, 0)):
screen.fill(BACKGROUND)
font = pygame.font.Font('./font/simkai.ttf', WIDTH//(len(text)))
textRender = font.render(text, True, color)
textRect = textRender.get_rect()
textRect.midtop = (WIDTH/2, HEIGHT/2)
screen.blit(textRender, textRect)
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
# 主函数
def main():
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
pygame.display.set_caption('FROM一个喜欢你很久的小哥哥')
clock = pygame.time.Clock()
pygame.mixer.music.load('./bg_music/1.mp3')
pygame.mixer.music.play(-1, 30.0)
pygame.mixer.music.set_volume(0.25)
unlike_pos_x = 330
unlike_pos_y = 300
unlike_pos_width = 100
unlike_pos_height = 50
like_pos_x = 180
like_pos_y = 300
like_pos_width = 100
like_pos_height = 50
running = True
like_color = (255, 0, 255)
while running:
screen.fill(BACKGROUND)
img = pygame.image.load("./imgs/1.png")
imgRect = img.get_rect()
imgRect.midtop = WIDTH//2, HEIGHT//4
screen.blit(img, imgRect)
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
mouse_pos = pygame.mouse.get_pos()
if mouse_pos[0] < like_pos_x+like_pos_width+5 and mouse_pos[0] > like_pos_x-5 and\
mouse_pos[1] < like_pos_y+like_pos_height+5 and mouse_pos[1] > like_pos_y-5:
like_color = BACKGROUND
running = False
mouse_pos = pygame.mouse.get_pos()
if mouse_pos[0] < unlike_pos_x+unlike_pos_width+5 and mouse_pos[0] > unlike_pos_x-5 and\
mouse_pos[1] < unlike_pos_y+unlike_pos_height+5 and mouse_pos[1] > unlike_pos_y-5:
while True:
unlike_pos_x, unlike_pos_y = get_random_pos()
if mouse_pos[0] < unlike_pos_x+unlike_pos_width+5 and mouse_pos[0] > unlike_pos_x-5 and\
mouse_pos[1] < unlike_pos_y+unlike_pos_height+5 and mouse_pos[1] > unlike_pos_y-5:
continue
break
title('小姐姐,我观察你很久了', screen, scale=[2, 10])
title('做我女朋友好不好呀', screen, scale=[2, 6])
button('好呀', like_pos_x, like_pos_y, like_pos_width, like_pos_height, like_color, screen)
button('算了吧', unlike_pos_x, unlike_pos_y, unlike_pos_width, unlike_pos_height, (255, 0, 255), screen)
pygame.display.flip()
pygame.display.update()
clock.tick(60)
show_like_interface('我就知道小姐姐你也喜欢我~', screen, color=(255, 0, 0))
if __name__ == '__main__':
main()
来源:https://blog.csdn.net/lbperfect123/article/details/82928123


猜你喜欢
- tf.keras.layers模块中的函数from __future__ import print_function as _print_f
- 介绍:仅供技术交流学习探讨,请勿用于非法用途,。本文部分资源来源于网络,如有侵权请联系版主删除。一、简介Burp Intruder是一个强大
- JavaScript 读取、删除 Cookie 的函数* * WebFXCookie class */ fun
- 本文实例为大家分享了Golang实现文件传输的具体代码,供大家参考,具体内容如下借助TCP完成文件的传输,基本思路如下:1、发送方(客户端)
- 一般学习java和部署项目都是在本地部署,但是生产环境一般都是在linux环境下,部署和安装环境都是在控制台下进行操作的,没有windows
- 需求描述制作一个H5页面,打开之后可以录音,并将录音文件提交至后台微信录音最长时长为1min微信官方文档--音频接口代码如下 /
- 阅读上一篇:什么是名字空间<meta http-equiv="Content-Type" co
- 在最开始的时候所有的斐波那契代码都是使用递归的方式来写的,递归有很多的缺点,执行效率低下,浪费资源,还有可能会造成栈溢出,而递归的程序的优点
- 举例为大家介绍如何运用命令行实现MySQL导出导入数据库一、命令行导出数据库1.进入MySQL目录下的bin文件夹:cd MySQL中到bi
- 保存文件名太长OSError: [Errno 36] File name too lon问题描述安装pip install python-d
- 例子:1:www.jb51.net2:www.jb51.net3:www.jb51.net4:www.jb51.net5:www.jb51.
- 序言这次玩次狠得。除了编译器使用yum安装,其他全部手动编译。哼~看似就Nginx、PHP、MySql三个东东,但是它们太尼玛依赖别人了。没
- 目录 一,抓取情况描述二,网页分析三,程序编写 一,抓取情况描述1.抓取的页面需要登陆,以公司网页为例,登陆网址http
- 本文实例为大家分享了js实现计算器功能的具体代码,供大家参考,具体内容如下在老师的带领下完成了这个简单的计算器,这是一个神奇的过程,计算器的
- 本文主要介绍的是Python高阶函数与装饰器函数的相关内容,分享给大家,下面话不多说了,来一起看看详细的介绍吧高阶函数1、可以使用函数对象作
- 我用的是Anaconda3 ,用spyder编写pytorch的代码,在Anaconda3中新建了一个pytorch的虚拟环境(虚拟环境的名
- 布局管理就是管理图形窗口中各个部件的位置和排列。图形窗口中的大量部件也需要通过布局管理,对部件进行整理分组、排列定位,才能使界面整齐有序、美
- Checkbutton(多选按钮)组件用于实现确定是否选择的按钮。Checkbutton 组件可以包含文本或图像,你可以将一个 Python
- 时间紧任务重,女神提出的要求有模棱两可,只能自己考虑各种情况,除了用python还有谁能这么短的时间搞出来。程序界面,增删改查不能少,后悔药
- 问题有一个元素序列,想知道在序列中出现次数最多的元素是什么解决方案collections 模块中的 Counter 类转让给女士为此问题所设