~vbkaisetsu/+junk/renpy-vertical-text

« back to all changes in this revision

Viewing changes to demo/game/script.rpy

  • Committer: tom
  • Date: 2006-10-01 14:09:56 UTC
  • Revision ID: svn-v3-trunk1:a20cb6e2-ff0c-0410-a951-e6c088e16c52:renpy%2Ftrunk:148

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
3
# game.
 
4
 
 
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
 
7
# first read-through.
 
8
 
 
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
 
12
# program.
 
13
 
 
14
init:
 
15
    
 
16
    # The version of this script.
 
17
    $ library.script_version = (5, 6, 1)
 
18
 
 
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"
 
23
 
 
24
    # Set up the theme for this game. This must be after the
 
25
    # library.script_version and config.screen_width lines.
 
26
    $ theme.roundrect()
 
27
 
 
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
 
33
 
 
34
    # Declare the images that are used in the program.
 
35
 
 
36
    # Backgrounds.
 
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))
 
42
 
 
43
    # Character pictures.
 
44
    image eileen happy = "9a_happy.png"
 
45
    image eileen vhappy = "9a_vhappy.png"
 
46
    image eileen concerned = "9a_concerned.png"
 
47
 
 
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))
 
52
 
 
53
 
 
54
# The start label marks the place where the main menu jumps to to
 
55
# begin the actual game.
 
56
 
 
57
label start:
 
58
 
 
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"
 
63
 
 
64
    # This variable is only used by our game. If it's true, it means
 
65
    # that we won the date.
 
66
    $ date = False
 
67
 
 
68
    # Clear the game runtime timer, so it doesn't reflect time spent
 
69
    # sitting at the main menu.
 
70
    $ renpy.clear_game_runtime()        
 
71
 
 
72
    # Start some music playing in the background.
 
73
    $ renpy.music.play('sun-flower-slow-drag.mid')
 
74
 
 
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
 
77
    # of it.
 
78
    scene bg washington with fade
 
79
    show eileen vhappy with dissolve
 
80
 
 
81
 
 
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()
 
85
 
 
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."
 
90
 
 
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.
 
94
    show eileen happy
 
95
  
 
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."
 
99
 
 
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
 
104
       novel games."
 
105
 
 
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
 
108
       a working game."
 
109
 
 
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?"
 
112
 
 
113
    # This variable is used to save the choices that have been made in
 
114
    # the main menu.
 
115
    $ seen_set = [ ]
 
116
 
 
117
label choices:
 
118
 
 
119
    # We change the save name here.
 
120
    $ save_name = "Question Menu"
 
121
 
 
122
    # This is the main menu, that lets the user decide what he wants
 
123
    # to hear about.
 
124
    menu:
 
125
 
 
126
        # The set menu clause ensures that each menu choice can only
 
127
        # be chosen once.
 
128
        set seen_set
 
129
 
 
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?":
 
133
 
 
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
 
138
 
 
139
            # When we're done talking about features, jump back up
 
140
            # to choices.
 
141
            jump choices
 
142
 
 
143
        # Another choice. 
 
144
        "How do I write my own games with it?":
 
145
            call writing from _call_writing_1
 
146
            jump choices
 
147
 
 
148
        "Can you demonstrate more features to me?":
 
149
            call demonstrate from _call_demonstrate_1
 
150
            jump choices
 
151
 
 
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
 
157
            jump choices
 
158
 
 
159
        "Why are we in Washington, DC?":
 
160
            call washington from _call_washington_1
 
161
            jump choices
 
162
 
 
163
        "I think I've heard enough." if seen_set:
 
164
            jump ending
 
165
 
 
166
 
 
167
# This is the section on writing games.
 
168
label writing:
 
169
 
 
170
    # Change the title of the save games.
 
171
    $ save_name = "Writing Games"
 
172
 
 
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/."
 
177
 
 
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
 
180
       game."
 
181
 
 
182
    e "The source for this game can be found in the file
 
183
       game/script.rpy."
 
184
 
 
185
    e "The goal of Ren'Py is to make writing the game similar to
 
186
       typing up the script on the computer."
 
187
 
 
188
    e "For example, a line of dialogue is expressed by putting the
 
189
       character's name next to the dialogue string."
 
190
 
 
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."
 
195
    
 
196
    e "The menu statement makes it easy to create menus."
 
197
 
 
198
    e "A number of statements let you control what is shown on the
 
199
       screen."
 
200
 
 
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
 
204
    # to the new scene.
 
205
    scene bg whitehouse with fade
 
206
 
 
207
    e "The scene statement clears the scene list, which is the list of
 
208
       things that are shown on the screen."
 
209
 
 
210
    # This shows an image, and dissolves it in.
 
211
    show eileen happy with dissolve
 
212
 
 
213
    e "The show statement shows another image on the screen."
 
214
 
 
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
 
219
 
 
220
    e "Images can take at clauses that specify where on the screen
 
221
       they are shown."
 
222
 
 
223
    show eileen vhappy at left
 
224
 
 
225
    e "Showing a new image with the same first part of the name
 
226
       replaces the image in the scene list."
 
227
 
 
228
    hide eileen with dissolve
 
229
 
 
230
    e "Finally, the hide statement hides an image, which is useful
 
231
       when a character leaves the scene."
 
232
 
 
233
    show eileen happy with dissolve
 
234
 
 
235
    e "Don't worry, I'm not going anywhere."
 
236
 
 
237
    e "The with statement is used to cause transitions to
 
238
       happen. Transitions like fade..."
 
239
 
 
240
    # This statement hides the transient stuff from being included
 
241
    # in the next fade.
 
242
    with None
 
243
 
 
244
    # This with statement causes things to fade without changing the
 
245
    # scene.
 
246
    with fade
 
247
 
 
248
    e "... or dissolve ..."
 
249
 
 
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.
 
253
    with None
 
254
    scene bg washington
 
255
    show eileen happy
 
256
    with dissolve
 
257
 
 
258
    e "... are easily invoked."
 
259
 
 
260
    e "We now provide a series of user-interface functions, that allow
 
261
       the programmer to create fairly complex interfaces."
 
262
 
 
263
    e "Ren'Py also includes a number of control statements, and even
 
264
       lets you include python code."
 
265
 
 
266
    e "Rather than go into this here, you can read all about it in the
 
267
       reference."
 
268
 
 
269
    e "You can see a number of features in action by asking me to
 
270
       demonstrate them at the next menu."
 
271
 
 
272
    e "If you want to make changes, you can edit the script for this
 
273
       game by editing game/script.rpy"
 
274
 
 
275
    e "When you've made a change, just re-run the game to see your
 
276
       change in action."
 
277
 
 
278
    e "Would you like to know about something else?"
 
279
 
 
280
    # We return back up to the menu that lets the user pick a topic.
 
281
    return
 
