当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?

导语

哈喽哈喽~我是木木子!

今天就是大家期待的——《鱿鱼游戏》之《123木头人》正式的Pygame版本,界面图片都

是超清的画质特好,还搭配了音乐更有激情~

“大头娃娃恐惧症”正在蔓延:“무궁화 꽃이 피었습니다 ”。​​ 

上一期:《鱿鱼游戏》之《碰糖》游戏想看的可以看下啦~

事情是这样的:

闲来无事,在家就是刷刷剧看看综艺,这不?

优酷举行2022精品先鉴会,会上官宣了一波新剧集和综艺,其中,一档名为《鱿鱼的胜利》的

综艺不仅引起了网友的注意,也引起了我的注意。

据介绍,《鱿鱼的胜利》是一次智力与体力的大挑战,也是“一场大型儿时游戏回忆杀”。

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第1张图片

看着介绍文案中的“挑战”、“儿时游戏”等关键字眼,再加上海报上粉红色的圆圈、三角、方块元

素,这和美国流媒体播放平台奈飞公司最近的爆款剧集《鱿鱼游戏》不能说是毫无关系,简

直是一模一样……

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第2张图片

于是,我的灵感一现,苦于上一期文章《鱿鱼游戏》之《碰糖》没有火起来,我想着肯定是图

案太简单了,大家感觉没什么难度,没什么视觉效果~SO,小编肝了几天几夜终于给大家写出

了这款超级《鱿鱼游戏》之《123木头人》Pygame版本的游戏送给大家!进来康康嘛?

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第3张图片

正文

游戏规则:

大家是否对扎双马尾的小娃娃感到恐惧?是否害怕玩“一二三,木头人”游戏?

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第4张图片一个诡异的机械女童的声音,伴随着惊悚急促的背景音,用韩语冰冷的喊道“一、二、三,木头

人,思密达。”以上情景,在近期成为绝大部分网友挥之不去的梦魇。只要顺利在木头人转身之

前到达划定的区域即可游戏完成,没有完成的或者女童转身看到在移动的就是敌人即游戏失败

​一、准备中

既然是《123木头人》的游戏那素材也是找的跟《鱿鱼游戏》类似的,如下即是相应素材

1)图片素材

2)音乐、背景

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第5张图片

3)环境安装

本文用到的环境如下:Python3、Pycharm、Pygame模块以及部分自带模块。

模块安装:pip install -i https://pypi.douban.com/simple/ +模块名

二、代码演示

主程序:

import pygame, sys, random
from random import randrange


pygame.init()
screen = pygame.display.set_mode((1024,768))
clock = pygame.time.Clock()
game_font = pygame.font.Font('04B_19.ttf',40)
small_font = pygame.font.Font('04B_19.ttf',10)

bg_surface = pygame.image.load('bk5.png').convert()
man_movement = 0.0
man_status = 0 # 0 stand 1 run
move_speed = 1.0
move_timer = 10

otherman_status = 0
score = 0

man_run1 = pygame.image.load('man/man_1.png').convert_alpha()
man_run2 = pygame.image.load('man/man_2.png').convert_alpha()
man_run3 = pygame.image.load('man/man_3.png').convert_alpha()
man_run4 = pygame.image.load('man/man_4.png').convert_alpha()
man_run5 = pygame.image.load('man/man_5.png').convert_alpha()
man_run6 = pygame.image.load('man/man_6.png').convert_alpha()
man_run7 = pygame.image.load('man/man_7.png').convert_alpha()



pman_surface1 = pygame.image.load('man/man_1.png').convert_alpha()
pman_surface2 = pygame.image.load('man/man_2.png').convert_alpha()
pman_surface3 = pygame.image.load('man/man_3.png').convert_alpha()
pman_surface4 = pygame.image.load('man/man_4.png').convert_alpha()
pman_surface5 = pygame.image.load('man/man_5.png').convert_alpha()
pman_surface6 = pygame.image.load('man/man_6.png').convert_alpha()
pman_surface7 = pygame.image.load('man/man_7.png').convert_alpha()
pman_frames = [man_run1,man_run2,man_run3,man_run4,man_run5,man_run6,man_run7]
pman_index = 0
pmanFLAP = pygame.USEREVENT + 4
pygame.time.set_timer(pmanFLAP,20)


pman_list = []

