-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumber.rpy
141 lines (111 loc) · 5.57 KB
/
Number.rpy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//Player must click some buttons in predefined order before time gone.
transform roto_transform (roto_var):
# ATL transform that will rotate our displayables to "roto_var" degrees
rotate roto_var
rotate_pad False
##### The game screen
screen numbers_scr:
# It is better to operate this game with mouse only, so just disable cursor and enter keys
key "K_LEFT" action Hide("nonexistent_screen")
key "K_RIGHT" action Hide("nonexistent_screen")
key "K_UP" action Hide("nonexistent_screen")
key "K_DOWN" action Hide("nonexistent_screen")
key "K_RETURN" action Hide("nonexistent_screen")
key "K_KP_ENTER" action Hide("nonexistent_screen")
##### Timer
#
# It returns "smth" every second and "win" (if all buttons were clicked) or "lose" (if time was up)
timer 1 action [Return("smth"), If( game_timer>1, If( numbers_buttons[-1]["b_to_show"] == False, Return("win"), SetVariable("game_timer", game_timer-1) ), Return("lose") ) ] repeat True
text "[game_timer]" size 25 xpos 10 ypos 10
for each_b in sorted(numbers_buttons, reverse=True):
if each_b["b_to_show"]:
$ text_var = each_b["b_value"]
$ i = each_b["b_number"] - 1
button:
# Will show image if "b_value" was set as file name or displayable.
#background None
#add each_b["b_value"]
# Also it is neccessary to comment out the next 4 lines.
#background "image.png" # Sets button's appearance
text '[text_var]{size=18}.{/size}' size 30 align (0.5, 0.55) color "#000"
xminimum 100 xmaximum 100
yminimum 100 ymaximum 100
xpos each_b["b_x_pos"]
ypos each_b["b_y_pos"]
anchor (0.5, 0.5)
action If (i == -1, SetDict(numbers_buttons[each_b["b_number"] ], "b_to_show", False),
If (numbers_buttons[i]["b_to_show"] == False,
SetDict(numbers_buttons[each_b["b_number"] ], "b_to_show", False),
SetVariable("game_timer", game_timer-1) ) ) # Wrong click reduces the time left by 1 second
at roto_transform (renpy.random.randint (0, 10)*36)
# It might be usefull to show the order of buttons to click if it's not obvious.
side "c b":
area (150, 05, 640, 70) # The size of hint's area
viewport id "vp":
draggable True
hbox:
xalign 1.0
# The same buttons declaration, but they will be scaled down
for each_b in numbers_buttons:
$ text_var = each_b["b_value"]
button:
# Will show image if "b_value" was set as file name or displayable.
#background None
#add each_b["b_value"]
# Also it is neccessary to comment out the next 4 lines.
#background "image.png" # Sets button's appearance
text '[text_var]{size=18}.{/size}' size 30 align (0.5, 0.55) color "#000"
xminimum 100 xmaximum 100
yminimum 100 ymaximum 100
action If (each_b["b_to_show"], Hide("nonexistent_screen"), None)
at Transform(zoom=0.5) # Size
bar value XScrollValue("vp")
init:
##### Images
image img1 = "img1.png"
image img2 = "img2.png"
label numbers_game:
#####
#
# At first, let's set the values for buttons
$ numbers_buttons = []
$ buttons_values = []
# This might be numbers,
python:
for i in range (1, renpy.random.randint (10, 15) ):
buttons_values.append (str(i) )
# or letters,
#$ buttons_values = [u"а", u"б", u"в", u"г", u"д", u"е", u"ё", u"ж", u"з", u"и", u"й", u"к", u"л", u"м", u"н", u"о", u"п", u"р", u"с", u"т", u"у", u"ф", u"х", u"ц", u"ч", u"ш", u"щ", u"ъ", u"ы", u"ь", u"э", u"ю", u"я" ]
# or images,
#$ buttons_values = ["img1", "img2", "my_img.png"]
# This will make the description for all buttons (numbers, values and positions)
python:
for i in range (0, len(buttons_values) ):
numbers_buttons.append ( {"b_number":i, "b_value":buttons_values[i], "b_x_pos":(renpy.random.randint (10, 70))*10, "b_y_pos":(renpy.random.randint (15, 50))*10, "b_to_show":True} )
"To win the game - click all the buttons one after another (start from \"1\")."
# Before start the game, let's set the timer
$ game_timer = 20
# Shows the game screen
show screen numbers_scr
# The loop will exist untill game screen returns win or lose
label loop:
$ result = ui.interact()
$ game_timer = game_timer
if result == "smth":
jump loop
if result == "lose":
hide screen numbers_scr
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
"You lose! Try again."
jump numbers_game
if result == "win":
hide screen numbers_scr
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
"You win!"
return