Binoculars

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Andredron
Miko-Class Veteran
Posts: 688
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Binoculars

#1 Post by Andredron »

Code: Select all

image bg:    # background picture with all the buttons - we will show it before we start looking through binoculars
    contains:
        "bg.png" # background 800х600
    contains:
        "bg_idle.png" # button image, reduced by 2 times, because the original image size (1600x1200x)
        zoom 0.5

    
screen binoculars:
    zorder 70
    modal True # makes only the current screen active - you cannot interact with the rest. If this parameter is not set, then when you click on the mouse button, the game will continue, and we haven't finished with the binoculars yet
    
    # let's assemble the binoculars and what we are looking at into one screen so that we can interact with both
    add "bg" xalign bg_xalign yalign bg_yalign zoom 2.0 # draw the background (800 x 600), enlarged by 2 times
    
    imagebutton:        # put a button on top of the background (the size of the pictures for the button is 1600 x 1200, i.e. also 2 times larger than the screen)
        
        xalign bg_xalign yalign bg_yalign 
        idle "bg_idle.png"
        hover "bg_hover.png"
        action [Hide("binoculars"), Hide("back_view"), Jump ("far_away_label") ]    # when pressed, it will send us far, far away
        focus_mask True # only the opaque part of the button will be active

    
    # we will also make a picture of the binoculars in the form of a button, because it should partially hide the background and the buttons on it
    imagebutton:
        align (0.5, 0.5)
        idle "bin.png"
        hover "bin.png"
        action Hide ("smth") # the button must do something, otherwise it will not cover the buttons in the background, and they can be pressed "through" the picture of the binoculars
        focus_mask True # only the opaque part of the button will be active - i.e. we will be able to interact with the background in the place where the binocular picture is transparent
    

    textbutton "Top" yalign 0.0 xalign 0.5 action setVariable("bg_yalign", max(-0.2, (bg_yalign-0.1) ) )    
    textbutton "Down" yalign 1.0 xalign 0.5 action setVariable("bg_yalign", min( 1.2, (bg_yalign+0.1) ) )
    textbutton "Left" yalign 0.5 xalign 0.0 action setVariable("bg_xalign", max(-0.2, (bg_xalign-0.1) ) )
    textbutton "To the right" yalign 0.5 xalign 1.0 action setVariable("bg_xalign", min( 1.2, (bg_xalign+0.1) )  )
    textbutton "X" action [Hide("binoculars"), Hide("back_view") ]


label far_away_label:
    scene 3 pic with dissolve
    "How vague everything is..."
    " Now I will focus the binoculars...."
    "And-and...."
    scene 2 pic with dissolve
    "....."
    scene 2 pic with fade
    "Who is this?"
    "And what is he doing at his house...."
    return
    
# The game starts here.
label start:
    $ bg_xalign = 0.5
    $ $ bg_align = 0.5
    scene black
    centered"12 o'clock at night"
    "Favorite hiding place {a=define_stalker}Stalker{/a} Lucy"
    scene 1 pic with fade
    "I wonder what my neighbor is doing there..."
    scene black
    centered "An hour passes"
    scene bg1 with dissolve
    "Oh! Finally the neighbor came out!"
    "Now I'll look 1 eye, this time the neighbor will throw out and you can go to bed..."
    "Takes out binoculars and starts looking at his balcony"

  
    show screen binoculars
    $ renpy.pause(0.0001)
    "I don't want to look at him...."
    "The end"

    return

label define_stalker:

    "These are those who fanatically pursue and watch their victim from hiding places"
    return
    
    
Download - https://drive.google.com/drive/folders/ ... rH3xJxGm9S

Image

Image

Post Reply

Who is online

Users browsing this forum: No registered users