最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python仿抖音表白神器

 更新時間:2019年04月08日 08:37:03   作者:weixin_33704234  
這篇文章主要教大家制作python抖音表白神器,仿制抖音表白小軟件,具有一定的參考價值,感興趣的小伙伴們可以參考一下

Python能夠干嘛?

可以做日常任務(wù),比如自動備份你的MP3;
可以做網(wǎng)站,很多著名的網(wǎng)站像知乎、YouTube就是Python寫的;
可以做網(wǎng)絡(luò)游戲的后臺,很多在線游戲的后臺都是Python開發(fā)的。

上面說的這些本人并沒有實現(xiàn)過;

但是我知道Python可以做一些有趣的東西,比如仿制抖音表白小軟件;

本人也是剛剛學(xué)習(xí)Python,這個腳本通過百度找到的,然后自己也重新寫了一遍,加深了映像,最主要的還是思路要清晰;

流程:

1、創(chuàng)建一個游戲屏幕
2、加載title
3、加載button,
4、當鼠標移動到 '算了吧' 上面的時候 重加加載桌面并隨機生成一個 '算了吧' 坐標;
5、當鼠標移動到 ‘好呀'上面時 顯示不同的title

以下就是Python腳本:

import pygame
import random
 
 
# 設(shè)置游戲屏幕大小 這是一個常量
WIDTH, HEIGHT = 640, 480
 
screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
pygame.display.set_caption('FROM一個喜歡你很久的小哥哥')
 
# 標題
def title(text, screen, scale, color=(255, 0, 0)):
 font = pygame.font.SysFont('SimHei', 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)
 
 # 初始化文字的坐標
 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, (0, 0, 0))
 textRect = textRender.get_rect()
 textRect.center = ((x+w/2), (y+h/2))
 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((255, 255, 255))
 font = pygame.font.SysFont('SimHei', 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 == pygame.QUIT:
    pygame.quit()
 
def main():
 pygame.init()
 clock = pygame.time.Clock()
 unlike_pos_x = 330
 unlike_pos_y = 250
 unlike_pos_width = 80
 unlike_pos_height = 40
 unlike_color = (0, 191, 255)
 
 like_pos_x = 180
 like_pos_y = 250
 like_pos_width = 80
 like_pos_height = 40
 like_color = (0, 191, 255)
 
 running = True
 while running:
  # 填充窗口
  screen.fill((255, 255, 255))
 
  img = pygame.image.load('d:/love2.png')
  imgRect = img.get_rect()
  imgRect.midtop = int(WIDTH / 1.3), HEIGHT // 7
  screen.blit(img, imgRect)
 
  # 獲取坐標
  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('小姐姐,我觀察你很久了', screen, scale=[5, 8])
  title('做我女朋友好不好呀', screen, scale=[5, 4])
  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, unlike_color, screen)
 
  for event in pygame.event.get():
   if event.type == pygame.QUIT:
    pygame.quit()
 
  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:
   show_like_interface('我就知道小姐姐你也喜歡我~', screen, color=(255, 0, 0))
 
  pygame.display.flip()
  pygame.display.update()
  clock.tick(60)
 
 
main()

大家有好的創(chuàng)意也可以一起交流下;

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python tkinter 樹形列表控件(Treeview)的使用方法

    Python tkinter 樹形列表控件(Treeview)的使用方法

    這篇文章主要介紹了Python tkinter 樹形列表控件(Treeview)的使用方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • Python實現(xiàn)刪除重復(fù)文件的示例代碼

    Python實現(xiàn)刪除重復(fù)文件的示例代碼

    這篇文章主要為大家詳細介紹了如何利用Python實現(xiàn)刪除重復(fù)文件功能,文中的示例代碼講解詳細,對我們學(xué)習(xí)Python有一定的幫助,感興趣的小伙伴的可以了解一下
    2023-02-02
  • python灰色預(yù)測法的具體使用

    python灰色預(yù)測法的具體使用

    灰色系統(tǒng)理論認為對既含有已知信息又含有未知或非確定信息的系統(tǒng)進行預(yù)測,本文就介紹了python灰色預(yù)測法的具體使用,具有一定的參考價值,感興趣的可以了解一下
    2022-03-03
  • Python實現(xiàn)字典按照value進行排序的方法分析

    Python實現(xiàn)字典按照value進行排序的方法分析

    這篇文章主要介紹了Python實現(xiàn)字典按照value進行排序的方法,結(jié)合實例形式分析了Python字典按照value進行排序的相關(guān)操作技巧,需要的朋友可以參考下
    2017-12-12
  • python爬蟲框架scrapy下載中間件的編寫方法

    python爬蟲框架scrapy下載中間件的編寫方法

    這篇文章主要介紹了python爬蟲框架scrapy下載中間件,在每一個scrapy工程中都有一個名為 middlewares.py 的文件,這個就是中間件文件,本文通過示例代碼給大家介紹的非常詳細,需要的朋友參考下吧
    2022-03-03
  • Python實現(xiàn)字符串模糊匹配詳解

    Python實現(xiàn)字符串模糊匹配詳解

    這篇文章主要為大家詳細介紹了Python實現(xiàn)字符串模糊匹配的相關(guān)知識,文中的示例代碼講解詳細,具有一定的借鑒價值,感興趣的小伙伴可以了解下
    2023-11-11
  • 使用python將mysql數(shù)據(jù)庫的數(shù)據(jù)轉(zhuǎn)換為json數(shù)據(jù)的方法

    使用python將mysql數(shù)據(jù)庫的數(shù)據(jù)轉(zhuǎn)換為json數(shù)據(jù)的方法

    這篇文章主要介紹了使用python將mysql數(shù)據(jù)庫的數(shù)據(jù)轉(zhuǎn)換為json數(shù)據(jù)的方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • PIP和conda 更換國內(nèi)安裝源的方法步驟

    PIP和conda 更換國內(nèi)安裝源的方法步驟

    這篇文章主要介紹了PIP和conda 更換國內(nèi)安裝源的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • python 實現(xiàn)數(shù)據(jù)庫中數(shù)據(jù)添加、查詢與更新的示例代碼

    python 實現(xiàn)數(shù)據(jù)庫中數(shù)據(jù)添加、查詢與更新的示例代碼

    這篇文章主要介紹了python 實現(xiàn)數(shù)據(jù)庫中數(shù)據(jù)添加、查詢與更新的示例代碼,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2020-12-12
  • pampy超強的模式匹配工具的實現(xiàn)

    pampy超強的模式匹配工具的實現(xiàn)

    在自然語言處理界,模式匹配可以說是最常用的技術(shù)。甚至可以說,將NLP技術(shù)作為真實生產(chǎn)力的項目都少不了模式匹配。本文就介紹了pampy超強的模式匹配工具的實現(xiàn),感興趣的可以了解一下
    2021-07-07

最新評論

东明县| 广德县| 通渭县| 简阳市| 龙海市| 宁强县| 明光市| 高安市| 喀什市| 新巴尔虎左旗| 壶关县| 昌宁县| 理塘县| 阳信县| 象州县| 汕头市| 桂东县| 德兴市| 建阳市| 遂平县| 湘潭县| 饶河县| 东乌珠穆沁旗| 云林县| 临澧县| 页游| 鄂温| 锡林浩特市| 闻喜县| 吉林市| 延安市| 仪征市| 济宁市| 蛟河市| 山阳县| 望都县| 化德县| 宝丰县| 扎兰屯市| 东丰县| 鹤山市|