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()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持聚米学院。
python 表白程序代码_python抖音表白程序源代码相关推荐
- 表白编程代码python_python抖音表白程序源代码
import sys import random import pygame from pygame.locals import * WIDTH, HEIGHT = 640, 480 BACKGROU ...
- 抖音记事本代码html,抖音表白程序制作教程 抖音表白代码制作分享-记事本文件...
抖音表白程序制作教程 抖音表白代码制作分享 抖音是一款短视频软件,上面有很多新奇而富有创意的玩法,比如最近很火的利用弹窗表白,那么抖音表白程序应该怎么制作呢?下面小编给大家带来抖音表白程序制作教程分享 ...
- 微信小程序转头条/抖音小程序的方法
很多公司都在做小程序,现在主流小程序有不少:微信小程序/头条小程序/百度小程序/支付宝小程序/QQ小程序...,很多公司为了方便开发都会采用taro或uni等开发方式,直接多端使用,但是对于小公司这些 ...
- python表白程序exe_我喜欢你 抖音表白程序python版
本文实例为大家分享了python抖音表白神器,供大家参考,具体内容如下 # -*- coding: utf-8 -*- import sys from PyQt5 import QtWidgets f ...
- 抖音txt表白html,抖音txt弹窗表白整蛊怎么弄 抖音表白撩妹套路弹窗设置教程
抖音上有很多有意思的视频,最近抖音txt弹窗表白整蛊火了,很多网友都在问怎么设置,小编为大家带来了这个玩法的教程,一起来看看吧. 抖音txt弹窗表白整蛊怎么弄 1.直接在电脑上打开一个记事本 输入一下 ...
- python机器人制作方法_Python抖音机器人制作!让你有看不完的小姐姐
抖音有多火?可以用一句话概括: 犹如蝗虫经过之处,庄稼寸地不生 . 作为一个开发者,有一个学习的氛围跟一个交流圈子特别重要这是一个我的python交流群:813542856,不管你是小白还是大牛欢迎入 ...
- python表白源代码加音乐_python抖音表白程序源代码
import sys import random import pygame from pygame.locals import * WIDTH, HEIGHT = 640, 480 BACKGROU ...
- python抖音表白程序_python抖音表白程序源代码
进口sysimport randomimport pygamefrom进口*宽度.高度= 640,480背景=(0,191,255)#按钮def按钮(文本,x, y, w, h,颜色,屏幕):(屏幕, ...
- 简单编程代码表白_用简单代码实现抖音表白神器
话不多说,直接进入教学 代码部分: from tkinter import * from tkinter import messagebox import randomdef no_close():r ...
最新文章
- sylog mysql_syslog-ng+loganalyzer搭建日志集中监控平台
- 资深程序员不一定当得了软件架构师
- 在Mac上安装Hadoop
- Java-Runoob:Java Stream、File、IO
- Transact_SQL小手册
- windows下gvim中文乱码解决方案
- GPL侵权诉讼被驳回,Linux之父Torvalds又要发飙了!
- High performance find query using lean() in mongoose
- open-falcon采集的一些指标及说明
- 楼下邻居是事逼怎么办
- win10输入法变成繁体字怎么办 - 如何关闭繁体,简体切换功能
- 山东春考计算机组装与维修,山东春考计算机组装与维修模拟试题(11页)-原创力文档...
- 夙愿:对数函数与指数函数的交点问题
- JavaEE之--登录页面(用户名、密码、验证码)
- python第二阶段(2)入门-数据科学包 pandas
- 大学Java基础课程设计——网络聊天室
- 数钱数到手抽筋html5,数钱数到手抽筋的经典句子
- Axure可视化动态数据图表6合1元件库
- (产品贴)移动护理平台
- android 行车模式,Android手机充当行车记录器(DailyRoads)
热门文章
- Inject Dll 过程
- qwtplot读取tid数据并绘图
- ISOLINUX: A bootloader for Linux using ISO 9660/El Torito CD-ROMs
- Linux网络协议栈:网卡收包分析
- linux环境C语言操作数据库
- 代码里经常看见idle,是什么意思
- Java 生态圈知识汇总
- 大数据城市规划 杨东_AI为智慧城市规划做建设
- 超级硬盘数据恢复软件v2.7.2.6_电脑磁盘上的视频误删如何恢复?误删视频恢复教程...
- 函数 单片机glint_PIC单片机CCS之C语言(#BIT的用法)