520,并非情人所属, 我们可以表白万物,

不管什么时候, 这都是一个特别的日子,

今天,我要表白所有, 心里有我的人!

在这个充满幸福的日子里, 我要把最美好的祝福,

送给心里有我的每一个人;

祝愿大家:

一生平安,身体健康,

生活幸福,家庭美满!
(之前单身的我感谢万物)

不知不觉又是520了,先的一年有多少人表白成功,又有多少人表白失败,

有多少步入婚姻的殿堂,又有谁单身至今,不管如何,

今天在这里希望不想单身的人们找到属于自己的幸福~

那么接下来就让我们来看看怎么代码表白吧~

“无套路表白”

效果展示

设置了只能选A选项,点不了B选项,哈哈哈哈(当然点击上面的叉叉还是会关掉)

import pygame
import random
import sys # 根据背景图大小,设置游戏屏幕大小
WIDTH, HEIGHT = 1024, 576
# 不全屏
screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
# 全屏
# screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN, 32)
pygame.display.set_caption('小姐姐,你的快递到了。') # 添加文本信息
def title(text, screen, scale, color=(0, 0, 0)):
font = pygame.font.SysFont('SimHei', 27)
textRender = font.render(text, True, color)
# 初始化文本的坐标
screen.blit(textRender, (WIDTH / scale[0], HEIGHT / scale[1])) # 按钮
def button(text, x, y, w, h, color, screen):
pygame.draw.rect(screen, color, (x, y, w, h))
font = pygame.font.SysFont('SimHei', 20)
textRender = font.render(text, True, (255, 255, 255))
textRect = textRender.get_rect()
textRect.center = ((x+w/2), (y+h/2))
screen.blit(textRender, textRect) # 生成随机的位置坐标
def get_random_pos():
x, y = random.randint(10, 600), random.randint(20, 500)
return x, y # 点击答应按钮后显示的页面
def show_like_interface(screen):
screen.fill((255, 255, 255))
background1 = pygame.image.load('2.png').convert()
screen.blit(background1, (0, 0))
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit() def main():
pygame.init()
clock = pygame.time.Clock()
# 添加背景音乐
pygame.mixer.music.load('手写的从前-周杰伦.mp3')
pygame.mixer.music.play(-1, 20)
pygame.mixer.music.set_volume(0.5)
# 设置不同意按钮属性
unlike_pos_x = 130
unlike_pos_y = 375
unlike_pos_width = 450
unlike_pos_height = 55
unlike_color = (115, 76, 243)
# 设置同意按钮属性
like_pos_x = 130
like_pos_y = 280
like_pos_width = 450
like_pos_height = 55
like_color = (115, 76, 243) running = True
while running:
# 填充窗口
screen.fill((255, 255, 255))
# 添加背景图
background = pygame.image.load('1.png').convert()
screen.blit(background, (0, 0)) # 获取鼠标坐标
pos = pygame.mouse.get_pos()
# 判断鼠标位置,不同意时,按钮不断变化
if pos[0] < unlike_pos_x + unlike_pos_width + 5 and pos[0] > unlike_pos_x - 5 and pos[1] < unlike_pos_y + unlike_pos_height + 5 and pos[1] > unlike_pos_y - 5:
while True:
unlike_pos_x, unlike_pos_y = get_random_pos()
if pos[0] < unlike_pos_x + unlike_pos_width + 5 and pos[0] > unlike_pos_x - 5 and pos[1] < unlike_pos_y + unlike_pos_height + 5 and pos[1] > unlike_pos_y - 5:
continue
break # 设置标题及按钮文本信息
title('1.如果有一天我向你表白,你会怎么样?', screen, scale=[8, 3])
button('A.你小子终于开窍了,你敢表白我就敢答应!', like_pos_x, like_pos_y, like_pos_width, like_pos_height, like_color, screen)
button('B.我拿你当闺蜜,你居然想睡我!果断拒绝!', unlike_pos_x, unlike_pos_y, unlike_pos_width, unlike_pos_height, unlike_color, screen)
# 设置关闭选项属性
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# 当鼠标点击同意按钮后,跳转结束页面
if pos[0] < like_pos_x + like_pos_width + 5 and pos[0] > like_pos_x - 5 and pos[1] < like_pos_y + like_pos_height + 5 and pos[1] > like_pos_y - 5:
if event.type == pygame.MOUSEBUTTONDOWN:
show_like_interface(screen) pygame.display.flip()
pygame.display.update()
clock.tick(60) main()

无套路进阶版

这个就厉害了,在没有点击好呀之前你点击叉叉也是关不掉她的


