[RenPy] 纯文本查看 复制代码
## 定义线索数量
define clue_1 = 0
define clue_2 = 0
define clue_3 = 0
define clue_4 = 0
define clue_5 = 0
define clue_6 = 0
define clue_7 = 0
define numbers_list = [] ## 一个可以存放随机数的子集
define clue_lock_key = 0 ## 解锁条件
## 用于改变文本的样式
style text_style:
size 40
color "#39C5BB" ## 初音色!!
outlines [(absolute(1), "#000000", absolute(0), absolute(0))]## 黑色描边
## 初始随机数
init python:
import random ## 应用了随机数模块
numbers_list = [] ## 建立一个可以存放随机数的子集
random_numbers = (random.randint(1, 7)) ## 使R_N等于随机数
while len(numbers_list) < 10: ## 当随机数数量不足10时,进入循环
if numbers_list.count(str(random_numbers)) >= 3: ## 当“X”的数量大于3时将无法获取
numbers_list.remove(str(random_numbers)) ## 将R_N转换为字符从子集中删去
random_numbers = (random.randint(1, 7)) ## 使随机数再次改变
else:
numbers_list.append(str(random_numbers)) ## 将R_N转换为字符串加入到子集中
random_numbers = (random.randint(1, 7)) ## 使随机数再次改变
clue_list_1 = numbers_list.count("1") ## 获取列表中“X”的数量
clue_list_2 = numbers_list.count("2")
clue_list_3 = numbers_list.count("3")
clue_list_4 = numbers_list.count("4")
clue_list_5 = numbers_list.count("5")
clue_list_6 = numbers_list.count("6")
clue_list_7 = numbers_list.count("7")
## 线索墙
screen Wall_of_clues:
button:
xsize 1120
ysize 720
action [Hide("menu_clues"), Show("Wall_of_clues")] ## 透明的关闭按钮
button:
xpos 0.02
ypos 0.9
text "随机"
action Jump("compute") ## 随机按钮
if clue_lock_key == 7:
button:
xpos 0.02
ypos 0.8
text "{size=30}解锁"
action MainMenu(confirm=True) ## 解锁按钮(此处作用为回到标题)
if clue_1 == 0: ## 等待放置的线索槽位
button:
add "images/clue_lock.png"
xpos 0.1
ypos 0.05
action Show("menu_clues") ## 打开待收取列表
elif clue_1 >= 1: ## 展示已知的线索
button:
add "images/clue_1.png"
text "{i}[clue_list_1]" style "text_style": ## 使用到了"text_style"样式
xpos 0.15
ypos 0.35
xpos 0.1
ypos 0.05
action [SetVariable("clue_1", clue_1-1), SetVariable("clue_lock_key", clue_lock_key-1)]## 使已收线索减1,使key加1
if clue_2 == 0:
button:
add "images/clue_lock.png"
xpos 0.3
ypos 0.05
action Show("menu_clues")
elif clue_2 >= 1:
button:
add "images/clue_2.png"
text "{i}[clue_list_2]" style "text_style":
xpos 0.15
ypos 0.35
xpos 0.3
ypos 0.05
action [SetVariable("clue_2", clue_2-1), SetVariable("clue_lock_key", clue_lock_key-1)]
if clue_3 == 0:
button:
add "images/clue_lock.png"
xpos 0.5
ypos 0.05
action Show("menu_clues")
elif clue_3 >= 1:
button:
add "images/clue_3.png"
text "{i}[clue_list_3]" style "text_style":
xpos 0.15
ypos 0.35
xpos 0.5
ypos 0.05
action [SetVariable("clue_3", clue_3-1), SetVariable("clue_lock_key", clue_lock_key-1)]
if clue_4 == 0:
button:
add "images/clue_lock.png"
xpos 0.7
ypos 0.05
action Show("menu_clues")
elif clue_4 >= 1:
button:
add "images/clue_4.png"
text "{i}[clue_list_4]" style "text_style":
xpos 0.15
ypos 0.35
xpos 0.7
ypos 0.05
action [SetVariable("clue_4", clue_4-1), SetVariable("clue_lock_key", clue_lock_key-1)]
if clue_5 == 0:
button:
add "images/clue_lock.png"
xpos 0.1
ypos 0.5
action Show("menu_clues")
elif clue_5 >= 1:
button:
add "images/clue_5.png"
text "{i}[clue_list_5]" style "text_style":
xpos 0.15
ypos 0.35
xpos 0.1
ypos 0.5
action [SetVariable("clue_5", clue_5-1), SetVariable("clue_lock_key", clue_lock_key-1)]
if clue_6 == 0:
button:
add "images/clue_lock.png"
xpos 0.3
ypos 0.5
action Show("menu_clues")
elif clue_6 >= 1:
button:
add "images/clue_6.png"
text "{i}[clue_list_6]" style "text_style":
xpos 0.15
ypos 0.35
xpos 0.3
ypos 0.5
action [SetVariable("clue_6", clue_6-1), SetVariable("clue_lock_key", clue_lock_key-1)]
if clue_7 == 0:
button:
add "images/clue_lock.png"
xpos 0.5
ypos 0.5
action Show("menu_clues")
elif clue_7 >= 1:
button:
add "images/clue_7.png"
text "{i}[clue_list_7]" style "text_style":
xpos 0.15
ypos 0.35
xpos 0.5
ypos 0.5
action [SetVariable("clue_7", clue_7-1), SetVariable("clue_lock_key", clue_lock_key-1)]
## 待收取的线索
screen menu_clues:
frame:
xsize 160
ysize 720
xcenter 1200
ycenter 0.5
viewport:
xinitial 0.0
yinitial 0.0
mousewheel True
draggable True
side_yfill True
vbox:
spacing 10
if "1" in numbers_list and clue_1 < 1: ## 如果“X”包含在列表中,并且线索数量小于1时,展示线索
for clue_list_1 in range(1,numbers_list.count("1")+1): ## 遍历,循环次数为“列表中‘X’的数量”
button:
add "images/clue_1.png":
xsize 115
ysize 165
action [SetVariable("clue_1", clue_1+1), SetVariable("clue_lock_key", clue_lock_key+1)]## 使已收取线索加1,使key加1
if "2" in numbers_list and clue_2 < 1:
for clue_list_2 in range(1,numbers_list.count("2")+1):
button:
add "images/clue_2.png":
xsize 115
ysize 165
action [SetVariable("clue_2", clue_2+1), SetVariable("clue_lock_key", clue_lock_key+1)]
if "3" in numbers_list and clue_3 < 1:
for clue_list_3 in range(1,numbers_list.count("3")+1):
button:
add "images/clue_3.png":
xsize 115
ysize 165
action [SetVariable("clue_3", clue_3+1), SetVariable("clue_lock_key", clue_lock_key+1)]
if "4" in numbers_list and clue_4 < 1:
for clue_list_4 in range(1,numbers_list.count("4")+1):
button:
add "images/clue_4.png":
xsize 115
ysize 165
action [SetVariable("clue_4", clue_4+1), SetVariable("clue_lock_key", clue_lock_key+1)]
if "5" in numbers_list and clue_5 < 1:
for clue_list_5 in range(1,numbers_list.count("5")+1):
button:
add "images/clue_5.png":
xsize 115
ysize 165
action [SetVariable("clue_5", clue_5+1), SetVariable("clue_lock_key", clue_lock_key+1)]
if "6" in numbers_list and clue_6 < 1:
for clue_list_6 in range(1,numbers_list.count("6")+1):
button:
add "images/clue_6.png":
xsize 115
ysize 165
action [SetVariable("clue_6", clue_6+1), SetVariable("clue_lock_key", clue_lock_key+1)]
if "7" in numbers_list and clue_7 < 1:
for clue_list_7 in range(1,numbers_list.count("7")+1):
button:
add "images/clue_7.png":
xsize 115
ysize 165
action [SetVariable("clue_7", clue_7+1), SetVariable("clue_lock_key", clue_lock_key+1)]
## 随机按钮跳转到这里,进行随机
label compute:
## 后面的内容和init python里的内容差不多
python:
clue_1 = 0 ## 重置已经搜集到的线索
clue_2 = 0
clue_3 = 0
clue_4 = 0
clue_5 = 0
clue_6 = 0
clue_7 = 0
numbers_list.clear() ## 清除列表
random_numbers = (random.randint(1, 7))
while len(numbers_list) < 10:
if numbers_list.count(str(random_numbers)) >= 3:
numbers_list.remove(str(random_numbers))
random_numbers = (random.randint(1, 7))
else:
numbers_list.append(str(random_numbers))
random_numbers = (random.randint(1, 7))
clue_list_1 = numbers_list.count("1") ## 重新获取列表中“X”的数量
clue_list_2 = numbers_list.count("2")
clue_list_3 = numbers_list.count("3")
clue_list_4 = numbers_list.count("4")
clue_list_5 = numbers_list.count("5")
clue_list_6 = numbers_list.count("6")
clue_list_7 = numbers_list.count("7")
clue_lock_key = 0 ## 重置key的数量
hide screen menu_clues ## 很重要!!不加这句会导致部分bug产生!!
call screen Wall_of_clues ## 再次启动
## 游戏开始
label start:
call screen Wall_of_clues
return