282
 
 
283
# This ends the well-commented portion of this script.
 
284
 
 
285
label features:
 
286
 
 
287
    $ save_name = "Features"
 
288
 
 
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
 
291
       game."
 
292
 
 
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."
 
295
 
 
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
 
298
       out already."
 
299
 
 
300
    e "Right-clicking or pressing escape will bring you to the game
 
301
       menu."
 
302
 
 
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."
 
306
 
 
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."
 
310
 
 
311
    e "The game menu also lets you restart or quit the game. But you
 
312
       wouldn't want to do that, would you?"
 
313
 
 
314
    e "Finally, the game menu lets you set up the game
 
315
       preferences. These preferences are saved between games."
 
316
 
 
317
    show eileen vhappy
 
318
 
 
319
    e "The next feature is really neat."
 
320
 
 
321
    show eileen happy
 
322
 
 
323
    menu rollback_menu:
 
324
        "Would you like to hear about rollback?"
 
325
        
 
326
        "Yes.":
 
327
            pass
 
328
 
 
329
        "No.":
 
330
            jump after_rollback
 
331
 
 
332
 
 
333
    e "Rollback is a feature that only Ren'Py has. It lets you go back
 
334
       in time in a game."
 
335
 
 
336
    e "For example, you can go back to a menu and save or make a
 
337
       different choice."
 
338
 
 
339
    e "You can access it by pressing page up or scrolling up on your
 
340
       mouse wheel."
 
341
 
 
342
    e "Why don't you try it by going back to the last menu and
 
343
       choosing 'No.' instead of 'Yes.'"
 
344
 
 
345
    e "Press page up or scroll up the mouse wheel."
 
346
 
 
347
    show eileen concerned
 
348
 
 
349
    e "Well, are you going to try it?"
 
350
 
 
351
    e "Your loss."
 
352
 
 
353
    e "Moving on."
 
354
 
 
355
label after_rollback:
 
356
 
 
357
    show eileen happy
 
358
    
 
359
    e "Ren'Py gives you a few ways of skipping dialogue. Pressing
 
360
       control quickly skips dialogue you've seen at least once."
 
361
 
 
362
    e "Pressing Tab toggles the skipping of dialogue you've seen at
 
363
       least once."
 
364
 
 
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
 
367
       after a rollback."
 
368
 
 
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."
 
371
 
 
372
    e "Finally, Ren'Py has predictive image loading, so you rarely
 
373
       have to wait for a new image to load."
 
374
 
 
375
    e "Remember, all these features are built into the engine or
 
376
       standard library. So every game written with Ren'Py has them."
 
377
 
 
378
    e "Is there anything else you'd like to know about?"
 
379
    
 
380
    return
 
381
 
 
382
 
 
383
label find_out_more:
 
384
 
 
385
    $ save_name = "Find Out More"
 
386
 
 
387
    e "There are a few places you can go to find out more about
 
388
       Ren'Py."
 
389
 
 
390
    e "The Ren'Py homepage, http://www.bishoujo.us/renpy/, is probably
 
391
       the best place to start."
 
392
 
 
393
    e "There, you can download new versions of Ren'Py, and read the
 
394
       tutorial online."
 
395
 
 
396
    e "If you have questions, the best place to ask them is the Ren'Py
 
397
       forum of the Lemmasoft forums."
 
398
 
 
399
    e "Just go to http://lemmasoft.renai.us/forums/, and click on
 
400
       Ren'Py."
 
401
 
 
402
    e "We thank Blue Lemma for hosting our forum."
 
403
 
 
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/."
 
406
 
 
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."
 
409
 
 
410
    e "Is there anything I can help you with now?"
 
411
 
 
412
    return
 
413
 
 
414
label washington:
 
415
 
 
416
    $ save_name = "Washington, DC"
 
417
 
 
418
    e "We're in Washington, DC because over Summer 2004 American
 
419
       Bishoujo's home base was just outside of DC."
 
420
 
 
421
    scene bg whitehouse
 
422
    show eileen happy at left
 
423
    with fade
 
424
 
 
425
    e "Even though we've moved back to New York, we took a bunch of
 
426
       pictures, and decided to use them."
 
427
 
 
428
    show eileen concerned at left
 
429
 
 
430
    e "It was easier than drawing new pictures for this demo."
 
431
 
 
432
    show eileen happy at left
 
433
    
 
434
    e "Do you have a favorite landmark in or around DC?"
 
435
 
 
436
    menu:
 
437
 
 
438
        "The White House.":
 
439
 
 
440
            e "I was supposed to go on a tour of the West Wing, once."
 
441
 
 
442
            show eileen concerned
 
443
 
 
444
            e "They wouldn't let us in."
 
445
 
 
446
            e "The secret service guy who was supposed to show us
 
447
               around was out of town that day."
 
448
 
 
449
            e "Too bad."
 
450
 
 
451
        "The National Mall.":
 
452
 
 
453
            e "It's always fun to go down to the national mall."
 
454
 
 
455
            e "You can visit the monuments, or see one of the
 
456
               museums."
 
457
 
 
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."
 
460
            
 
461
        "The Netherlands Carillon.":
 
462
            jump netherlands
 
463
            
 
464
    jump post_netherlands
 
465
 
 
466
label netherlands:
 
467
 
 
468
    show eileen vhappy at left
 
469
 
 
470
    e "You've been to the Netherlands Carillon?"
 
471
 
 
472
    scene bg carillon
 
473
    show eileen vhappy at left
 
474
    with dissolve
 
475
 
 
476
    e "It may not be much to look at but the sound of the bells is
 
477
       really neat."
 
478
 
 
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 
 
481
       bells live."
 
482
 
 
483
    e "You can climb to the top and talk to him, if you're not afraid
 
484
       of heights."
 
485
 
 
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!"
 
489
 
 
490
    e "I haven't been there for so long."
 
491
 
 
492
    menu:
 
493
        "Would you like to go there sometime?":
 
494
 
 
495
            e "You mean, together?"
 
496
 
 
497
            e "Sure, why not. How does next Saturday sound?"
 
498
            
 
499
            e "It's a date."
 
500
 
 
501
            $ date = True
 
502
 
 
503
        "That sounds nice.":
 
504
 
 
505
            show eileen happy at left
 
506
 
 
507
            e "Well, it is."
 
508
        
 
509
label post_netherlands:
 
510
 
 
511
    scene bg washington
 
512
    show eileen happy
 
513
    with fade
 
514
 
 
515
    e "Anyway, is there anything else you want to know about Ren'Py?"
 
516
 
 
517
    return
 
518
 
 
519
label ending:
 
520
 
 
521
    $ save_name = "Ending"
 
522
 
 
523
    e "Well, that's okay."
 
524
 
 
525
    e "I hope you'll consider using Ren'Py for your next game
 
526
       project."
 
