找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 7187|回复: 0

[转载] renpy顺序记忆小游戏

[复制链接]
发表于 2018-3-30 17:50:20 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 法海叔叔 于 2018-3-31 16:09 编辑

替换script.rpy测试。
[RenPy] 纯文本查看 复制代码
# 游戏的脚本可置于此文件中。
# 声明此游戏使用的角色。颜色参数可使角色姓名着色。
define e = Character("艾琳")

# 游戏在此开始。
init:
    $ win = 0
label start:

    # 显示一个背景。此处默认显示占位图,但您也可以在图片目录添加一个文件
    # (命名为“bg room.png”或“bg room.jpg”)来显示。
    scene black

    # 显示角色立绘。此处使用了占位图,但您也可以在图片目录添加命名为
    # “eileen happy.png”的文件来将其替换掉。
    # 此处显示各行对话。

    e "你赢了,再来一次吗"
    call simongame pass (difficulty=1,endgame=4,goquick=5) #难度设置
    # 此处为游戏结尾。

label simongame (difficulty=0, endgame=0,goquick=0):
    #this is a coding of old SIMON sequence game.
    #At first, determine some variable and reset counters.
    $ sequence=[] #the sequence to reply.
    $ nowpush=0 #the sequence iterator
    $ thecolor=0#the button you have to push.

label turnsequence: #now, call the randomizer to add signs.
    python:
        for i in range (0,difficulty):
            added=renpy.random.randint(0,3)
            sequence.append(added)
    $nowpush=0

label showthesequence: #now, show the screen that display the sequence
    if nowpush==len(sequence):
        jump theguessin #jump away if the sequence is complete
    show screen voidgame
    $ renpy.pause(0.5,hard=True)
    show screen displaysequence
    hide screen voidgame
    $ renpy.pause(0.5,hard=True)
    if nowpush< len(sequence):
        $ nowpush+=1
    jump showthesequence

label theguessin: #this label prepare the screen, hiding what's left from previous
    $ nowpush=0
    hide screen displaysequence
    #Now, call the screen for player input
    $ nowpush=0
label guessthesequence:  #now have the player input commands to repeat the sequence
    if nowpush==len(sequence):
        jump turnsequence #if complete, redo from start
    call screen inputcolor
    $ myguess=_return #that's the button you pressed
    $ theright =sequence[nowpush] #that's the correct button to push at the moment
    if theright==myguess:
        $nowpush+=1
        if nowpush==(endgame):
            jump winner
        jump guessthesequence
    if theright!=myguess:
        jump looser
label winner: #a messagge to define victory
    "你赢了!"
    call start
    return
label looser: #a message
    "你输了!"
    call start
    return

screen displaysequence:
    grid 2 2:
        xalign 0.5
        yalign 0.5
        spacing 5
        if sequence[nowpush]==0:
            add "redon.png"
        else:
            add "buttonoff.png"
        if sequence[nowpush]==1:
            add "blueon.png"
        else:
            add "buttonoff.png"
        if sequence[nowpush]==2:
            add "greenon.png"
        else:
            add "buttonoff.png"
        if sequence[nowpush]==3:
            add "yellowon.png"
        else:
            add "buttonoff.png"
screen voidgame:
    grid 2 2:
        xalign 0.5
        yalign 0.5
        spacing 5
        add "buttonoff.png"
        add "buttonoff.png"
        add "buttonoff.png"
        add "buttonoff.png"

screen inputcolor:
    use racetheclock(goquick) #this is a moving bar, so techie!
    text "开始吧!" xalign 0.5 yalign 0.9
    grid 2 2:
        xalign 0.5
        yalign 0.5
        spacing 5
        imagebutton idle "buttonoff.png" hover "redon.png" action Return(0)
        imagebutton idle "buttonoff.png" hover "blueon.png" action Return(1)
        imagebutton idle "buttonoff.png" hover "greenon.png" action Return(2)
        imagebutton idle "buttonoff.png" hover "yellowon.png" action Return(3)


screen racetheclock(goquick):
    $ mytime=AnimatedValue(value=10.0, range=10.0, delay=goquick, old_value=0.0)
    bar value mytime xalign 0.5 yalign 0.1 xsize 500
    timer goquick action Jump("too_slow")

label too_slow:
    "超时了"
    call simongame pass (difficulty=1,endgame=3,goquick=10)
    return



images.rar

3.76 KB, 下载次数: 25, 下载积分: 活力 100

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

本版积分规则

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

GMT+8, 2024-12-31 01:41 , Processed in 0.161989 second(s), 31 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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