'''配置文件'''
import os # 窗口大小(width, height)
SCREENSIZE = (500, 260)
# 定义一些颜色
RED = (255, 0, 0)
BLACK = (0, 0, 0)
AZURE = (240, 255, 255)
WHITE = (255, 255, 255)
MISTYROSE = (255, 228, 225)
PALETURQUOISE = (175, 238, 238)
PAPAYAWHIP = (255, 239, 213)
LIGHTGRAY = (211, 211, 211)
GAINSBORO = (230, 230, 230)
WHITESMOKE = (245, 245, 245)
DARKGRAY = (169, 169, 169)
BLUE = (0, 0, 255)
DEEPSKYBLUE = (0, 191, 255)
SKYBLUE = (135, 206, 235)
LIGHTSKYBLUE = (135, 206, 250)
# 背景音乐路径
BGM_PATH = os.path.join(os.getcwd(), 'resources/music/bgm.mp3')
# 字体路径
FONT_PATH = os.path.join(os.getcwd(), 'resources/font/STXINGKA.TTF')
# 背景图片路径
BG_IMAGE_PATH = os.path.join(os.getcwd(), 'resources/images/bg.png')
# ICON路径
ICON_IMAGE_PATH = os.path.join(os.getcwd(), 'resources/images/icon.png')
import sys
import cfg
import random
import pygame
from tkinter import Tk, messagebox '''
Function:
按钮类
Initial Args:
--x, y: 按钮左上角坐标
--width, height: 按钮宽高
--text: 按钮显示的文字
--fontpath: 字体路径
--fontsize: 字体大小
--fontcolor: 字体颜色
--bgcolors: 按钮背景颜色
--is_want_to_be_selected: 按钮是否想被玩家选中
--screensize: 软件屏幕大小
'''
class Button(pygame.sprite.Sprite):
def __init__(self, x, y, width, height, text, fontpath, fontsize, fontcolor, bgcolors, edgecolor, edgesize=1, is_want_to_be_selected=True, screensize=None, **kwargs):
pygame.sprite.Sprite.__init__(self)
self.rect = pygame.Rect(x, y, width, height)
self.text = text
self.font = pygame.font.Font(fontpath, fontsize)
self.fontcolor = fontcolor
self.bgcolors = bgcolors
self.edgecolor = edgecolor
self.edgesize = edgesize
self.is_want_tobe_selected = is_want_to_be_selected
self.screensize = screensize
'''自动根据各种情况将按钮绑定到屏幕'''
def draw(self, screen, mouse_pos):
# 鼠标在按钮范围内
if self.rect.collidepoint(mouse_pos):
# --不想被选中
if not self.is_want_tobe_selected:
while self.rect.collidepoint(mouse_pos):
self.rect.left, self.rect.top = random.randint(0, self.screensize[0]-self.rect.width), random.randint(0, self.screensize[1]-self.rect.height)
pygame.draw.rect(screen, self.bgcolors[0], self.rect, 0)
pygame.draw.rect(screen, self.edgecolor, self.rect, self.edgesize)
# 鼠标不在按钮范围内
else:
pygame.draw.rect(screen, self.bgcolors[1], self.rect, 0)
pygame.draw.rect(screen, self.edgecolor, self.rect, self.edgesize)
text_render = self.font.render(self.text, True, self.fontcolor)
fontsize = self.font.size(self.text)
screen.blit(text_render, (self.rect.x+(self.rect.width-fontsize[0])/2, self.rect.y+(self.rect.height-fontsize[1])/2)) '''在指定位置显示文字'''
def showText(screen, text, position, fontpath, fontsize, fontcolor, is_bold=False):
font = pygame.font.Font(fontpath, fontsize)
font.set_bold(is_bold)
text_render = font.render(text, True, fontcolor)
screen.blit(text_render, position) '''主函数'''
def main():
# 初始化
pygame.init()
screen = pygame.display.set_mode(cfg.SCREENSIZE, 0, 32)
pygame.display.set_icon(pygame.image.load(cfg.ICON_IMAGE_PATH))
pygame.display.set_caption('来自一位喜欢你的小哥哥')
# 背景音乐
pygame.mixer.music.load(cfg.BGM_PATH)
pygame.mixer.music.play(-1, 30.0)
# biu爱心那个背景图片
bg_image = pygame.image.load(cfg.BG_IMAGE_PATH)
bg_image = pygame.transform.smoothscale(bg_image, (150, 150))
# 实例化两个按钮
button_yes = Button(x=20, y=cfg.SCREENSIZE[1]-70, width=120, height=35,
text='好呀', fontpath=cfg.FONT_PATH, fontsize=15, fontcolor=cfg.BLACK, edgecolor=cfg.SKYBLUE,
edgesize=2, bgcolors=[cfg.DARKGRAY, cfg.GAINSBORO], is_want_to_be_selected=True, screensize=cfg.SCREENSIZE)
button_no = Button(x=cfg.SCREENSIZE[0]-140, y=cfg.SCREENSIZE[1]-70, width=120, height=35,
text='算了吧', fontpath=cfg.FONT_PATH, fontsize=15, fontcolor=cfg.BLACK, edgecolor=cfg.DARKGRAY,
edgesize=1, bgcolors=[cfg.DARKGRAY, cfg.GAINSBORO], is_want_to_be_selected=False, screensize=cfg.SCREENSIZE)
# 是否点击了好呀按钮
is_agree = False
# 主循环
clock = pygame.time.Clock()
while True:
# --背景图片
screen.fill(cfg.WHITE)
screen.blit(bg_image, (cfg.SCREENSIZE[0]-bg_image.get_height(), 0))
# --鼠标事件捕获
for event in pygame.event.get():
if event.type == pygame.QUIT:
# ----没有点击好呀按钮之前不许退出程序
if is_agree:
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN and event.button:
if button_yes.rect.collidepoint(pygame.mouse.get_pos()):
button_yes.is_selected = True
root = Tk()
root.withdraw()
messagebox.showinfo('', '么么哒')
root.destroy()
is_agree = True
# --显示文字
showText(screen=screen, text='小姐姐, 我观察你很久了', position=(40, 50),
fontpath=cfg.FONT_PATH, fontsize=25, fontcolor=cfg.BLACK, is_bold=False)
showText(screen=screen, text='做我女朋友好不好?', position=(40, 100),
fontpath=cfg.FONT_PATH, fontsize=25, fontcolor=cfg.BLACK, is_bold=True)
# --显示按钮
button_yes.draw(screen, pygame.mouse.get_pos())
button_no.draw(screen, pygame.mouse.get_pos())
# --刷新
pygame.display.update()
clock.tick(60) '''run'''
if __name__ == '__main__':
main()