527
 
 
528
    show eileen vhappy
 
529
 
 
530
    e "Thanks for viewing this demo!"
 
531
 
 
532
    if date:
 
533
        e "And I'll see you on Saturday."
 
534
    
 
535
    scene black with dissolve
 
536
 
 
537
    "Ren'Py and the Ren'Py demo were written by PyTom."
 
538
 
 
539
    "The character art was done by Piroshki (from the Lemmasoft forums)."
 
540
 
 
541
    'The background music is "Sun Flower Slow Drag" by S. Joplin
 
542
     (1868-1917). Thanks to the Mutopia project for making it
 
543
       available.'
 
544
 
 
545
    'The author would like to thank everyone who makes original
 
546
     English-language bishoujo games, and the people on the Lemmasoft forums
 
547
     who encouraged him.'
 
548
 
 
549
    "We can't wait to see what you do with this. Good luck!"
 
550
 
 
551
    $ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
 
552
    "It took you %(minutes)d minutes and %(seconds)d seconds to
 
553
     finish this demo."
 
554
       
 
555
    $ renpy.full_restart()
 
556
 
 
557
 
 
558
label speedtest:
 
559
 
 
560
    with None
 
561
    scene bg whitehouse
 
562
    show eileen happy
 
563
    with dissolve
 
564
 
 
565
    e "Okay, I'm going to run the speedtest on your system."
 
566
 
 
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."
 
570
 
 
571
    $ frames = config.frames
 
572
 
 
573
    with None
 
574
    scene bg washington
 
575
    show eileen happy
 
576
    with Dissolve(5.0)
 
577
 
 
578
    $ frames = config.frames - frames
 
579
    $ fps = frames / 5.0
 
580
 
 
581
    e "Well, your system displayed %(frames)d frames in five
 
582
       seconds. That's %(fps).1f fps."
 
583
 
 
584
    e "Remember, this is the worst-case speed, as usually we can just
 
585
       draw the parts of the screen that have changed."
 
586
 
 
587
    e "Thanks for viewing the secret speed test."
 
588
 
 
589
    return
 
590
 
 
591
label developer:
 
592
 
 
593
    scene black
 
594
 
 
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
 
599
 
 
600
    "Developer mode enabled. You can now use '>' to warp to the next
 
601
     menu."
 
602
 
 
603
    $ config.log = "log.txt"
 
604
 
 
605
    "Logging enabled. You can now find a log of this game in log.txt."
 
606
 
 
607
    return
 
608
    
 
609
# Setup the secret keys for the speedtest and developer mode.
 
610
init:
 
611
    python:
 
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')))
 
617
 
 
618
init:
 
619
 
 
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.
 
624
    
 
625
    python:
 
626
        def day_planner():
 
627
 
 
628
            periods = [ 'Morning', 'Afternoon', 'Evening' ]
 
629
            choices = [ 'Study', 'Exercise',
 
630
                        'Eat', 'Drink', 'Be Merry' ]
 
631
 
 
632
            plan = { 'Morning' : 'Eat',
 
633
                     'Afternoon' : 'Drink',
 
634
                     'Evening' : 'Be Merry' }
 
635
 
 
636
            day = 'March 25th'
 
637
 
 
638
            stats = [
 
639
                ('Strength', 100, 10),
 
640
                ('Intelligence', 100, 25),
 
641
                ('Moxie', 100, 100),
 
642
                ('Chutzpah', 100, 75),
 
643
                ]
 
644
 
 
645
            editing = None
 
646
 
 
647
            def button(text, selected, returns, **properties):
 
648
                style='selected_button'
 
649
                style_text='selected_button_text'
 
650
                    
 
651
                if selected:
 
652
                    role='selected_'
 
653
                else:
 
654
                    role=''
 
655
 
 
656
                ui.button(clicked=ui.returns(returns),
 
657
                          style='button', role=role, **properties)
 
658
                ui.text(text, style='button_text')
 
659
 
 
660
 
 
661
            while True:
 
662
 
 
663
                # Stats Window
 
664
                ui.frame(xpos=0,
 
665
                         ypos=0,
 
666
                         xanchor='left',
 
667
                         yanchor='top',
 
668
                         xfill=True,
 
669
                         )
 
670
 
 
671
                ui.vbox()
 
672
 
 
673
                ui.text('Statistics')
 
674
                ui.null(height=20)
 
675
 
 
676
                for name, range, value in stats:
 
677
 
 
678
                    ui.hbox()
 
679
                    ui.text(name, minwidth=150)
 
680
                    ui.bar(range, value, ypos=0.5, yanchor='center')
 
681
                    ui.close()
 
682
 
 
683
                ui.close()
 
684
                
 
685
                
 
686
 
 
687
            
 
688
                # Period Selection Window.
 
689
                ui.frame(xpos=0,
 
690
                         ypos=200,
 
691
                         xanchor='left',
 
692
                         yanchor='top',
 
693
                         xfill=False,
 
694
                         xminimum=300
 
695
                         )
 
696
                
 
697
                ui.vbox(xpos=0.5, xanchor='center')
 
698
                ui.text(day, xpos=0.5, xanchor='center', textalign=0.5)
 
699
                ui.null(height=20)
 
700
                
 
701
                for i in periods:
 
702
                    face = i + ": " + plan[i]
 
703
                    button(face, editing == i, ("edit", i), xminimum=250)
 
704
 
 
705
                ui.null(height=20)
 
706
                ui.textbutton("Continue", clicked=ui.returns(("done", True)), xminimum=250)
 
707
                ui.null(height=20)
 
708
                ui.close()
 
709
 
 
710
 
 
711
                # Choice window.
 
712
                if editing:
 
713
                    ui.frame(xpos=300,
 
714
                              ypos=200,
 
715
                              xanchor='left',
 
716
                              yanchor='top',
 
717
                              xfill=False,
 
718
                              xminimum=500
 
719
                              )
 
720
                
 
721
                    ui.vbox()
 
722
                    ui.text("What will you do in the %s?" % editing.lower())
 
723
                    ui.null(height=20)
 
724
 
 
725
                    for i in choices:
 
726
                        button(i, plan[editing] == i, ("set", i),
 
727
                               xpos=0, xanchor='left')
 
728
 
 
729
                    ui.close()
 
730
 
 
731
                # Window at the bottom.
 
732
                ui.window()
 
733
                ui.vbox()
 
734
                ui.text("To get to the next screen, click the 'Continue' button.")
 
735
                ui.close()
 
736
 
 
737
                type, value = ui.interact()
 
738
 
 
739
                if type == "done":
 
740
                    break
 
741
 
 
742
                if type == "edit":
 
743
                    editing = value
 
744
 
 
745
                if type == "set":
 
746
                    plan[editing] = value
 
747
                    editing = None
 
748
 
 
749
            return plan
 
750
 
 
751
init:
 