biggirl_run0 = pygame.image.load('girl/girl_0.png').convert_alpha()
biggirl_run1 = pygame.image.load('girl/girl_1.png').convert_alpha()
biggirl_run2 = pygame.image.load('girl/girl_2.png').convert_alpha()
biggirl_run3 = pygame.image.load('girl/girl_3.png').convert_alpha()
biggirl_run4 = pygame.image.load('girl/girl_4.png').convert_alpha()
biggirl_run5 = pygame.image.load('girl/girl_5.png').convert_alpha()
biggirl_run6 = pygame.image.load('girl/girl_6.png').convert_alpha()



man_frames = [man_run1,man_run2,man_run3,man_run4,man_run5,man_run6,man_run7]
man_index = 0
man_surface = man_frames[0]
man_rect = man_surface.get_rect(center = (100,700))
manFLAP = pygame.USEREVENT + 1
pos_x = 100
pos_y = 700
pygame.time.set_timer(manFLAP,20)
light_status = 0


biggirl_frames = [biggirl_run6,biggirl_run5,biggirl_run4,biggirl_run3,biggirl_run2,
biggirl_run1,biggirl_run0,biggirl_run0,biggirl_run0,biggirl_run1,
biggirl_run2,biggirl_run3,biggirl_run4,biggirl_run5,biggirl_run6]
biggirl_index = 0
biggirl_surface = biggirl_frames[0]
biggirl_rect = biggirl_surface.get_rect(center = (850,100))
biggirlFLAP = pygame.USEREVENT + 2
pygame.time.set_timer(biggirlFLAP,200)

gameover_status = 0

score_sound_countdown = 100

def biggirl_animation():
	new_man = biggirl_frames[biggirl_index]
	new_man_rect = new_man.get_rect(center = (biggirl_rect.centerx,biggirl_rect.centery))
	return new_man,new_man_rect

def man_animation():
	new_man = man_frames[man_index]
	new_man_rect = new_man.get_rect(center = (man_rect.centerx,man_rect.centery))
	return new_man,new_man_rect

def pman_animation():
	new_pman = pman_frames[pman_index]
	return new_pman

def pman_stand():
	new_pman = pman_frames[0]
	return new_pman

def man_stand():
	new_man = man_frames[0]
	new_man_rect = new_man.get_rect(center = (man_rect.centerx,man_rect.centery))
	return new_man,new_man_rect


def redlight_display(game_state):
    if (light_status ==1):
        score_surface = game_font.render("RED LIGHT",True,(255,0,0))
    else:
        score_surface = game_font.render("GREEN LIGHT",True,(0,255,0)) 

    score_rect = score_surface.get_rect(center = (150,50))
    screen.blit(score_surface,score_rect)


def gameover_display(gameover_status):
    if (gameover_status ==1 ):
        gameover_surface = game_font.render("GAME OVER",True,(255,0,0))
        gameover_rect = gameover_surface.get_rect(center = (1024/2,768/2))
        screen.blit(gameover_surface,gameover_rect)

        gameover_surface = game_font.render("Press Space to restart",True,(255,0,0))
        gameover_rect = gameover_surface.get_rect(center = (1024/2,768/2+50))
        screen.blit(gameover_surface,gameover_rect)

    if (gameover_status ==2 ):
        gameover_surface = game_font.render("YOU WIN",True,(255,0,0))
        gameover_rect = gameover_surface.get_rect(center = (1024/2,768/2))
        screen.blit(gameover_surface,gameover_rect)

        gameover_surface = game_font.render("Press Space to restart",True,(255,0,0))
        gameover_rect = gameover_surface.get_rect(center = (1024/2,768/2+50))
        screen.blit(gameover_surface,gameover_rect)





def move_pmans(pmans):
    for pman in pmans:
        if otherman_status ==1 :
            pman.centerx += 2
            pman.centery -= 1

        if pman.centery < -10:
            pmans.remove(pman)
    return pmans
            


def create_pman():
    if gameover_status ==0 :
        bottom_pman = pman_frames[0].get_rect(center = (randrange(1024)-600,800+randrange(500)))
        return bottom_pman


flap_sound = pygame.mixer.Sound('coin.wav')
death_sound = pygame.mixer.Sound('bomb2.wav')
song_sound = pygame.mixer.Sound('song.wav')


SPAWNpman = pygame.USEREVENT
pygame.time.set_timer(SPAWNpman,1200)


gameover_status =0 
pygame.display.set_caption('Squid Game')