所需素材

图片

字体

音乐

简陋版【击中心脏】 点击此处领取免费资料

效果展示

虽然它简陋,但是你的心意啊,配上一个表情包,再加上一条动人的情话,那效果,也是拉满的呀~
示范:

每一个人的缘分不同,相爱的时间也会有长短,只有尽心尽力的去做,我能够做到的就是:我会让我的爱陪你慢慢的老去。

哈哈哈哈哈哈哈哈哈哈哈

源代码

import turtle as t

def init():
t.speed(2)
t.pensize(2)
t.screensize(480, 360)
t.color('red', 'red') def draw_heart_right():
t.up()
t.goto(50, 50)
t.pendown()
t.right(45)
t.goto(100, 0)
t.seth(45)
t.fd(120)
t.circle(50, 225) def draw_heart_left():
t.up()
t.goto(0, 0)
t.down()
t.seth(45)
t.fd(120)
t.circle(50, 225)
t.seth(90)
t.circle(50, 225)
t.fd(120) def draw_arrow():
t.up()
t.seth(0)
# 羽毛
t.goto(-210, 40)
t.pendown()
t.goto(-215, 44)
t.goto(-190, 49)
t.goto(-175, 46)
t.up() t.goto(-210, 40)
t.pendown()
t.goto(-213, 34)
t.goto(-185, 39)
t.goto(-175, 46)
t.up() # 箭杆
t.pendown()
t.goto(0, 80)
t.penup()
t.goto(160, 110)
t.pendown()
t.goto(320, 140) # 箭羽
t.left(160)
t.begin_fill()
t.fd(10)
t.left(120)
t.fd(10)
t.left(120)
t.fd(10)
t.end_fill() if __name__ == '__main__':
init()
draw_heart_right()
draw_heart_left()
draw_arrow()
t.hideturtle()
t.done()

表白语录&求婚语录

在最后,赠送大家一些肯定能用上的语录吧~

单身表白语句

愿你余下岁月,无灾无难,无我不欢。

我这个人从不知道自己想要什么,但是对于喜欢你这件事,毋庸置疑。

猫咪在落叶里打了滚,晚霞铺满天空,风把思念吹向你,我所贪念的人间,不过是你而已!

奇遇使我遇上你。缘份使我爱上你。心里有话告诉你。但是又怕伤害你。想想还是告诉你。此时此刻想起你。但愿马上见到你。我是真心爱着你。