752
    image movie = Movie()
 
753
 
 
754
    python:
 
755
        povname = ""
 
756
        pov = DynamicCharacter("povname", color=(192, 64, 64, 255))
 
757
 
 
758
    $ ectc = Character('Eileen', color=(200, 255, 200, 255),
 
759
                       ctc = anim.Blink("arrow.png"))
 
760
 
 
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")
 
764
 
 
765
    $ equote = Character('Eileen',  color=(200, 255, 200, 255),
 
766
                         who_suffix = ':', what_prefix='"', what_suffix='"')
 
767
 
 
768
    $ eweird = Character('Eileen', color=(200, 255, 200, 255),
 
769
                         what_underline=True, window_left_margin=200,
 
770
                         window_yminimum=300)
 
771
 
 
772
    $ etwo = Character('Eileen', color=(200, 255, 200, 255),
 
773
                       show_two_window=True)
 
774
 
 
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))
 
778
 
 
779
    image eileen animated = Animation(
 
780
        "9a_vhappy.png", 1.0,
 
781
        "9a_happy.png", 1.0)
 
782
 
 
783
    image smanim = anim.SMAnimation(
 
784
        "r",
 
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))),
 
788
 
 
789
        anim.Edge("r", .5, "g", dissolve),
 
790
        anim.Edge("r", .5, "b", dissolve),
 
791
 
 
792
        anim.Edge("g", .5, "r", dissolve),
 
793
        anim.Edge("g", .5, "b", dissolve),
 
794
 
 
795
        anim.Edge("b", .5, "r", dissolve),
 
796
        anim.Edge("b", .5, "g", dissolve),         
 
797
        )
 
798
 
 
799
    # There's no reason to use DynamicDisplayable here, except to test it.
 
800
    image cyan base = DynamicDisplayable("Image('cyan.png')")
 
801
 
 
802
    image cyan crop = im.Crop("cyan.png", 100, 0, 100, 200)
 
803
 
 
804
    image cyan scale = im.Scale("cyan.png", 100, 100) 
 
805
    
 
806
    image cyan composite = im.Composite((200, 300),
 
807
                                        (0, 0), "cyan.png",
 
808
                                        (0, 50), "cyan.png",
 
809
                                        (0, 100), "cyan.png")
 
810
 
 
811
    image cyan livecomposite = LiveComposite((200, 300),
 
812
                                             (0, 0), anim.Blink(Image("cyan.png")),
 
813
                                             (0, 50), "cyan.png",
 
814
                                             (0, 100), "cyan.png")
 
815
 
 
816
    image cyan green = im.Map("cyan.png", bmap=im.ramp(0, 0))
 
817
 
 
818
    image cyan green2 = im.Recolor("cyan.png", 255, 255, 0, 255)
 
819
 
 
820
    image cyan alpha = im.Alpha("cyan.png", 0.5)
 
821
 
 
822
    image cyan blackwhite = "blackwhite.png"
 
823
 
 
824
    image cyan twocolor = im.Twocolor("blackwhite.png",
 
825
                                      (0, 255, 255, 255),
 
826
                                      (255, 255, 0, 255))
 
827
 
 
828
    image eileen alpha = im.Alpha("9a_happy.png", 0.5)
 
829
 
 
830
    image eileen flip = im.Flip("9a_happy.png", vertical=True)
 
831
 
 
832
    $ cyanpos = Position(xpos=700, xanchor='right', ypos=100, yanchor='top')
 
833
 
 
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)
 
838
 
 
839
    $ demotrans = ImageDissolve("demotrans.png", 3.0, 16)
 
840
 
 
841
    image circiris = "circiris.png"
 
842
 
 
843
    image snowblossom = SnowBlossom(anim.Filmstrip("sakura.png", (20, 20), (2, 1), .15))
 
844
 
 
845
    $ renpy.register_sfont("skyfont", 22, filename="skyfont.png", default_kern=-1)
 
846
 
 
847
    $ esf = Character('Eileen', color=(200, 255, 200, 255),
 
848
                      what_font="skyfont", what_size=22,
 
849
                      what_drop_shadow=(1, 1))
 
850
 
 
851
    $ style.frame.background = Frame("frame.png", 12, 12)
 
852
 
 
853
    $ definition = Character(None, window_yfill=True, window_xmargin=20, window_ymargin=20, window_background=Solid((0, 0, 0, 192)))
 
854
 
 
855
    $ config.layers.insert(1, 'demo')
 
856
    $ config.layer_clipping['demo'] = (50, 50, 700, 500)
 
857
 
 
858
    
 
859
label demonstrate:
 
860
 
 
861
    scene bg washington
 
862
    show eileen happy
 
863
 
 
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
 
866
       have demonstrated."
 
867
 
 
868
    menu demo_menu:
 
869
 
 
870
        "Simple transitions, updated in 4.8.5":
 
871
 
 
872
            e "Okay, I can tell you about simple transitions. We call
 
873
               them simple because they aren't that flexible."
 
874
 
 
875
            e "But don't let that get you down, since they're the
 
876
               transitions you'll probably use the most."
 
877
 
 
878
            with None
 
879
            scene bg whitehouse
 
880
            show eileen happy
 
881
            with dissolve
 
882
 
 
883
            e "The dissolve transition is probably the most useful,
 
884
               blending one scene into another."
 
885
 
 
886
            with None
 
887
            with fade
 
888
 
 
889
            e "The fade transition fades to black, and then fades back
 
890
               in to the new scene."
 
891
 
 
892
            e "If you're going to stay at a black screen, you'll
 
893
               probably want to use dissolve rather than fade."
 
894
 
 
895
            with None
 
896
            scene bg washington
 
897
            show eileen happy
 
898
            with pixellate
 
899
 
 
900
            e "The pixellate transition pixellates out the old scene,
 
901
               switches to the new scene, and then unpixellates that."
 
902
 
 
903
            e "It's probably not appropriate for most games, but we
 
904
               think it's kind of neat."
 
905
 
 
906
            e "Finally, we can point out that motions can be used as
 
907
               transitions."
 
908
 
 
909
            "..."
 
910
 
 
911
            "......"
 
912
 
 
913
            $ renpy.play('punch.wav')
 
914
            with vpunch
 
915
 
 
916
            e "Hey! Pay attention."
 
917
 
 
918
            e "I was about to demonstrate vpunch... well, I guess I just
 
919
               did."
 
920
 
 
921
            $ renpy.play('punch.wav')
 
922
            with hpunch
 
923
 
 
924
            e "We can also shake the screen horizontally, with hpunch."
 
925
 
 
926
        "ImageDissolve transitions, updated in 5.3.1.":
 
927
 
 
928
            e "ImageDissolve allows us to have dissolve transitions that are
 
929
               controlled by images."
 
930
 
 
931
            e "This lets us specify very complex transitions, fairly
 
