---
# System prepended metadata

title: 生日禮物
tags: [自己玩]

---

# 生日禮物
 ###### tags: `自己玩`
 
圖片可來[**我的雲端**](https://drive.google.com/drive/folders/1gAEiGbjCiC9qoNux9EkTGpFzPmtNot2p?usp=sharing)查看

```python=
import pygame
import random
import os
import time
from random import randint

pygame.init()#遊戲初始化
pygame.mixer.init()
WIDTH = 550
HIGHT = 600
font_name = pygame.font.match_font('DFKai-SB')#引入字體 arial不支援中文
screen = pygame.display.set_mode((WIDTH,HIGHT))#視窗大小 寬度500高度600
pygame.display.set_caption("世界上最怪的人")#更改視窗名字



clock = pygame.time.Clock()#可管理時間 


backsound = pygame.mixer.Sound(os.path.join("楊舒雅","準備好了嗎.mp3"))



不完整2 = pygame.image.load(os.path.join("楊舒雅","不完整2.jpg")).convert()
pygame.display.set_icon(不完整2)#更改視窗名字旁邊的圖案

封面照= pygame.image.load(os.path.join("楊舒雅","不完整1.jpg")).convert()
不完整2= pygame.image.load(os.path.join("楊舒雅","不完整2.jpg")).convert()
不完整3= pygame.image.load(os.path.join("楊舒雅","不完整3.jpg")).convert()

假文青1= pygame.image.load(os.path.join("楊舒雅","假文青1.jpg")).convert()
假文青2= pygame.image.load(os.path.join("楊舒雅","假文青2.jpg")).convert()
假文青3= pygame.image.load(os.path.join("楊舒雅","假文青3.jpg")).convert()
假文青4= pygame.image.load(os.path.join("楊舒雅","假文青4.jpg")).convert()
假文青5= pygame.image.load(os.path.join("楊舒雅","假文青5.jpg")).convert()

hipster = [假文青1,假文青2,假文青3,假文青4,假文青5]

搞怪1= pygame.image.load(os.path.join("楊舒雅","搞怪1.jpg")).convert()
搞怪2= pygame.image.load(os.path.join("楊舒雅","搞怪2.jpg")).convert()
搞怪3= pygame.image.load(os.path.join("楊舒雅","搞怪3.jpg")).convert()
搞怪4= pygame.image.load(os.path.join("楊舒雅","搞怪4.jpg")).convert()
搞怪5= pygame.image.load(os.path.join("楊舒雅","搞怪5.jpg")).convert()
搞怪6= pygame.image.load(os.path.join("楊舒雅","搞怪6.jpg")).convert()
搞怪7= pygame.image.load(os.path.join("楊舒雅","搞怪7.jpg")).convert()
搞怪8= pygame.image.load(os.path.join("楊舒雅","搞怪8.jpg")).convert()
搞怪9= pygame.image.load(os.path.join("楊舒雅","搞怪9.jpg")).convert()
funny = [搞怪2,搞怪3,搞怪4,搞怪5,搞怪6,搞怪9]

睡1= pygame.image.load(os.path.join("楊舒雅","睡1.jpg")).convert()
睡2= pygame.image.load(os.path.join("楊舒雅","睡2.jpg")).convert()
睡3= pygame.image.load(os.path.join("楊舒雅","睡3.jpg")).convert()
睡4= pygame.image.load(os.path.join("楊舒雅","睡4.jpg")).convert()
睡5= pygame.image.load(os.path.join("楊舒雅","睡5.jpg")).convert()

sleep = [睡1,睡2,睡3,睡4,睡5]

我1= pygame.image.load(os.path.join("楊舒雅","我12.jpg")).convert()
我1 = pygame.transform.rotate(我1, 90)
我2= pygame.image.load(os.path.join("楊舒雅","我6.jpg")).convert()
我2 = pygame.transform.rotate(我2, -90)
我3= pygame.image.load(os.path.join("楊舒雅","我4.jpg")).convert()
我4= pygame.image.load(os.path.join("楊舒雅","我9.jpg")).convert()
我5= pygame.image.load(os.path.join("楊舒雅","我8.jpg")).convert()
我5 = pygame.transform.rotate(我5, -90)
我6= pygame.image.load(os.path.join("楊舒雅","我5.jpg")).convert()
我7= pygame.image.load(os.path.join("楊舒雅","我2.jpg")).convert()
我7 = pygame.transform.rotate(我7, -90)
我8= pygame.image.load(os.path.join("楊舒雅","我7.jpg")).convert()

我9= pygame.image.load(os.path.join("楊舒雅","我1.jpg")).convert()
我10= pygame.image.load(os.path.join("楊舒雅","我11.jpg")).convert()

me = [我1,我2,我3,我4,我5,我6,我7,我8,我9,我10]

最喜歡的合照= pygame.image.load(os.path.join("楊舒雅","我10.png")).convert()


ilove= pygame.image.load(os.path.join("楊舒雅","i.png")).convert()
ilove = pygame.transform.scale(ilove, (550, 600))
love= pygame.image.load(os.path.join("楊舒雅","love.png")).convert()
love = pygame.transform.scale(love, (550, 600))
you= pygame.image.load(os.path.join("楊舒雅","you.png")).convert()
you = pygame.transform.scale(you, (550, 600))

豬 = pygame.image.load(os.path.join("楊舒雅","豬.png")).convert()
小豬 = pygame.transform.scale(豬, (100, 100))
小豬.set_colorkey((0,0,0)) 
羊肉串 = pygame.image.load(os.path.join("楊舒雅","羊肉串.png")).convert()
羊肉串1 = pygame.transform.scale(羊肉串, (60, 60))
羊肉串1.set_colorkey((0,0,0)) 
end = pygame.image.load(os.path.join("楊舒雅","結局.jpg")).convert()

screen.blit(封面照,(-100,-300))#blit就是畫 (圖案,(位置))

def draw_text2(surf, text, size ,x,y):#畫東西的函示 (哪個平面, 內容,大小,x,y)
    font = pygame.font.Font(font_name, size)
    text_surface = font.render(text, True, (255,185,15))
    text_rect = text_surface.get_rect()
    text_rect.centerx = x
    text_rect.top = y
    surf.blit(text_surface, text_rect)
def draw_text1(surf, text, size ,x,y):#畫東西的函示 (哪個平面, 內容,大小,x,y)
    font = pygame.font.Font(font_name, size)
    text_surface = font.render(text, True, (255,252,205))
    text_rect = text_surface.get_rect()
    text_rect.centerx = x
    text_rect.top = y
    surf.blit(text_surface, text_rect)
def draw_text3(surf, text, size ,x,y):#畫東西的函示 (哪個平面, 內容,大小,x,y)
    font = pygame.font.Font(font_name, size)
    text_surface = font.render(text, True, (152,245,255))
    text_rect = text_surface.get_rect()
    text_rect.centerx = x
    text_rect.top = y
    surf.blit(text_surface, text_rect)
def draw_text4(surf, text, size ,x,y):#畫東西的函示 (哪個平面, 內容,大小,x,y)
    font = pygame.font.Font(font_name, size)
    text_surface = font.render(text, True, (192,255,62))
    text_rect = text_surface.get_rect()
    text_rect.centerx = x
    text_rect.top = y
    surf.blit(text_surface, text_rect)
def draw_text5(surf, text, size ,x,y):#畫東西的函示 (哪個平面, 內容,大小,x,y)
    font = pygame.font.Font(font_name, size)
    text_surface = font.render(text, True, (255,106,106))
    text_rect = text_surface.get_rect()
    text_rect.centerx = x
    text_rect.top = y
    surf.blit(text_surface, text_rect)
def draw_text6(surf, text, size ,x,y,z,a,b):#畫東西的函示 (哪個平面, 內容,大小,x,y)
    font = pygame.font.Font(font_name, size)
    text_surface = font.render(text, True, (z,a,b))
    text_rect = text_surface.get_rect()
    text_rect.centerx = x
    text_rect.top = y
    surf.blit(text_surface, text_rect)

def draw_flower(circenterweidth,circenterhight):
    
    
    pygame.draw.circle(screen,(255, 218, 185),(circenterweidth,circenterhight),7)
    
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth-20,circenterhight),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth-20,circenterhight),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth-13,circenterhight-15),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth-13,circenterhight-15),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth-7,circenterhight-19),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth-7,circenterhight-19),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth,circenterhight-20),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth,circenterhight-20),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth,circenterhight-20),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth,circenterhight-20),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth+7,circenterhight-19),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth+7,circenterhight-19),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth+13,circenterhight-15),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth+13,circenterhight-15),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth+19,circenterhight-7),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth+19,circenterhight-7),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth+20,circenterhight),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth+20,circenterhight),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth-19,circenterhight-7),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth-19,circenterhight-7),(circenterweidth,circenterhight),2)
    
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth+7,circenterhight+19),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth+7,circenterhight+19),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth+13,circenterhight+15),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth+13,circenterhight+15),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth+19,circenterhight+7),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth+19,circenterhight+7),(circenterweidth,circenterhight),2)
    
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth-7,circenterhight+19),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth-7,circenterhight+19),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth-13,circenterhight+15),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth-13,circenterhight+15),(circenterweidth,circenterhight),2)
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth-19,circenterhight+7),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth-19,circenterhight+7),(circenterweidth,circenterhight),2)
     
    pygame.draw.circle(screen,(250 ,235 ,215),(circenterweidth,circenterhight+20),4)
    pygame.draw.line(screen,(202 ,255, 112),(circenterweidth,circenterhight+20),(circenterweidth,circenterhight),2)
    
    
    pygame.draw.circle(screen,(255, 193, 37),(circenterweidth,circenterhight),7)
    
def draw_init():
    
    screen.blit(封面照,(-100,-300))
    draw_text2(screen, "Happy Birthday",80,WIDTH/2,HIGHT/15)
    draw_text1(screen, "THE MOST",64,WIDTH/2,HIGHT/4)
    draw_text1(screen, "WEIRD GIRL",64,WIDTH/2,HIGHT/3+20)
    
    for p in range(0,WIDTH,50):
        for l in range(0,HIGHT,50):
            if  l not in range(int(HIGHT/2)+25,int(HIGHT/2)+125) :
                draw_text3(screen, "~",25,p,l)
                draw_text4(screen, "~",25,p+10,l)
                draw_text5(screen, "~",25,p+20,l)
            if  l in range(int(HIGHT/2)+25,int(HIGHT/2)+125) and p not in range(int(WIDTH/2)-200,int(WIDTH/2)+200):
                draw_text3(screen, "~",25,p,l)
                draw_text4(screen, "~",25,p+10,l)
                draw_text5(screen, "~",25,p+20,l)
    draw_text1(screen, "press '1' two time to see your's Sleeping Photos ",18,WIDTH/2,HIGHT/2+25)
    draw_text1(screen, "press '2' two time to see your's Funny Photos ",18,WIDTH/2-15,HIGHT/2+50)
    draw_text1(screen, "press '3' two time to see your's Hipster Photos ",18,WIDTH/2-6,HIGHT/2+75)
    draw_text1(screen, "press 'space' to see a big suprise  ",18,WIDTH/2-60,HIGHT/2+100)
    draw_text1(screen, "press 'q' two time to quit this screen ",18,WIDTH/2-45,HIGHT/2+125)
    pygame.display.update()
    watting = True
    while watting:
        clock.tick(FPS)#1秒鐘之內最多只能執行 FPS 次
        for event in pygame.event.get():#全部事件列出來
            if event.type == pygame.QUIT:#如果按x讓視窗關閉
                pygame.quit()
                return True
            elif event.type == pygame.KEYUP:#按下鍵盤建 (KEYUP 是按下再拿起案件才開始)
                
                watting = False
                return False
    
            
        
            
            
show_init = True
running = True
FPS = 60
while running:
    if show_init:
        backsound.play(-1)
        close = draw_init()
        
        draw_init()
        show_init = False
    clock.tick(FPS)#1秒鐘之內最多只能執行 FPS 次
    for event in pygame.event.get():#全部事件列出來
        if event.type == pygame.QUIT:#如果按x讓視窗關閉
            running = False
        elif event.type == pygame.KEYUP:      
            if event.key == pygame.K_2:
                
                搞怪1 = pygame.transform.scale(搞怪1, (550, 600)) 
                搞怪1 = pygame.transform.rotate(搞怪1, -90)
                screen.blit(搞怪1,(0,0))
                pygame.display.update()
                搞怪1 = pygame.transform.rotate(搞怪1, 90)
                for i in range(0,6,1):
                    funny1 = pygame.transform.scale(funny[i], (550, 600))
                    screen.blit(funny1,(0,0))
                    time.sleep(1)
                    pygame.display.update()
                screen.blit(love,(0,0))
                pygame.display.update()
                time.sleep(2)
                draw_init()
            if event.key == pygame.K_1:
                for i in range(0,len(sleep),1):
                    sleep1 = pygame.transform.scale(sleep[i], (550, 600))
                    screen.blit(sleep1,(0,0))
                    time.sleep(1)
                    pygame.display.update()
                screen.blit(ilove,(0,0))
                pygame.display.update()
                time.sleep(2)
                draw_init()
            if event.key == pygame.K_3:
                for i in range(0,len(hipster),1):
                    hipster1 = pygame.transform.scale(hipster[i], (550, 600))
                    screen.blit(hipster1,(0,0))
                    time.sleep(1)
                    pygame.display.update()
                screen.blit(you,(0,0))
                pygame.display.update()
                time.sleep(2)
                draw_init()
            if event.key == pygame.K_SPACE:
                for i in range(0,len(me),1):
                    me1 = pygame.transform.scale(me[i], (550, 600))
                    screen.blit(me1,(0,0))
                    pygame.display.update()
                    time.sleep(1)
                draw_init()
              
            if event.key == pygame.K_q:
                合照 = pygame.transform.scale(最喜歡的合照, (550, 600))
                screen.blit(合照,(0,0))
                pygame.display.update()
                
                time.sleep(2)
                draw_text6(screen,"嘿 又到了一年一度才有的時候了",30,WIDTH/2,160,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                draw_text6(screen,"汝又老了一歲 但因保養有功 ",30,WIDTH/2,190,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                draw_text6(screen,"似在汝的臉上找不出歲月的痕跡 ",30,WIDTH/2,220,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                draw_text6(screen,"當吾在家中看著汝的相片時 ",30,WIDTH/2,250,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                draw_text6(screen,"臉上總是掛著淺淺的微笑 ",30,WIDTH/2,280,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                draw_text6(screen,"不為別的 就是會想到你那勾錐一舉一動 ",30,WIDTH/2,310,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                draw_text6(screen,"雖然汝總是讓我不開勳 哈哈哈 ",30,WIDTH/2,340,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                draw_text6(screen,"願汝一生開勳且平安 呦 ",30,WIDTH/2,370,240 ,255 ,255)
                pygame.display.update()
                time.sleep(1.3)
                for i in range(1,120,4):
                    draw_text6(screen,"撈夫 一ㄨ ",i,WIDTH/2,HIGHT/2-50,255 ,131 ,250)
                    pygame.display.update()
                    time.sleep(0.1)
                    合照 = pygame.transform.scale(最喜歡的合照, (550, 600))
                    screen.blit(合照,(0,0))
                    draw_text6(screen,"嘿 又到了一年一度才有的時候了",30,WIDTH/2,160,240 ,255 ,255)
                    draw_text6(screen,"汝又老了一歲 但因保養有功 ",30,WIDTH/2,190,240 ,255 ,255)
                    draw_text6(screen,"似在汝的臉上找不出歲月的痕跡 ",30,WIDTH/2,220,240 ,255 ,255)
                    draw_text6(screen,"當吾在家中看著汝的相片時 ",30,WIDTH/2,250,240 ,255 ,255)
                    draw_text6(screen,"臉上總是掛著淺淺的微笑 ",30,WIDTH/2,280,240 ,255 ,255)
                    draw_text6(screen,"不為別的 就是會想到你那勾錐一舉一動 ",30,WIDTH/2,310,240 ,255 ,255)
                    draw_text6(screen,"雖然汝總是讓我不開勳 哈哈哈 ",30,WIDTH/2,340,240 ,255 ,255)
                    draw_text6(screen,"願汝一生開勳且平安 呦 ",30,WIDTH/2,370,240 ,255 ,255)
                draw_text6(screen,"撈夫 一ㄨ ",i,WIDTH/2,HIGHT/2-50,255 ,131 ,250)   
    
                draw_flower(275,300)
                pygame.display.update()
                time.sleep(1.5)
                for i in range(1,5,1):
                    flowerwidth = randint(0,550)
                    flowerhight = randint(0,600)
                    draw_flower(flowerwidth,flowerhight)
                    pygame.display.update()
                    time.sleep(1)
                for i in range(1,10,1):
                    flowerwidth = randint(0,550)
                    flowerhight = randint(0,600)
                    draw_flower(flowerwidth,flowerhight)
                pygame.display.update()
                time.sleep(0.8)
                for j in range(1,7,1):
                    for i in range(1,20,1):
                        flowerwidth = randint(0,550)
                        flowerhight = randint(0,600)
                        draw_flower(flowerwidth,flowerhight)
                    pygame.display.update()
                    time.sleep(0.6)
              
                pygame.draw.rect(screen,(180 ,238, 180),(50,HIGHT/3-20,WIDTH-100,80),0)
                draw_text6(screen, "~  END  ~" ,40 ,WIDTH/2,HIGHT/3,255 ,48 ,48)
                screen.blit(小豬,(WIDTH/2-200,HIGHT/3-25))
                screen.blit(羊肉串1,(WIDTH/2+120,HIGHT/3-15))
                pygame.display.update()
                time.sleep(2)
                running = False
                pygame.QUIT

```