我不是一个不善言谈的人,但是我会用我的实际行动让你感觉到,我是真的很爱你的,所以希望你给我一个照顾你一辈子的机会,然后一起慢慢变老,好吗?

一见钟情爱上你,二话不说想追你,三番四次来找你,五朵玫瑰送给你,六神无主想泡你,七次八次来烦你,九颗真心打动你,十分满意就是你。

此短信法力无边,收到后神效立显,单身者即刻遇艳,单恋者真爱如愿,恋爱者爱情蜜甜,已婚者齐眉举案,离婚者梅开再恋,转发者快乐天天!

你就像是开着一架喷气式的小飞机,扑哧扑哧地就飞进了我的心。

求婚语句

月色好、月色美、月色让我心不悔,爱上你、恋上你、都是因你把爱给,爱朦胧、月朦胧、朦胧里面有晶莹,不要怨我爱上你,都是月亮惹的祸。亲爱的让我们用爱情的婚礼来弥补月亮的过失吧!

此刻的我很激动,却不知道如何表达,那些原本背得滚瓜烂熟的求婚词早于被抛向脑后。亲爱的,原谅我不善于说太多的甜言蜜语,但请你相信我有一颗真挚爱你的心。愿此生永远守护你,爱护你,一生一世,永不分离。或许这些言语说来总是太空泛,那就让我用一辈子来实现它吧!

从遇见你开始,我的心便只属于你。世界上每个人终会遇见那个对的人,我很开心,因为我找到了我的唯一——最特别的你。我相信你一定是上天给我派来的天使,让我的生活突然充满了阳光照耀的温暖。谢谢你,为我做了那么多那么多。接下来的日子,让我嫁给你吧!

我愿意守护你一辈子。两个人能相遇,是一种缘分。若能相遇、相知、相惜,更是一种向往。在求婚的时候,男生可以表达愿意与之共度一生的心。承诺一辈子不离不弃!这样的表白是需要下很大的决心,要三思而后行,为自己说下的话负责任。

请您能给我一个荣幸,让我可以陪你度过一生!一年四季,四季如初。陪你走过鸟语花香的春天、度过火热的夏天、走过高爽的秋天、在寒冷的冬天相依偎。

自从遇见了你,我的心便只属于你。感谢上苍让我们在茫茫人海中相遇。让我遇见一个特别的你,你的到来温暖了我的世界,仿佛那冬日的温暖阳光照耀着我。你愿戴上这颗刻有你专属名字的钻戒吗?陪我共度此生,一生一世不分离!

怎么样 是不是非常全面呢?
还有什么问题都可以在文末添加群找管理员小姐姐解答喔~

我是小熊猫,咱下篇文章见啦~

最新文章

  1. WinDbg 命令三部曲:(一)WinDbg 命令手册
  2. javascript强制转换详解
  3. MongoDB相关资料收集
  4. 7.python字符串-内置方法分析
  5. (转)MapReduce二次排序
  6. Spring boot 1.3.5 RELEASE 官方文档中文翻译--Part2:新手入门
  7. Codeforces Round #306 (Div. 2)
  8. Spring ProxyFactory
  9. 在线maven仓库
  10. Java解析OFFICE(word,excel,powerpoint)以及PDF的实现方案及开发中的点滴分享
  11. 我的hibernate学习记录(二)
  12. ASUS T100TA 换屏要记
  13. ROS机器人程序设计(原书第2版)补充资料 (伍) 第五章 计算机视觉
  14. 洛谷P3627[APOI2009] (讨厌的)抢掠计划
  15. IdentityServer4 中文文档 -16- (快速入门)使用 EntityFramework Core 存储配置数据
  16. 2018 ICPC青岛网络赛 B. Red Black Tree(倍增lca好题)
  17. 使用node去爬虫
  18. 集合类(常见的集合类:Collection、List、Set、ArrayList、linkedList、Vector、HashSet、TreeSet)
  19. Codeforces Round #427 (Div. 2) Problem A Key races (Codeforces 835 A)
  20. 算法之DP

热门文章

  1. style设置 三个 竖线隔得太近了,这个属性和值 设置让他们分开一点
  2. Blazor 组件库 BootstrapBlazor中 Ajax 组件的使用
  3. 多线程JUC并发篇常见面试详解
  4. 配置Docker镜像源为国内镜像源
  5. for &amp; while &amp;迭代器
  6. [STL] map 映射
  7. 1.11 Linux的主要应用领域有哪些?
  8. iptables系列教程(二)| iptables语法规则
  9. SmartDialog迁移至4.0:一份真诚的迁移说明
  10. numpy学习Ⅱ