932
               simply."
 
933
 
 
934
            e "Let's try some, and then I'll show how they work."
 
935
 
 
936
            e "There are two ImageDissolve transitions present by
 
937
               default in the standard library."
 
938
            
 
939
            scene black with blinds
 
940
            scene bg washington
 
941
            show eileen happy
 
942
            with blinds
 
943
 
 
944
            e "The blinds transition opens and closes what looks like
 
945
               vertical blinds."
 
946
 
 
947
            scene black with squares
 
948
            scene bg washington
 
949
            show eileen happy
 
950
            with squares
 
951
 
 
952
            e "The squares transition uses these squares to show
 
953
               things."
 
954
 
 
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."
 
957
 
 
958
            e "There are also a few transitions that aren't in the
 
959
               standard library."
 
960
 
 
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."
 
964
 
 
965
            e "You can find them defined in the source of the demo
 
966
               script."
 
967
 
 
968
            scene black with circirisin
 
969
 
 
970
            e "We can hide things with a circirisin..."
 
971
 
 
972
            with None
 
973
            scene bg washington
 
974
            with circirisout
 
975
 
 
976
            e "... and show them again with a circirisout."
 
977
 
 
978
            e "The ramp parameter lets things dissolve in and out
 
979
               along the way."
 
980
 
 
981
            scene bg whitehouse with circirisoutramp
 
982
 
 
983
            e "It's even possible to have weird custom transitions."
 
984
 
 
985
            scene circiris with demotrans
 
986
 
 
987
            e "What we're showing here is the picture that's used in
 
988
               the circiris transitions."
 
989
 
 
990
            e "If you take a look, the center of it is white, while
 
991
               the edges are darker."
 
992
 
 
993
            e "When we use an ImageDissolve, the white will dissolve
 
994
               in first, followed by progressively darker colors."
 
995
 
 
996
            e "Let's try it."
 
997
 
 
998
            with None
 
999
            scene bg washington
 
1000
            show eileen happy
 
1001
            with slowcirciris
 
1002
 
 
1003
            
 
1004
            e "It's also possible to reverse the transition, so that
 
1005
               the black pixels are dissolved in first."
 
1006
 
 
1007
        "CropMove transitions, added in 4.5.":
 
1008
 
 
1009
            e "The CropMove transition class lets us provide a wide
 
1010
               range of transition effects."
 
1011
 
 
1012
            hide eileen with dissolve
 
1013
 
 
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."
 
1016
 
 
1017
            scene bg whitehouse with wiperight
 
1018
 
 
1019
            e "We first have wiperight..."
 
1020
 
 
1021
            scene bg washington with wipeleft
 
1022
 
 
1023
            e "...followed by wipeleft... "    
 
1024
 
 
1025
            scene bg whitehouse with wipeup
 
1026
 
 
1027
            e "...wipeup..."
 
1028
 
 
1029
            scene bg washington with wipedown
 
1030
 
 
1031
            e "...and wipedown."
 
1032
 
 
1033
            e "Next, the slides."
 
1034
 
 
1035
            scene bg whitehouse with slideright
 
1036
 
 
1037
            e "Slideright..."
 
1038
 
 
1039
            scene bg washington with slideleft
 
1040
 
 
1041
            e "...slideleft..."
 
1042
 
 
1043
            scene bg whitehouse with slideup
 
1044
 
 
1045
            e "...slideup..."
 
1046
 
 
1047
            scene bg washington with slidedown
 
1048
 
 
1049
            e "and slidedown."
 
1050
 
 
1051
            e "While the slide transitions slide in the new scene, the
 
1052
               slideaways slide out the old scene."
 
1053
 
 
1054
            scene bg whitehouse with slideawayright
 
1055
 
 
1056
            e "Slideawayright..."
 
1057
 
 
1058
            scene bg washington with slideawayleft
 
1059
 
 
1060
            e "...slideawayleft..."
 
1061
 
 
1062
            scene bg whitehouse with slideawayup
 
1063
 
 
1064
            e "...slideawayup..."
 
1065
 
 
1066
            scene bg washington with slideawaydown
 
1067
 
 
1068
            e "and slideawaydown."
 
1069
 
 
1070
            e "We also have a couple of transitions that use a
 
1071
               rectangular iris."
 
1072
 
 
1073
            scene bg whitehouse with irisout
 
1074
 
 
1075
            e "There's irisout..."
 
1076
 
 
1077
            with None
 
1078
            scene bg washington
 
1079
            show eileen happy
 
1080
            with irisin
 
1081
 
 
1082
            e "... and irisin."
 
1083
 
 
1084
            e "It's enough to make you feel a bit dizzy."
 
1085
            
 
1086
        "Positions and movement, updated in 5.6.0.":
 
1087
 
 
1088
            e "I'm not stuck standing in the middle of the screen,
 
1089
               even though I like being the center of attention."
 
1090
 
 
1091
            e "Positions, given with an at clause, specify where I'm
 
1092
               standing."
 
1093
 
 
1094
            e "The move transition moves around images that have
 
1095
               changed position."
 
1096
 
 
1097
            e "For example..."
 
1098
 
 
1099
            show eileen happy at offscreenleft with move
 
1100
 
 
1101
            e "I can move over to the offscreenleft position, just off
 
1102
               the left side of the screen."
 
1103
 
 
1104
            show eileen happy at left with move
 
1105
 
 
1106
            e "The left position has my left side border the left
 
1107
               margin of the screen."
 
1108
 
 
1109
            show eileen happy at center with move
 
1110
 
 
1111
            e "I can also move to the center..."
 
1112
 
 
1113
            show eileen happy at right with move
 
1114
 
 
1115
            e "... the right ..."
 
1116
 
 
1117
            show eileen happy at offscreenright with move
 
1118
 
 
1119
            e "... or even to offscreenright, off the right-hand side
 
1120
               of the screen."
 
1121
 
 
1122
            show eileen happy at right with move
 
1123
 
 
1124
            e "We don't limit you to these five positions either. You
 
1125
               can always create your own Position objects."
 
1126
 
 
1127
            # This is necessary to restart the time at which we are
 
1128
            # shown. 
 
1129
            hide eileen happy
 
1130
 
 
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)
 
1134
 
 
1135
            e "It's also possible to have a movement happen while
 
1136
               showing dialogue on the screen, using the Move function."
 
1137
 
 
1138
            e "Move can repeat a movement, and even have it bounce
 
1139
               back and forth, like I'm doing now."
 
1140
            
 
1141
            scene bg onememorial at Pan((0, 800), (0, 0), 10.0) with dissolve
 
1142
 
 
1143
            e "We can pan around an image larger than the
 
1144
               screen, using the Pan function in an at
 
1145
               clause."
 
1146
 
 
1147
            e "That's what we're doing now, panning up a picture of
 
1148
               the memorial to the Big Red One."
 
