python编写告白程序(python抖音表白程序源代码)
类别:脚本大全 浏览量:752
时间:2021-10-20 08:07:04 python编写告白程序
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
您可能感兴趣
- python中的insert(python assert的用处示例详解)
- python算法图解(python实现kmp算法的实例代码)
- python微信红包代码(php生成微信红包数组的方法)
- python图片识别文字代码(python批量识别图片指定区域文字内容)
- python菜单栏教程(Python3.5实现的三级菜单功能示例)
- python数字形式转换详解(Python3.5实现的罗马数字转换成整数功能示例)
- python抽奖转盘代码(详解python--模拟轮盘抽奖游戏)
- python利用空列表进行数字排序(python实现计数排序与桶排序实例代码)
- 用python图片转字符串(python实现图片转字符小工具)
- python中的类和对象的定义和使用(Python类的继承、多态及获取对象信息操作详解)
- python模块化打包(python使用Paramiko模块实现远程文件拷贝)
- python加密和解密(python实现对输入的密文加密)
- python实现螺旋矩阵(Python3实现的旋转矩阵图像算法示例)
- python如何读取文件(Python从文件中读取数据的方法讲解)
- python中if判断数据类型(基于python if 判断选择结构的实例详解)
- python中的1和0(python把1变成01的步骤总结)
- 红色代表什么(红色代表什么意义和象征)
- 菲律宾安全吗(菲律宾安全吗2023)
- 彩礼重要吗()
- 写信告诉我今天海是什么颜色(写信告诉我今天海是什么颜色回答)
- 英语难学吗(法语比英语难学吗)
- 今天要吃什么(今天要吃什么菜好)
热门推荐
- python获取网络数据tcp(Python选择网卡发包及接收数据包)
- nginxhttp转https原理(nginx如何将http访问的网站改成https访问)
- docker进入mysql查看路径(Docker 环境运行 Mysql 和开启 Binlog 配置主从同步的设置方法)
- 静态web服务器nginx(WEB服务器该选择 Apache 还是 Nginx?)
- zabbix如何监控访问状态码(基于zabbix实现监控Jenkins过程详解)
- Serif和Sans-serif的区别
- dedecms替代方案(DedeCMS投票模块漏洞解决方法)
- phpstudy中apache到期如何修改(phpStudy找不到Apache“服务名” 解决方法)
- mysql日志功能介绍(mysql日志系统的简单使用教程)
- javascript写计算器教程(基于JavaScript实现简易计算器)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9