1
# This script and the artwork associated with it, is in the
2
# public domain. Feel free to use it as the basis for your own
5
# If you're trying to understand this script, I recommend skipping
6
# down to the line beginning with 'label start:', at least on your
9
# This init block runs first, and sets up all sorts of things that
10
# are used by the rest of the game. Variables that are set in init
11
# blocks are _not_ saved, unless they are changed later on in the
16
# The version of this script.
17
$ library.script_version = (5, 6, 1)
19
# Set up the size of the screen, and the window title.
20
$ config.screen_width = 800
21
$ config.screen_height = 600
22
$ config.window_title = "The Ren'Py Demo Game"
24
# Set up the theme for this game. This must be after the
25
# library.script_version and config.screen_width lines.
28
# Set this to true to enable some developer-specific
29
# functionality. It should be false in a finished game.
30
# Read the "Developer Tools" section of the reference
31
# to see what this enables.
32
$ config.developer = True
34
# Declare the images that are used in the program.
37
image bg carillon = "carillon.jpg"
38
image bg whitehouse = "whitehouse.jpg"
39
image bg washington = "washington.jpg"
40
image bg onememorial = "1memorial.jpg"
41
image black = Solid((0, 0, 0, 255))
44
image eileen happy = "9a_happy.png"
45
image eileen vhappy = "9a_vhappy.png"
46
image eileen concerned = "9a_concerned.png"
48
# Character objects. These lets us have the character say
49
# dialogue without us having to repeatedly type her name. It also
50
# lets us change the color of her name.
51
$ e = Character(u'Eileen', color=(200, 255, 200, 255))
54
# The start label marks the place where the main menu jumps to to
55
# begin the actual game.
59
# The save_name variable sets the name of the save game. Like all
60
# variables declared outside of init blocks, this variable is
61
# saved and restored with a save file.
62
$ save_name = "Introduction"
64
# This variable is only used by our game. If it's true, it means
65
# that we won the date.
68
# Clear the game runtime timer, so it doesn't reflect time spent
69
# sitting at the main menu.
70
$ renpy.clear_game_runtime()
72
# Start some music playing in the background.
73
$ renpy.music.play('sun-flower-slow-drag.mid')
75
# Now, set up the first scene. We first fade in our washington
76
# background, and then we dissolve in the image of Eileen on top
78
scene bg washington with fade
79
show eileen vhappy with dissolve
82
# Store the current version of Ren'Py into a variable, so we can
83
# interpolate it into the next line.
84
$ version = renpy.version()
86
# Display a line of dialogue. In this case, we manually specify
87
# who's saying the line of dialogue. We also interpolate in the
88
# version of Ren'Py we're using.
89
"Girl" "Hi, and welcome to the %(version)s demo program."
91
# This instantly replaces the very happy picture of Eileen with
92
# one showing her merely happy. It demonstrates how the show
93
# statement lets characters change emotions.
96
# Another line of dialogue.
97
"Girl" "My name is Eileen, and while I hope to one day star in a
98
real game, for now I'm here to tell you about Ren'Py."
100
# This line uses the e character object, which displays Eileen's
101
# name in green. The use of a short name for a character object
102
# lets us save typing when writing the bulk of the dialogue.
103
e "Ren'Py is a language and engine for writing and playing visual
106
e "Our goal is to allow people to be able to write the script for
107
a game, and with very little effort, turn that script into
110
e "I can tell you about the features of Ren'Py games, or how to write
111
your own game. What do you want to know about?"
113
# This variable is used to save the choices that have been made in
119
# We change the save name here.
120
$ save_name = "Question Menu"
122
# This is the main menu, that lets the user decide what he wants
126
# The set menu clause ensures that each menu choice can only
130
# This is a menu choice. When chosen, the statements in its
131
# block are executed.
132
"What are some features of Ren'Py games?":
134
# We call the features label. The from clause needs to be
135
# here to ensure that save games work, even after we
136
# change the script. It was added automatically.
137
call features from _call_features_1
139
# When we're done talking about features, jump back up
144
"How do I write my own games with it?":
145
call writing from _call_writing_1
148
"Can you demonstrate more features to me?":
149
call demonstrate from _call_demonstrate_1
152
# This choice has a condition associated with it. It is only
153
# displayed if the condition is true (in this case, if we have
154
# selected at least one other choice has been chosen.)
155
"Where can I find out more?" if seen_set:
156
call find_out_more from _call_find_out_more_1
159
"Why are we in Washington, DC?":
160
call washington from _call_washington_1
163
"I think I've heard enough." if seen_set:
167
# This is the section on writing games.
170
# Change the title of the save games.
171
$ save_name = "Writing Games"
173
# We start off with a bunch of dialogue.
174
e "If you want to write a game, we recommend that you read the
175
Ren'Py reference, which you can get from our web page,
176
http://www.bishoujo.us/renpy/."
178
e "But here, we'll go over some of the basics of writing Ren'Py
179
scripts. It might make sense if you open the source for this
182
e "The source for this game can be found in the file
185
e "The goal of Ren'Py is to make writing the game similar to
186
typing up the script on the computer."
188
e "For example, a line of dialogue is expressed by putting the
189
character's name next to the dialogue string."
191
# A string by itself like this displays without a name associated
192
# with it. So it's useful for dialogue and narration.
193
"I somehow remember that strings by themselves are displayed as
194
thoughts or narration."
196
e "The menu statement makes it easy to create menus."
198
e "A number of statements let you control what is shown on the
201
# This scene statement has a with clause associated with it. In
202
# this case (based on what is defined in the init clause at the
203
# top of this script), it causes a fade to black, and then back
205
scene bg whitehouse with fade
207
e "The scene statement clears the scene list, which is the list of
208
things that are shown on the screen."
210
# This shows an image, and dissolves it in.
211
show eileen happy with dissolve
213
e "The show statement shows another image on the screen."
215
# The at clause here, displays the character on the left side of
216
# the screen. The with clause causes us to slide from the old
217
# position to the new position.
218
show eileen happy at left with move
220
e "Images can take at clauses that specify where on the screen
223
show eileen vhappy at left
225
e "Showing a new image with the same first part of the name
226
replaces the image in the scene list."
228
hide eileen with dissolve
230
e "Finally, the hide statement hides an image, which is useful
231
when a character leaves the scene."
233
show eileen happy with dissolve
235
e "Don't worry, I'm not going anywhere."
237
e "The with statement is used to cause transitions to
238
happen. Transitions like fade..."
240
# This statement hides the transient stuff from being included
244
# This with statement causes things to fade without changing the
248
e "... or dissolve ..."
250
# In this block, the scene statement clears the scene list. So we
251
# have to reshow the eileen happy image, so that it appears that
252
# just the background is dissolving. Sneaky.
258
e "... are easily invoked."
260
e "We now provide a series of user-interface functions, that allow
261
the programmer to create fairly complex interfaces."
263
e "Ren'Py also includes a number of control statements, and even
264
lets you include python code."
266
e "Rather than go into this here, you can read all about it in the
269
e "You can see a number of features in action by asking me to
270
demonstrate them at the next menu."
272
e "If you want to make changes, you can edit the script for this
273
game by editing game/script.rpy"
275
e "When you've made a change, just re-run the game to see your
278
e "Would you like to know about something else?"
280
# We return back up to the menu that lets the user pick a topic.
283
# This ends the well-commented portion of this script.
287
$ save_name = "Features"
289
e "Ren'Py provides a number of gameplay features, giving the user
290
a good experience while freeing up the game author to write his
293
e "What are some of these features? Well, first of all, we take
294
care of displaying the screen, as well as dialogue and menus."
296
e "You can navigate through the game using the keyboard or the
297
mouse. If you've gotten this far, you've probably figured that
300
e "Right-clicking or pressing escape will bring you to the game
303
e "The game menu lets you save or load the game. Ren'Py doesn't
304
limit the number of save slots available. You can create as
305
many slots as you can stand."
307
e "A preferences screen on the game menu lets you change the
308
fullscreen mode, control skipping, text speed, and
309
transitions, and turn sound and music on and off."
311
e "The game menu also lets you restart or quit the game. But you
312
wouldn't want to do that, would you?"
314
e "Finally, the game menu lets you set up the game
315
preferences. These preferences are saved between games."
319
e "The next feature is really neat."
324
"Would you like to hear about rollback?"
333
e "Rollback is a feature that only Ren'Py has. It lets you go back
336
e "For example, you can go back to a menu and save or make a
339
e "You can access it by pressing page up or scrolling up on your
342
e "Why don't you try it by going back to the last menu and
343
choosing 'No.' instead of 'Yes.'"
345
e "Press page up or scroll up the mouse wheel."
347
show eileen concerned
349
e "Well, are you going to try it?"
355
label after_rollback:
359
e "Ren'Py gives you a few ways of skipping dialogue. Pressing
360
control quickly skips dialogue you've seen at least once."
362
e "Pressing Tab toggles the skipping of dialogue you've seen at
365
e "Pressing page down or scrolling the mouse wheel down will let
366
you skip dialogue you've seen this session. This is useful
369
e "If you want to try these, you might want to rollback a bit
370
first, so you can skip over something you've seen already."
372
e "Finally, Ren'Py has predictive image loading, so you rarely
373
have to wait for a new image to load."
375
e "Remember, all these features are built into the engine or
376
standard library. So every game written with Ren'Py has them."
378
e "Is there anything else you'd like to know about?"
385
$ save_name = "Find Out More"
387
e "There are a few places you can go to find out more about
390
e "The Ren'Py homepage, http://www.bishoujo.us/renpy/, is probably
391
the best place to start."
393
e "There, you can download new versions of Ren'Py, and read the
396
e "If you have questions, the best place to ask them is the Ren'Py
397
forum of the Lemmasoft forums."
399
e "Just go to http://lemmasoft.renai.us/forums/, and click on
402
e "We thank Blue Lemma for hosting our forum."
404
e "Finally, feel free to email or IM us if you need help. You can
405
get the addresses to use from http://www.bishoujo.us/renpy/."
407
e "We really want people to make their own games with Ren'Py, and
408
if there's anything we can do to help, just tell us."
410
e "Is there anything I can help you with now?"
416
$ save_name = "Washington, DC"
418
e "We're in Washington, DC because over Summer 2004 American
419
Bishoujo's home base was just outside of DC."
422
show eileen happy at left
425
e "Even though we've moved back to New York, we took a bunch of
426
pictures, and decided to use them."
428
show eileen concerned at left
430
e "It was easier than drawing new pictures for this demo."
432
show eileen happy at left
434
e "Do you have a favorite landmark in or around DC?"
440
e "I was supposed to go on a tour of the West Wing, once."
442
show eileen concerned
444
e "They wouldn't let us in."
446
e "The secret service guy who was supposed to show us
447
around was out of town that day."
451
"The National Mall.":
453
e "It's always fun to go down to the national mall."
455
e "You can visit the monuments, or see one of the
458
e "I guess you could run out of things to do after a while
459
but I didn't over the course of a summer."
461
"The Netherlands Carillon.":
464
jump post_netherlands
468
show eileen vhappy at left
470
e "You've been to the Netherlands Carillon?"
473
show eileen vhappy at left
476
e "It may not be much to look at but the sound of the bells is
479
e "I love going there. Saturdays during the summer, they have
480
these recitals in the park where a guy comes and plays the
483
e "You can climb to the top and talk to him, if you're not afraid
486
e "Once, I saw a little girl there, maybe three or four years old.
487
The guy played the bumblebee song for here, and he even let her play the last
488
note. It was so cute!"
490
e "I haven't been there for so long."
493
"Would you like to go there sometime?":
495
e "You mean, together?"
497
e "Sure, why not. How does next Saturday sound?"
505
show eileen happy at left
509
label post_netherlands:
515
e "Anyway, is there anything else you want to know about Ren'Py?"
521
$ save_name = "Ending"
523
e "Well, that's okay."
525
e "I hope you'll consider using Ren'Py for your next game
530
e "Thanks for viewing this demo!"
533
e "And I'll see you on Saturday."
535
scene black with dissolve
537
"Ren'Py and the Ren'Py demo were written by PyTom."
539
"The character art was done by Piroshki (from the Lemmasoft forums)."
541
'The background music is "Sun Flower Slow Drag" by S. Joplin
542
(1868-1917). Thanks to the Mutopia project for making it
545
'The author would like to thank everyone who makes original
546
English-language bishoujo games, and the people on the Lemmasoft forums
549
"We can't wait to see what you do with this. Good luck!"
551
$ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
552
"It took you %(minutes)d minutes and %(seconds)d seconds to
555
$ renpy.full_restart()
565
e "Okay, I'm going to run the speedtest on your system."
567
e "I'll only be testing the performance of the dissolve
568
transition. It taxes your system the most, as it needs to
569
redraw the entire screen each frame."
571
$ frames = config.frames
578
$ frames = config.frames - frames
581
e "Well, your system displayed %(frames)d frames in five
582
seconds. That's %(fps).1f fps."
584
e "Remember, this is the worst-case speed, as usually we can just
585
draw the parts of the screen that have changed."
587
e "Thanks for viewing the secret speed test."
595
# It's bad form to change a config variable outside of an init
596
# block. We're only doing this to help test the game. Don't do
597
# it in your own game.
598
$ config.developer = True
600
"Developer mode enabled. You can now use '>' to warp to the next
603
$ config.log = "log.txt"
605
"Logging enabled. You can now find a log of this game in log.txt."
609
# Setup the secret keys for the speedtest and developer mode.
612
config.keymap['speedtest'] = [ 'S' ]
613
config.keymap['developer'] = [ 'D' ]
614
config.underlay.append(renpy.Keymap(
615
speedtest=renpy.curried_call_in_new_context('speedtest'),
616
developer=renpy.curried_call_in_new_context('developer')))
620
# This is just some example code to show the ui functions in
621
# action. You probably want to delete this (and the call to
622
# day_planner above) from your game. This code isn't really all
623
# that useful except as an example.
628
periods = [ 'Morning', 'Afternoon', 'Evening' ]
629
choices = [ 'Study', 'Exercise',
630
'Eat', 'Drink', 'Be Merry' ]
632
plan = { 'Morning' : 'Eat',
633
'Afternoon' : 'Drink',
634
'Evening' : 'Be Merry' }
639
('Strength', 100, 10),
640
('Intelligence', 100, 25),
642
('Chutzpah', 100, 75),
647
def button(text, selected, returns, **properties):
648
style='selected_button'
649
style_text='selected_button_text'
656
ui.button(clicked=ui.returns(returns),
657
style='button', role=role, **properties)
658
ui.text(text, style='button_text')
673
ui.text('Statistics')
676
for name, range, value in stats:
679
ui.text(name, minwidth=150)
680
ui.bar(range, value, ypos=0.5, yanchor='center')
688
# Period Selection Window.
697
ui.vbox(xpos=0.5, xanchor='center')
698
ui.text(day, xpos=0.5, xanchor='center', textalign=0.5)
702
face = i + ": " + plan[i]
703
button(face, editing == i, ("edit", i), xminimum=250)
706
ui.textbutton("Continue", clicked=ui.returns(("done", True)), xminimum=250)
722
ui.text("What will you do in the %s?" % editing.lower())
726
button(i, plan[editing] == i, ("set", i),
727
xpos=0, xanchor='left')
731
# Window at the bottom.
734
ui.text("To get to the next screen, click the 'Continue' button.")
737
type, value = ui.interact()
746
plan[editing] = value
752
image movie = Movie()
756
pov = DynamicCharacter("povname", color=(192, 64, 64, 255))
758
$ ectc = Character('Eileen', color=(200, 255, 200, 255),
759
ctc = anim.Blink("arrow.png"))
761
$ ectcf = Character('Eileen', color=(200, 255, 200, 255),
762
ctc = anim.Filmstrip("sakura.png", (20, 20), (2, 1), .30, xpos=760, ypos=560, xanchor=0, yanchor=0),
763
ctc_position="fixed")
765
$ equote = Character('Eileen', color=(200, 255, 200, 255),
766
who_suffix = ':', what_prefix='"', what_suffix='"')
768
$ eweird = Character('Eileen', color=(200, 255, 200, 255),
769
what_underline=True, window_left_margin=200,
772
$ etwo = Character('Eileen', color=(200, 255, 200, 255),
773
show_two_window=True)
775
$ eside = Character('Eileen', color=(200, 255, 200, 255),
776
window_left_margin=270,
777
show_side_image=Image("9a_happy.png", xalign=0.0, ypos=380))
779
image eileen animated = Animation(
780
"9a_vhappy.png", 1.0,
783
image smanim = anim.SMAnimation(
785
anim.State("r", Solid((255, 0, 0, 255))),
786
anim.State("g", Solid((0, 255, 0, 255))),
787
anim.State("b", Solid((0, 0, 255, 255))),
789
anim.Edge("r", .5, "g", dissolve),
790
anim.Edge("r", .5, "b", dissolve),
792
anim.Edge("g", .5, "r", dissolve),
793
anim.Edge("g", .5, "b", dissolve),
795
anim.Edge("b", .5, "r", dissolve),
796
anim.Edge("b", .5, "g", dissolve),
799
# There's no reason to use DynamicDisplayable here, except to test it.
800
image cyan base = DynamicDisplayable("Image('cyan.png')")
802
image cyan crop = im.Crop("cyan.png", 100, 0, 100, 200)
804
image cyan scale = im.Scale("cyan.png", 100, 100)
806
image cyan composite = im.Composite((200, 300),
809
(0, 100), "cyan.png")
811
image cyan livecomposite = LiveComposite((200, 300),
812
(0, 0), anim.Blink(Image("cyan.png")),
814
(0, 100), "cyan.png")
816
image cyan green = im.Map("cyan.png", bmap=im.ramp(0, 0))
818
image cyan green2 = im.Recolor("cyan.png", 255, 255, 0, 255)
820
image cyan alpha = im.Alpha("cyan.png", 0.5)
822
image cyan blackwhite = "blackwhite.png"
824
image cyan twocolor = im.Twocolor("blackwhite.png",
828
image eileen alpha = im.Alpha("9a_happy.png", 0.5)
830
image eileen flip = im.Flip("9a_happy.png", vertical=True)
832
$ cyanpos = Position(xpos=700, xanchor='right', ypos=100, yanchor='top')
834
$ slowcirciris = ImageDissolve("circiris.png", 5.0, 8)
835
$ circirisout = ImageDissolve("circiris.png", 1.0, 8)
836
$ circirisoutramp = ImageDissolve("circiris.png", 3.0, ramp=[ 16 * i for i in range(0, 15) + range(15, 0, -1) + range(0, 15) + range(15, 0, -1) + range(0, 15) + range(15, 0, -1) + range(0, 15) ] )
837
$ circirisin = ImageDissolve("circiris.png", 1.0, 8, reverse=True)
839
$ demotrans = ImageDissolve("demotrans.png", 3.0, 16)
841
image circiris = "circiris.png"
843
image snowblossom = SnowBlossom(anim.Filmstrip("sakura.png", (20, 20), (2, 1), .15))
845
$ renpy.register_sfont("skyfont", 22, filename="skyfont.png", default_kern=-1)
847
$ esf = Character('Eileen', color=(200, 255, 200, 255),
848
what_font="skyfont", what_size=22,
849
what_drop_shadow=(1, 1))
851
$ style.frame.background = Frame("frame.png", 12, 12)
853
$ definition = Character(None, window_yfill=True, window_xmargin=20, window_ymargin=20, window_background=Solid((0, 0, 0, 192)))
855
$ config.layers.insert(1, 'demo')
856
$ config.layer_clipping['demo'] = (50, 50, 700, 500)
864
e "I can give you a demonstration of some of the features in
865
Ren'Py, but you'll have to tell me what it is you'd like to
870
"Simple transitions, updated in 4.8.5":
872
e "Okay, I can tell you about simple transitions. We call
873
them simple because they aren't that flexible."
875
e "But don't let that get you down, since they're the
876
transitions you'll probably use the most."
883
e "The dissolve transition is probably the most useful,
884
blending one scene into another."
889
e "The fade transition fades to black, and then fades back
890
in to the new scene."
892
e "If you're going to stay at a black screen, you'll
893
probably want to use dissolve rather than fade."
900
e "The pixellate transition pixellates out the old scene,
901
switches to the new scene, and then unpixellates that."
903
e "It's probably not appropriate for most games, but we
904
think it's kind of neat."
906
e "Finally, we can point out that motions can be used as
913
$ renpy.play('punch.wav')
916
e "Hey! Pay attention."
918
e "I was about to demonstrate vpunch... well, I guess I just
921
$ renpy.play('punch.wav')
924
e "We can also shake the screen horizontally, with hpunch."
926
"ImageDissolve transitions, updated in 5.3.1.":
928
e "ImageDissolve allows us to have dissolve transitions that are
929
controlled by images."
931
e "This lets us specify very complex transitions, fairly
934
e "Let's try some, and then I'll show how they work."
936
e "There are two ImageDissolve transitions present by
937
default in the standard library."
939
scene black with blinds
944
e "The blinds transition opens and closes what looks like
947
scene black with squares
952
e "The squares transition uses these squares to show
955
e "I'm not sure why anyone would want to use it, but it
956
was used in some translated games, so we added it."
958
e "There are also a few transitions that aren't in the
961
e "These ones require images the size of the screen, and
962
so we couldn't include them as the size of the screen
963
can change from game to game."
965
e "You can find them defined in the source of the demo
968
scene black with circirisin
970
e "We can hide things with a circirisin..."
976
e "... and show them again with a circirisout."
978
e "The ramp parameter lets things dissolve in and out
981
scene bg whitehouse with circirisoutramp
983
e "It's even possible to have weird custom transitions."
985
scene circiris with demotrans
987
e "What we're showing here is the picture that's used in
988
the circiris transitions."
990
e "If you take a look, the center of it is white, while
991
the edges are darker."
993
e "When we use an ImageDissolve, the white will dissolve
994
in first, followed by progressively darker colors."
1004
e "It's also possible to reverse the transition, so that
1005
the black pixels are dissolved in first."
1007
"CropMove transitions, added in 4.5.":
1009
e "The CropMove transition class lets us provide a wide
1010
range of transition effects."
1012
hide eileen with dissolve
1014
e "I'll stand offscreen, so you can see some of its modes. I'll read
1015
out the mode name after each transition."
1017
scene bg whitehouse with wiperight
1019
e "We first have wiperight..."
1021
scene bg washington with wipeleft
1023
e "...followed by wipeleft... "
1025
scene bg whitehouse with wipeup
1029
scene bg washington with wipedown
1031
e "...and wipedown."
1033
e "Next, the slides."
1035
scene bg whitehouse with slideright
1039
scene bg washington with slideleft
1043
scene bg whitehouse with slideup
1047
scene bg washington with slidedown
1051
e "While the slide transitions slide in the new scene, the
1052
slideaways slide out the old scene."
1054
scene bg whitehouse with slideawayright
1056
e "Slideawayright..."
1058
scene bg washington with slideawayleft
1060
e "...slideawayleft..."
1062
scene bg whitehouse with slideawayup
1064
e "...slideawayup..."
1066
scene bg washington with slideawaydown
1068
e "and slideawaydown."
1070
e "We also have a couple of transitions that use a
1073
scene bg whitehouse with irisout
1075
e "There's irisout..."
1084
e "It's enough to make you feel a bit dizzy."
1086
"Positions and movement, updated in 5.6.0.":
1088
e "I'm not stuck standing in the middle of the screen,
1089
even though I like being the center of attention."
1091
e "Positions, given with an at clause, specify where I'm
1094
e "The move transition moves around images that have
1099
show eileen happy at offscreenleft with move
1101
e "I can move over to the offscreenleft position, just off
1102
the left side of the screen."
1104
show eileen happy at left with move
1106
e "The left position has my left side border the left
1107
margin of the screen."
1109
show eileen happy at center with move
1111
e "I can also move to the center..."
1113
show eileen happy at right with move
1115
e "... the right ..."
1117
show eileen happy at offscreenright with move
1119
e "... or even to offscreenright, off the right-hand side
1122
show eileen happy at right with move
1124
e "We don't limit you to these five positions either. You
1125
can always create your own Position objects."
1127
# This is necessary to restart the time at which we are
1131
show eileen happy at Move((1.0, 1.0, 'right', 'bottom'),
1132
(0.0, 1.0, 'left', 'bottom'),
1133
4.0, repeat=True, bounce=True)
1135
e "It's also possible to have a movement happen while
1136
showing dialogue on the screen, using the Move function."
1138
e "Move can repeat a movement, and even have it bounce
1139
back and forth, like I'm doing now."
1141
scene bg onememorial at Pan((0, 800), (0, 0), 10.0) with dissolve
1143
e "We can pan around an image larger than the
1144
screen, using the Pan function in an at
1147
e "That's what we're doing now, panning up a picture of
1148
the memorial to the Big Red One."
1150
scene bg whitehouse with dissolve
1151
scene bg whitehouse at Zoom((800, 600), (0, 0, 800, 600), (225, 150, 400, 300), 1.0)
1153
e "We can zoom into images..."
1155
scene bg whitehouse at Zoom((800, 600), (225, 150, 400, 300), (0, 0, 800, 600), 1.0)
1157
e "... and zoom back out of them again."
1160
show eileen happy at FactorZoom(1.0, 0.5, 1.0, opaque=False), center
1162
e "We can also zoom images by a factor..."
1164
show eileen happy at FactorZoom(0.5, 1.0, 1.0, opaque=False), center
1166
e "... and zoom {i}them{/i} out again."
1176
e "Finally, there's now a particle motion system in
1179
e "It can be used to animate things like falling cherry
1180
blossoms, falling snow, and rising bubbles."
1182
e "While there's convenient support for things rising and
1183
falling in straight lines, it's also possible to define
1186
e "The sky's the limit."
1188
e "Or the ground, in the case of these cherry blossoms."
1190
hide snowblossom with dissolve
1192
"Animation, updated in 4.8.5":
1194
e "Ren'Py supports a number of ways of creating
1197
e "These animations let you vary images, independent of
1200
show eileen animated
1202
e "For example, I'm switching my expression back and
1203
forth, once a second."
1205
e "Even though you clicked, I'm still doing it."
1207
e "This is an example of the Animation function at work."
1211
e "The Animation function is limited to simple lists of
1212
images, with fixed delays between them."
1214
e "The sequence can repeat, or can stop after one
1217
e "If you want more control, you can use the
1218
anim.SMAnimation function."
1220
e "It can randomly change images, and even apply
1221
transitions to changes."
1228
e "Here, we randomly dissolve the background between red,
1229
green, and blue images."
1238
e "It's probably best if we stop here, before somebody's
1241
"Fonts and Text Tags, updated in 5.5.1.":
1243
e "Text tags let us control the appearance of text that is
1246
e "Text tags can make text {b}bold{/b}, {i}italic{/i}, or
1249
e "They can make the font size {size=+12}bigger{/size} or
1250
{size=-8}smaller{/size}."
1252
e "They let you pause{w} the display of the text,
1253
optionally with{p}line breaks."
1255
e "They let you include {image=slider_idle.png} images
1258
e "They can even change the
1259
{color=#f00}color{/color}
1260
{color=#ff0}of{/color}
1261
{color=#0f0}the{/color}
1262
{color=#0ff}text{/color}."
1264
e "There are also bold, italic, and underline style properties, which can
1265
be styled onto any text."
1267
e "{a=define_hyperlink}Hyperlinks{/a} let buttons be
1268
defined as using text tags."
1270
e "If you find yourself using text tags on every line, you
1271
should probably look at style properties instead."
1273
e "Used with care, text tags can enhance {b}your{/b} game."
1275
e "{u}Used{/u} with {i}abandon,{/i} they {b}can{/b} make {b}your{/b}
1276
game {color=#333}hard{/color} {color=#888}to{/color} {color=#ccc}read{/color}."
1278
e "With great power comes great responsibility, after all."
1280
e "And we want to give you all the power you need."
1282
esf "For even more control, Ren'Py supports SFonts."
1284
esf "An SFont is an image file containing font
1287
esf "SFonts let you use fonts you otherwise couldn't, and
1288
apply special effects to fonts... like I'm doing
1291
e "We recommend keeping your usual font simple and readable."
1293
esf "Not like this one."
1295
"Music, sound and movies, updated in 4.5.":
1297
e "Ren'Py supports a number of multimedia functions."
1299
e "You're probably hearing music playing in the
1303
$ renpy.music_stop(fadeout=0.5)
1304
e "We can stop it..."
1307
$ renpy.music_start('sun-flower-slow-drag.mid')
1308
e "... and start it playing again."
1310
# This plays a sound effect.
1311
$ renpy.play("18005551212.ogg")
1313
e "We can also play up to eight channels of sound effects
1314
on top of the music."
1316
e "We ship, in the extras/ directory, code to support
1317
characters having voice."
1319
e "Finally, we support playing mpeg movies."
1321
if renpy.exists('Eisenhow1952.mpg'):
1323
e "Since you downloaded the Eisenhower commercial, I can show
1324
it to you as a cutscene."
1326
e "You can click to continue if it gets on your nerves too
1329
$ renpy.movie_cutscene('Eisenhow1952.mpg', 63.0)
1332
show movie at Position(xpos=420, ypos=25, xanchor='left', yanchor='top')
1335
$ renpy.movie_start_displayable('Eisenhow1952.mpg', (352, 240))
1337
e "Ren'Py can even overlay rendered images on top of a movie,
1338
although that's more taxing for your CPU."
1340
e "It's like I'm some sort of newscaster or something."
1342
$ renpy.movie_stop()
1345
$ renpy.music_start('sun-flower-slow-drag.mid')
1349
e "You haven't downloaded the Eisenhower commercial, so we
1350
can't demonstrate it."
1352
e "That's it for multimedia."
1354
"Image Operations, updated in 5.6.0":
1356
e "Image operations allow one to manipulate images as they
1359
e "These are efficient, as they are only evaluated when an
1360
image is first loaded."
1362
e "This way, there's no extra work that needs to be done
1363
when each frame is drawn to the screen."
1365
show eileen happy at left with move
1366
show cyan base at cyanpos with dissolve
1368
e "Let me show you a test image, a simple cyan circle."
1370
e "We'll be applying some image operations to it, to see
1371
how they can be used."
1373
show cyan crop at cyanpos with dissolve
1375
e "The im.Crop operation can take the image, and chop it
1376
up into a smaller image."
1378
show cyan composite at cyanpos with dissolve
1380
e "The im.Composite operation lets us take multiple images,
1381
and draw them into a single image."
1383
e "While you can do this by showing multiple images, this
1384
is more efficent, if more complex."
1386
show cyan livecomposite at cyanpos with dissolve
1388
e "There's also LiveComposite, which is less efficent, but
1389
allows for animation."
1391
e "It isn't really an image operation, but we don't know
1392
where else to put it."
1394
show cyan scale at cyanpos with dissolve
1396
e "The im.Scale operation lets us change the size of images."
1398
show cyan green at cyanpos with dissolve
1400
e "The im.Map operation lets us mess with the red, green,
1401
blue, and alpha channels of an image."
1403
e "In this case, we removed all the blue from the image,
1404
leaving only the green component of cyan."
1406
show cyan base at cyanpos with dissolve
1407
show cyan green2 at cyanpos with dissolve
1409
e "The im.Recolor operation can do the same thing, but is more
1410
efficient when we're linearly mapping colors."
1412
show cyan blackwhite at cyanpos with dissolve
1414
e "The im.Twocolor operation lets you take a black and white image, like this one..."
1416
show cyan twocolor at cyanpos with dissolve
1418
e "... and assign colors to replace black and white."
1420
show cyan base at cyanpos with dissolve
1421
show cyan alpha at cyanpos with dissolve
1423
e "The im.Alpha operation can adjust the alpha channel on
1424
an image, making things partially transparent."
1426
show eileen alpha at left with dissolve
1428
e "It's useful if a character just happens to be ghost."
1432
show eileen happy at left
1435
e "But that's not the case with me."
1437
show eileen happy with move
1439
show eileen flip with dissolve
1441
e "Finally, there's im.Flip, which can flip an image horizontally or vertically."
1443
e "I think the less I say about this, the better."
1445
show eileen happy with dissolve
1448
"User interaction, updated in 5.5.0":
1450
e "Ren'Py gives a number of ways of interacting with the
1453
e "You've already seen say statements and menus."
1457
e "But were you aware that you can have dialogue and
1458
menus onscreen at the same time?"
1470
e "Well, now you know."
1472
e "We can also prompt the user to enter some text."
1474
$ povname = renpy.input("What is your name?")
1476
pov "My name is %(povname)s."
1479
e "Imagemaps let the user click on an image to make a
1482
# This is an imagemap. It consists of two images, and a list of
1483
# hotspots. For each hotspot we give the coordinates of the left,
1484
# top, right, and bottom sides, and the value to return if it is
1487
$ result = renpy.imagemap("ground.png", "selected.png", [
1488
(100, 100, 300, 400, "eileen"),
1489
(500, 100, 700, 400, "lucy")
1492
# We've assigned the chosen result from the imagemap to the
1493
# result variable. We can use an if statement to vary what
1494
# happens based on the user's choice.
1496
if result == "eileen":
1500
elif result == "lucy":
1501
show eileen concerned
1502
e "It looks like you picked Lucy."
1504
# Eileen is being a bit possesive here. :-P
1506
e "You can forget about Saturday."
1511
e "While these constructs are probably enough for most
1512
visual novels, dating simulations may be more
1515
e "The ui functions allow you to create quite complicated
1518
e "For example, try the following scheduling and stats screen,
1519
which could be used by a stat-based dating simulation."
1523
e "The ui functions can be used to rewrite many parts of
1526
e "Hopefully, this gives you enough power to write any
1527
visual novel you want."
1529
"Character Objects, updated in 5.6.0.":
1531
e "The Character object is used to declare characters, and
1532
it can also be used to customize things about how a
1535
e "By supplying it with the appropriate arguments, we can
1536
really change around the feel of the game."
1538
e "In this section, we'll demonstrate some of what can be
1539
accomplished by customizing character objects."
1541
equote "By supplying what_prefix and what_suffix arguments
1542
to a Character object, we can automatically add
1543
things before each line of text."
1545
equote "This is a lot easier than having to put those
1548
equote "We can also use who_prefix and who_suffix to
1549
add text to the name of the speaker."
1551
e "We can also supply arguments to the Character
1552
object that customize the look of the character
1553
name, the text that is being said, and the window
1556
eweird "These can really change the look of the game."
1558
eside "A more practical use of that is in conjunction with
1559
show_side_image, which lets us position an image next
1562
etwo "There's also show_two_window, which puts the character's
1563
name in its own window."
1565
ectc "Finally, we demonstrate a click to continue
1566
indicator. In this example, it's nestled in with the
1569
ectc "This also demonstrates the use of the anim.Blink
1572
ectcf "A click to continue image can also be placed at a
1573
fixed location on the screen."
1575
e "That's it for now."
1577
"Layers and Advanced Show, added in 5.6.0.":
1579
e "Ren'Py lets you define layers, and show images on
1585
show bg whitehouse onlayer demo
1588
show eileen happy onlayer demo
1591
e "The \"onlayer\" clause of the scene, show, and hide
1592
statements lets us pick which layers the commands
1595
e "As you can see, layers do not have to take up the
1596
entire screen. When a layer doesn't, images are
1597
clipped to the layer."
1603
e "The \"as\" clause lets you change the tag of an image."
1605
show eileen happy as eileen2
1608
show eileen happy at left
1609
show eileen happy at right as eileen2
1612
e "This is useful when you want to show two copies of the
1615
e "Or if a character has a twin."
1617
show eileen happy at center
1618
show eileen happy at offscreenright as eileen2
1623
show expression Text("This is text.", size=50, yalign=0.5, xalign=0.5, drop_shadow=(2, 2)) as text
1626
e "You can use \"show expression\" to show things that
1627
aren't just images, like text."
1632
show eileen happy zorder 2
1633
show cyan base at Position(xalign=0.6, yalign=0.0) zorder 1
1636
e "Finally, the \"zorder\" clause lets you place an image behind
1643
e "And that's it for layers and advanced show."
1647
"" # Empty, so we have a blank line.
1649
"That's enough for me.":
1651
e "Is there anything else you'd like to ask?"
1655
e "Is there anything else you want demonstrated?"
1660
label define_hyperlink:
1662
definition "A hyperlink is a button that is defined inside text, using
1663
text tags. They're ideal for including definitions of words
1664
used in the script, but they shouldn't be used in place of
1669
# Here, are a number of customizations that make the game look
1670
# better. We place them down here at the bottom, to make the first few
1671
# lines of the script look better.
1673
# These can be deleted without issue, if you do not want them.
1677
# Change the look of the main menu.
1678
$ style.mm_root.background = Image("mainmenu.jpg")
1679
$ style.mm_menu_window.yanchor = 0
1680
$ style.mm_menu_window.ypos = .05
1682
# Change the look of the text window.
1683
$ style.window.background = Frame("window.png", 16, 16)
1684
$ style.window.xmargin = 0
1685
$ style.window.ymargin = 0
1686
$ style.window.xpadding = 12
1687
$ style.window.top_padding = 6
1688
$ style.window.bottom_padding = 12
1690
# Interface sounds, just for the heck of it.
1691
$ style.button.activate_sound = 'click.wav'
1692
$ style.imagemap.activate_sound = 'click.wav'
1693
$ library.enter_sound = 'click.wav'
1694
$ library.exit_sound = 'click.wav'
1695
$ library.sample_sound = "18005551212.ogg"
1697
# Select the transitions that are used when entering and exiting
1699
$ library.enter_transition = pixellate
1700
$ library.exit_transition = pixellate
1703
# The splashscreen is called, if it exists, before the main menu is
1704
# shown the first time. It is not called if the game has restarted.
1706
# We'll comment it out for now.
1708
# label splashscreen:
1710
# show text "American Bishoujo Presents..." with dissolve
1711
# $ renpy.pause(1.0)
1712
# hide text with dissolve
1717
$ MicroLayer = renpy.curry(Fixed)
1724
store.hovered_text = ""
1726
def mybutton(text, hovered_text, clicked):
1728
def hovered(hovered_text=hovered_text):
1730
if store.hovered_text == hovered_text:
1733
store.hovered_text = hovered_text
1734
renpy.restart_interaction()
1738
ui.textbutton(text, hovered=hovered, clicked=clicked)
1742
mybutton("Foo", "You're hovering the foo button.", ui.returns(1))
1743
mybutton("Bar", "You're hovering the bar button.", ui.returns(2))
1744
mybutton("Baz", "You're hovering the baz button.", ui.returns(3))
1747
ui.add(DynamicDisplayable("Text(store.hovered_text)"))