1149
 
 
1150
            scene bg whitehouse with dissolve
 
1151
            scene bg whitehouse at Zoom((800, 600), (0, 0, 800, 600), (225, 150, 400, 300), 1.0)
 
1152
 
 
1153
            e "We can zoom into images..."
 
1154
 
 
1155
            scene bg whitehouse at Zoom((800, 600), (225, 150, 400, 300), (0, 0, 800, 600), 1.0)
 
1156
 
 
1157
            e "... and zoom back out of them again."
 
1158
 
 
1159
            scene bg whitehouse
 
1160
            show eileen happy at FactorZoom(1.0, 0.5, 1.0, opaque=False), center
 
1161
 
 
1162
            e "We can also zoom images by a factor..."
 
1163
 
 
1164
            show eileen happy at FactorZoom(0.5, 1.0, 1.0, opaque=False), center
 
1165
 
 
1166
            e "... and zoom {i}them{/i} out again."
 
1167
            
 
1168
        
 
1169
            with None
 
1170
            scene bg washington
 
1171
            show eileen happy
 
1172
            with dissolve
 
1173
 
 
1174
            show snowblossom
 
1175
 
 
1176
            e "Finally, there's now a particle motion system in
 
1177
               Ren'Py."
 
1178
 
 
1179
            e "It can be used to animate things like falling cherry
 
1180
               blossoms, falling snow, and rising bubbles."
 
1181
 
 
1182
            e "While there's convenient support for things rising and
 
1183
               falling in straight lines, it's also possible to define
 
1184
               your own motions."
 
1185
 
 
1186
            e "The sky's the limit."
 
1187
 
 
1188
            e "Or the ground, in the case of these cherry blossoms."
 
1189
 
 
1190
            hide snowblossom with dissolve
 
1191
 
 
1192
        "Animation, updated in 4.8.5":
 
1193
 
 
1194
            e "Ren'Py supports a number of ways of creating
 
1195
               animations."
 
1196
 
 
1197
            e "These animations let you vary images, independent of
 
1198
               the user's clicks."
 
1199
 
 
1200
            show eileen animated
 
1201
 
 
1202
            e "For example, I'm switching my expression back and
 
1203
               forth, once a second."
 
1204
 
 
1205
            e "Even though you clicked, I'm still doing it."
 
1206
 
 
1207
            e "This is an example of the Animation function at work."
 
1208
 
 
1209
            show eileen happy
 
1210
 
 
1211
            e "The Animation function is limited to simple lists of
 
1212
               images, with fixed delays between them."
 
1213
 
 
1214
            e "The sequence can repeat, or can stop after one
 
1215
               go-through."
 
1216
 
 
1217
            e "If you want more control, you can use the
 
1218
               anim.SMAnimation function."
 
1219
 
 
1220
            e "It can randomly change images, and even apply
 
1221
               transitions to changes."
 
1222
 
 
1223
            with None
 
1224
            scene smanim
 
1225
            show eileen happy
 
1226
            with dissolve
 
1227
 
 
1228
            e "Here, we randomly dissolve the background between red,
 
1229
               green, and blue images."
 
1230
 
 
1231
            e "Psychadelic."
 
1232
 
 
1233
            with None
 
1234
            scene bg washington
 
1235
            show eileen happy
 
1236
            with dissolve
 
1237
 
 
1238
            e "It's probably best if we stop here, before somebody's
 
1239
               brain explodes."
 
1240
 
 
1241
        "Fonts and Text Tags, updated in 5.5.1.":
 
1242
 
 
1243
            e "Text tags let us control the appearance of text that is
 
1244
               shown to the user."
 
1245
 
 
1246
            e "Text tags can make text {b}bold{/b}, {i}italic{/i}, or
 
1247
               {u}underlined{/u}."
 
1248
 
 
1249
            e "They can make the font size {size=+12}bigger{/size} or
 
1250
               {size=-8}smaller{/size}."
 
1251
 
 
1252
            e "They let you pause{w} the display of the text,
 
1253
               optionally with{p}line breaks."
 
1254
 
 
1255
            e "They let you include {image=slider_idle.png} images
 
1256
               inside text."
 
1257
 
 
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}."
 
1263
 
 
1264
            e "There are also bold, italic, and underline style properties, which can
 
1265
               be styled onto any text."
 
1266
 
 
1267
            e "{a=define_hyperlink}Hyperlinks{/a} let buttons be
 
1268
               defined as using text tags."
 
1269
 
 
1270
            e "If you find yourself using text tags on every line, you
 
1271
               should probably look at style properties instead."
 
1272
 
 
1273
            e "Used with care, text tags can enhance {b}your{/b} game."
 
1274
 
 
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}."
 
1277
 
 
1278
            e "With great power comes great responsibility, after all."
 
1279
 
 
1280
            e "And we want to give you all the power you need."
 
1281
 
 
1282
            esf "For even more control, Ren'Py supports SFonts."
 
1283
 
 
1284
            esf "An SFont is an image file containing font
 
1285
                 information."
 
1286
 
 
1287
            esf "SFonts let you use fonts you otherwise couldn't, and
 
1288
                 apply special effects to fonts... like I'm doing
 
1289
                 now."
 
1290
 
 
1291
            e "We recommend keeping your usual font simple and readable."
 
1292
 
 
1293
            esf "Not like this one."
 
1294
 
 
1295
        "Music, sound and movies, updated in 4.5.":
 
1296
            
 
1297
            e "Ren'Py supports a number of multimedia functions."
 
1298
 
 
1299
            e "You're probably hearing music playing in the
 
1300
               background."
 
1301
 
 
1302
 
 
1303
            $ renpy.music_stop(fadeout=0.5)
 
1304
            e "We can stop it..."
 
1305
 
 
1306
 
 
1307
            $ renpy.music_start('sun-flower-slow-drag.mid')
 
1308
            e "... and start it playing again."
 
1309
            
 
1310
            # This plays a sound effect.
 
1311
            $ renpy.play("18005551212.ogg")
 
1312
 
 
1313
            e "We can also play up to eight channels of sound effects
 
1314
               on top of the music."
 
1315
 
 
1316
            e "We ship, in the extras/ directory, code to support
 
1317
               characters having voice."
 
1318
 
 
1319
            e "Finally, we support playing mpeg movies."
 
1320
    
 
1321
            if renpy.exists('Eisenhow1952.mpg'):
 
1322
 
 
1323
                e "Since you downloaded the Eisenhower commercial, I can show
 
1324
                   it to you as a cutscene."
 
1325
 
 
1326
                e "You can click to continue if it gets on your nerves too
 
1327
                   much."
 
1328
 
 
1329
                $ renpy.movie_cutscene('Eisenhow1952.mpg', 63.0)
 
1330
 
 
1331
                hide eileen
 
