找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 6919|回复: 1

[转载] [转]记忆力小游戏

[复制链接]
发表于 2018-3-28 22:53:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
一个renpy的记忆类小游戏,转自官方论坛,原贴地址:https://lemmasoft.renai.us/forums/viewtopic.php?f=51&t=18047&p=235921#p235919

[RenPy] 纯文本查看 复制代码
##### The game screen
screen memo_scr:    
    ##### Timer
    timer 1.0 action If (memo_timer > 1, SetVariable("memo_timer", memo_timer - 1), Jump("memo_game_lose") ) repeat True
    text str(memo_timer) xalign 0.5 yalign 0.05 outlines [(3, "#111111", 0, 0)] 
    
    ##### Cards
    #
    # To use images, just comment out lines that show text and uncomment lines that show images
    grid 4 3:
        for card in cards_list:
            button:
                background None
                if card["c_chosen"]:        # shows the face of the card
                    #text card["c_value"]    # will show text
                    add card["c_value"]    # 用图片去掉#号
                else:                       # shows the back of the card
                    #text "X"                # will show text
                    add "C"                # 使用图片去掉#号
                action If ( (card["c_chosen"] or not can_click), None, [SetDict(cards_list[card["c_number"]], "c_chosen", True), Return(card["c_number"]) ] )
 

    

init:
    python:
        def cards_shuffle(x):
            renpy.random.shuffle(x)
            return x

    ##### Images
    image A = "n1.png"         # different card images
    image B = "n2.png"
    image C = "nb.png"          # back of the card

    

    
label memoria_game:
    
    #####
    #
    # At first, let's set the cards to play (the amount should match the grid size - in this example 12)
    $ values_list = ["A", "A", "A", "A", "A", "A", "B",  "B", "B", "B", "B", "B"]
    
    # Then - shuffle them
    $ values_list = cards_shuffle(values_list)
    
    # And make the cards_list that describes all the cards
    $ cards_list = []
    python:
        for i in range (0, len(values_list) ):
            cards_list.append ( {"c_number":i, "c_value": values_list[i], "c_chosen":False} )   

    # Before start the game, let's set the timer
    $ memo_timer = 50.0
    
    # Shows the game screen
    show screen memo_scr
    
    # The game loop
    label memo_game_loop:
        $ can_click = True
        $ turned_cards_numbers = []
        $ turned_cards_values = []
        
        # Let's set the amount of cards that should be opened each turn (all of them should match to win)
        $ turns_left = 3
        
        label turns_loop:
            if turns_left > 0:
                $ result = ui.interact()
                $ memo_timer = memo_timer
                $ turned_cards_numbers.append (cards_list[result]["c_number"])
                $ turned_cards_values.append (cards_list[result]["c_value"])
                $ turns_left -= 1
                jump turns_loop
        
        # To prevent further clicking befor chosen cards will be processed
        $ can_click = False
        # If not all the opened cards are matched, will turn them face down after pause
        if turned_cards_values.count(turned_cards_values[0]) != len(turned_cards_values):
            $ renpy.pause (1.0, hard = True)
            python:
                for i in range (0, len(turned_cards_numbers) ):
                    cards_list[turned_cards_numbers[i]]["c_chosen"] = False
        
        # If cards are matched, will check if player has opened all the cards
        else:
            $ renpy.pause (1.0, hard = True)
            python: 
                
                # Let's remove opened cards from game field
                # But if you prefere to let them stay - just comment out next 2 lines
                for i in range (0, len(turned_cards_numbers) ):
                    cards_list[turned_cards_numbers[i]]["c_value"] = Null()
                    
                    
                for j in cards_list:
                    if j["c_chosen"] == False:
                        renpy.jump ("memo_game_loop")
                renpy.jump ("memo_game_win")
                
                

        jump memo_game_loop

label memo_game_lose:
    hide screen memo_scr
    $ renpy.pause (0.1, hard = True)
    $ renpy.pause (0.1, hard = True)
    "You lose! Try again."
    jump memoria_game

label memo_game_win:
    hide screen memo_scr
    $ renpy.pause (0.1, hard = True)
    $ renpy.pause (0.1, hard = True)
    "You win!"
    
label start:

    menu:
        "开始游戏":
            jump memoria_game

return
n1.png
n2.png
nb.png

评分

参与人数 1干货 +1 收起 理由
BuErShen + 1 感谢分享

查看全部评分

发表于 2018-5-16 14:27:41 | 显示全部楼层
这个素材和游戏 在My我的cute室友roommate 我的表姐中 看到过  还有一个 连连看的游戏 也不错
回复 支持 抱歉

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|RenPy中文空间 ( 苏ICP备17067825号|苏公网安备 32092302000068号 )

GMT+8, 2024-4-25 21:09 , Processed in 0.063302 second(s), 14 queries , File On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表