while True:

    if ((biggirl_index>=5) & (biggirl_index<=10)):
        light_status = 1
        otherman_status = 0
    else :
        light_status = 0  
        otherman_status = 1 

    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_d:
                man_status = 1
                flap_sound.play()
            if event.key == pygame.K_a:
                man_status = 0
                flap_sound.play()
            if (event.key == pygame.K_SPACE) &( gameover_status !=0 ):
                man_status = 0
                gameover_status = 0 
                pman_list = [] 
                man_rect.centerx = 100
                man_rect.centery = 700
                pos_x = 100
                pos_y = 700



        elif event.type == SPAWNpman:
            if ((otherman_status == 1) & (gameover_status == 0)):
                for num in range(0,10): 
                    pman_list.append(create_pman())
                print("pile count = ",len(pman_list))


        elif event.type == pmanFLAP:
            if pman_index < 6 :
                pman_index = pman_index + 1
            else:
                pman_index = 0

            if otherman_status==1 :
                pman_surface = pman_animation()
            else:
                pman_surface = pman_stand()
            


        elif event.type == manFLAP:
            if man_index < 6 :
                man_index = man_index + 1
            else:
                man_index = 0
            if man_status==1 :
                man_surface,man_rect = man_animation()
            else:
                man_surface,man_rect = man_stand()



        elif event.type == biggirlFLAP:
            if gameover_status == 0 :
                if biggirl_index < 14 :
                    biggirl_index = biggirl_index + 1
                else:
                    biggirl_index = 0
                    song_sound.play()

            biggirl_surface,biggirl_rect = biggirl_animation()



    if gameover_status == 0:

        screen.blit(bg_surface,(0,0))
        text_surface = game_font.render("Press (D) to Go, (A) Stop",True,(0,0,0))
        text_rect = text_surface.get_rect(center = (1024/2,768-50))
        screen.blit(text_surface,text_rect)


        screen.blit(man_surface, man_rect)


        screen.blit(biggirl_surface, biggirl_rect)
         # pmans
        pman_list = move_pmans(pman_list)
        ##pman_list = remove_pmans(pman_list)

        for pman in pman_list:
            screen.blit(pman_surface,pman)

        if (man_status == 1):
            pos_x = pos_x + move_speed
            pos_y = pos_y - move_speed/2
            man_rect.centerx = pos_x
            man_rect.centery = pos_y

        if ((man_status ==1)and (light_status==1)) :
            gameover_status = 1
            death_sound.play()
            gameover_display(gameover_status)

        if (pos_y < 250):
            gameover_status = 2
            death_sound.play()
            gameover_display(gameover_status)

        redlight_display('main_game')
    else:
        gameover_display(gameover_status)


    pygame.display.update()
    clock.tick(120)

三、效果展示

1)视频效果展示——

“大头娃娃恐惧症”正在蔓延:“무궁화 꽃이 피었습니다 ”!

2)截图效果展示——

游戏界面:

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第6张图片

诡异女童转身:

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第7张图片

诡异女童正面:

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第8张图片

游戏结束:

游戏开始自动跑跟转身,如果在女童转身之后按住D继续跑则游戏结束!

当《鱿鱼游戏》强势来袭:“一、二、三,木头人,思密达。”你还在恐惧嘛?_第9张图片

总结

《123木头人》小游戏这里就正式结束啦~音乐修改了,让大家消除一下对木头人的恐惧!

是不是Very good  哈哈哈~ 贴心小可爱!有需要完整的素材源码记得找我哈!

免费源码领取处:滴滴我即可啦~

或者看我主页(pc端)页面自取即可!

你们的支持是我最大的动力!!记得三连哦~mua 欢迎大家阅读往期的文章哦~




往期游戏阅读推荐——

项目1.0  超级玛丽

程序员自制游戏:超级玛丽100%真实版,能把你玩哭了~【附源码】

项目1.1   扫雷

 Pygame实战:据说这是史上最难扫雷游戏,没有之一,你们感受下......

项目1.3  太空机甲游戏

Pygame实战:牛,几千行代码实现《机甲闯关冒险游戏》,太牛了(保存起来慢慢学)

项目1.4  水果忍者

【Pygame实战】风靡全球的切水果游戏升级版“水果忍者”上线啦,你敢来PK嘛?

 项目4.9  天天酷跑小游戏

《天天酷跑》是不是真的不火了?Python发布“酷跑+”计划。

文章汇总——

项目1.0 Python—2021 |已有文章汇总 | 持续更新,直接看这篇就够了

(更多内容+源码都在文章汇总哦!!欢迎阅读~)

你可能感兴趣的:(python合集,Pygame合集,程序员合集,pygame,python,开发语言)