1332
                show movie at Position(xpos=420, ypos=25, xanchor='left', yanchor='top')
 
1333
                show eileen happy
 
1334
 
 
1335
                $ renpy.movie_start_displayable('Eisenhow1952.mpg', (352, 240))
 
1336
 
 
1337
                e "Ren'Py can even overlay rendered images on top of a movie,
 
1338
                   although that's more taxing for your CPU."
 
1339
 
 
1340
                e "It's like I'm some sort of newscaster or something."
 
1341
 
 
1342
                $ renpy.movie_stop()
 
1343
                hide movie
 
1344
 
 
1345
                $ renpy.music_start('sun-flower-slow-drag.mid')
 
1346
 
 
1347
            else:
 
1348
 
 
1349
                e "You haven't downloaded the Eisenhower commercial, so we
 
1350
                   can't demonstrate it."
 
1351
 
 
1352
            e "That's it for multimedia."
 
1353
 
 
1354
        "Image Operations, updated in 5.6.0":
 
1355
 
 
1356
            e "Image operations allow one to manipulate images as they
 
1357
               are loaded in."
 
1358
 
 
1359
            e "These are efficient, as they are only evaluated when an
 
1360
               image is first loaded."
 
1361
 
 
1362
            e "This way, there's no extra work that needs to be done
 
1363
               when each frame is drawn to the screen."
 
1364
 
 
1365
            show eileen happy at left with move
 
1366
            show cyan base at cyanpos with dissolve
 
1367
 
 
1368
            e "Let me show you a test image, a simple cyan circle."
 
1369
 
 
1370
            e "We'll be applying some image operations to it, to see
 
1371
               how they can be used."
 
1372
 
 
1373
            show cyan crop at cyanpos with dissolve
 
1374
            
 
1375
            e "The im.Crop operation can take the image, and chop it
 
1376
               up into a smaller image."
 
1377
 
 
1378
            show cyan composite at cyanpos with dissolve
 
1379
 
 
1380
            e "The im.Composite operation lets us take multiple images,
 
1381
               and draw them into a single image."
 
1382
 
 
1383
            e "While you can do this by showing multiple images, this
 
1384
               is more efficent, if more complex."
 
1385
 
 
1386
            show cyan livecomposite at cyanpos with dissolve
 
1387
 
 
1388
            e "There's also LiveComposite, which is less efficent, but
 
1389
               allows for animation."
 
1390
 
 
1391
            e "It isn't really an image operation, but we don't know
 
1392
               where else to put it."
 
1393
 
 
1394
            show cyan scale at cyanpos with dissolve
 
1395
 
 
1396
            e "The im.Scale operation lets us change the size of images."
 
1397
 
 
1398
            show cyan green at cyanpos with dissolve
 
1399
 
 
1400
            e "The im.Map operation lets us mess with the red, green,
 
1401
               blue, and alpha channels of an image."
 
1402
 
 
1403
            e "In this case, we removed all the blue from the image,
 
1404
               leaving only the green component of cyan."
 
1405
 
 
1406
            show cyan base at cyanpos with dissolve
 
1407
            show cyan green2 at cyanpos with dissolve 
 
1408
 
 
1409
            e "The im.Recolor operation can do the same thing, but is more
 
1410
               efficient when we're linearly mapping colors."
 
1411
 
 
1412
            show cyan blackwhite at cyanpos with dissolve
 
1413
 
 
1414
            e "The im.Twocolor operation lets you take a black and white image, like this one..."
 
1415
 
 
1416
            show cyan twocolor at cyanpos with dissolve
 
1417
 
 
1418
            e "... and assign colors to replace black and white."
 
1419
 
 
1420
            show cyan base at cyanpos with dissolve
 
1421
            show cyan alpha at cyanpos with dissolve
 
1422
 
 
1423
            e "The im.Alpha operation can adjust the alpha channel on
 
1424
               an image, making things partially transparent."
 
1425
 
 
1426
            show eileen alpha at left with dissolve
 
1427
 
 
1428
            e "It's useful if a character just happens to be ghost."
 
1429
 
 
1430
            with None
 
1431
            hide cyan
 
1432
            show eileen happy at left
 
1433
            with dissolve
 
1434
 
 
1435
            e "But that's not the case with me."
 
1436
 
 
1437
            show eileen happy with move
 
1438
 
 
1439
            show eileen flip with dissolve
 
1440
 
 
1441
            e "Finally, there's im.Flip, which can flip an image horizontally or vertically."
 
1442
 
 
1443
            e "I think the less I say about this, the better."
 
1444
 
 
1445
            show eileen happy with dissolve
 
1446
 
 
1447
            
 
1448
        "User interaction, updated in 5.5.0":
 
1449
 
 
1450
            e "Ren'Py gives a number of ways of interacting with the
 
1451
               user."
 
1452
 
 
1453
            e "You've already seen say statements and menus."
 
1454
 
 
1455
            menu:
 
1456
                
 
1457
                e "But were you aware that you can have dialogue and
 
1458
                   menus onscreen at the same time?"
 
1459
 
 
1460
                "Yes.":
 
1461
 
 
1462
                    show eileen vhappy
 
1463
 
 
1464
                    e "Good!"
 
1465
 
 
1466
                    show eileen happy
 
1467
 
 
1468
                "No.":
 
1469
 
 
1470
                    e "Well, now you know."
 
1471
 
 
1472
            e "We can also prompt the user to enter some text."
 
1473
 
 
1474
            $ povname = renpy.input("What is your name?")
 
1475
 
 
1476
            pov "My name is %(povname)s."
 
1477
 
 
1478
            
 
1479
            e "Imagemaps let the user click on an image to make a
 
1480
               choice."
 
1481
 
 
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
 
1485
            # picked.
 
1486
 
 
1487
            $ result = renpy.imagemap("ground.png", "selected.png", [
 
1488
                (100, 100, 300, 400, "eileen"),
 
1489
                (500, 100, 700, 400, "lucy")
 
1490
                ])
 
1491
 
 
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.
 
1495
 
 
1496
            if result == "eileen":
 
1497
                show eileen vhappy
 
1498
                e "You picked me!"
 
1499
 
 
1500
            elif result == "lucy":
 
1501
                show eileen concerned
 
1502
                e "It looks like you picked Lucy."
 
1503
 
 
1504
                # Eileen is being a bit possesive here. :-P
 
1505
                if date:
 
1506
                    e "You can forget about Saturday."
 
1507
                    $ date = False
 
1508
 
 
1509
            show eileen happy
 
1510
 
 
1511
            e "While these constructs are probably enough for most
 
1512
               visual novels, dating simulations may be more
 
1513
               complicated."
 
1514
 
 
1515
            e "The ui functions allow you to create quite complicated
 
1516
               interfaces."
 
1517
            
 
1518
            e "For example, try the following scheduling and stats screen,
 
1519
               which could be used by a stat-based dating simulation."
 
1520
 
 
1521
            $ day_planner()
 
1522
 
 
1523
            e "The ui functions can be used to rewrite many parts of
 
1524
               the interface."
 
1525
 
 
1526
            e "Hopefully, this gives you enough power to write any
 
1527
               visual novel you want."
 
1528
 
 
1529
        "Character Objects, updated in 5.6.0.":
 
1530
 
 
1531
            e "The Character object is used to declare characters, and
 
1532
               it can also be used to customize things about how a
 
1533
               character speaks."
 
1534
 
 
1535
            e "By supplying it with the appropriate arguments, we can
 
1536
               really change around the feel of the game."
 
1537
 
 
1538
            e "In this section, we'll demonstrate some of what can be
 
1539
               accomplished by customizing character objects."
 
1540
 
 
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."
 
1544
 
 
1545
            equote "This is a lot easier than having to put those
 
1546
                    quotes in by hand."
 
1547
 
 
1548
            equote "We can also use who_prefix and who_suffix to
 
1549
                    add text to the name of the speaker."
 
1550
 
 
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
 
1554
               itself."
 
1555
 
 
1556
            eweird "These can really change the look of the game."
 
1557
 
 
1558
            eside "A more practical use of that is in conjunction with
 
1559
                   show_side_image, which lets us position an image next
 
1560
                   to the text."
 
1561
 
 
1562
            etwo "There's also show_two_window, which puts the character's
 
1563
                  name in its own window."
 
1564
            
 
1565
            ectc "Finally, we demonstrate a click to continue
 
1566
                  indicator. In this example, it's nestled in with the
 
1567
                  text."
 
1568
 
 
1569
            ectc "This also demonstrates the use of the anim.Blink
 
1570
                  function."
 
1571
 
 
1572
            ectcf "A click to continue image can also be placed at a
 
1573
                   fixed location on the screen."
 
1574
 
 
1575
            e "That's it for now."
 
1576
 
 
1577
        "Layers and Advanced Show, added in 5.6.0.":
 
1578
 
 
1579
            e "Ren'Py lets you define layers, and show images on
 
1580
               specific layers."
 
1581
 
 
1582
            hide eileen
 
1583
            with dissolve
 
1584
 
 
1585
            show bg whitehouse onlayer demo
 
1586
            with dissolve
 
1587
 
 
1588
            show eileen happy onlayer demo 
 
1589
            with dissolve
 
1590
 
 
1591
            e "The \"onlayer\" clause of the scene, show, and hide
 
1592
               statements lets us pick which layers the commands
 
1593
               affect."
 
1594
 
 
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."
 
1598
 
 
1599
            scene onlayer demo
 
1600
            show eileen happy
 
1601
            with dissolve
 
1602
 
 
1603
            e "The \"as\" clause lets you change the tag of an image."
 
1604
 
 
1605
            show eileen happy as eileen2
 
1606
            with None
 
1607
 
 
1608
            show eileen happy at left
 
1609
            show eileen happy at right as eileen2
 
1610
            with move
 
1611
 
 
1612
            e "This is useful when you want to show two copies of the
 
1613
               same image."
 
1614
 
 
1615
            e "Or if a character has a twin."
 
1616
 
 
1617
            show eileen happy at center
 
1618
            show eileen happy at offscreenright as eileen2
 
1619
            with move
 
1620
 
 
1621
            hide eileen2
 
1622
 
 
1623
            show expression Text("This is text.", size=50, yalign=0.5, xalign=0.5, drop_shadow=(2, 2)) as text
 
1624
            with dissolve
 
1625
 
 
1626
            e "You can use \"show expression\" to show things that
 
1627
               aren't just images, like text."
 
1628
 
 
1629
            hide text
 
1630
            with dissolve
 
1631
 
 
1632
            show eileen happy zorder 2
 
1633
            show cyan base at Position(xalign=0.6, yalign=0.0) zorder 1
 
1634
            with dissolve
 
1635
 
 
1636
            e "Finally, the \"zorder\" clause lets you place an image behind
 
1637
               another."
 
1638
 
 
1639
            hide cyan base
 
1640
            show eileen happy
 
1641
            with dissolve
 
1642
 
 
1643
            e "And that's it for layers and advanced show."
 
1644
 
 
1645
            
 
1646
 
 
1647
        "" # Empty, so we have a blank line.
 
1648
 
 
1649
        "That's enough for me.":
 
1650
 
 
1651
            e "Is there anything else you'd like to ask?"
 
1652
 
 
1653
            return
 
1654
 
 
1655
    e "Is there anything else you want demonstrated?"
 
1656
 
 
1657
    jump demo_menu
 
1658
 
 
1659
 
 
1660
label define_hyperlink:
 
1661
 
 
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
 
1665
                menus."
 
1666
 
 
1667
    return
 
1668
 
 
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.
 
1672
#
 
1673
# These can be deleted without issue, if you do not want them.
 
1674
 
 
1675
init:
 
1676
    
 
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
 
1681
 
 
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
 
1689
 
 
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"
 
1696
 
 
1697
    # Select the transitions that are used when entering and exiting
 
1698
    # the game menu.
 
1699
    $ library.enter_transition = pixellate
 
1700
    $ library.exit_transition = pixellate
 
1701
    
 
1702
 
 
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.
 
1705
 
 
1706
# We'll comment it out for now.
 
1707
#
 
1708
# label splashscreen:
 
1709
#     scene black
 
1710
#     show text "American Bishoujo Presents..." with dissolve
 
1711
#     $ renpy.pause(1.0)
 
1712
#     hide text with dissolve
 
1713
#
 
1714
#     return
 
1715
 
 
1716
init:
 
1717
    $ MicroLayer = renpy.curry(Fixed)
 
1718
 
 
1719
label splashscreen:
 
1720
    "Foo."
 
1721
 
 
1722
    python hide:
 
1723
 
 
1724
        store.hovered_text = ""
 
1725
 
 
1726
        def mybutton(text, hovered_text, clicked):
 
1727
 
 
1728
            def hovered(hovered_text=hovered_text):
 
1729
 
 
1730
                if store.hovered_text == hovered_text:
 
1731
                    return
 
1732
 
 
1733
                store.hovered_text = hovered_text
 
1734
                renpy.restart_interaction()
 
1735
                return None
 
1736
 
 
1737
            
 
1738
            ui.textbutton(text, hovered=hovered, clicked=clicked)
 
1739
 
 
1740
        ui.vbox()
 
1741
        ui.hbox()
 
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))
 
1745
        ui.close()
 
1746
 
 
1747
        ui.add(DynamicDisplayable("Text(store.hovered_text)"))
 
1748
        ui.close()
 
1749
 
 
1750
        ui.interact()
 
1751
 
 
1752
$ foo = "bar"
 
1753
 
 
1754