how to create a day night display

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
desArt
Newbie
Posts: 2
Joined: Fri Mar 16, 2018 7:09 pm
Contact:

how to create a day night display

#1 Post by desArt »

Hi!
I'm new in coding and I usually create scripts from scraps of previously found codes and some dose of experimentation...

What was I trying to do?
- make a bar that shows weather it's night or day

What have I done?
- counting time bar
- bluish filter for backgrounds that appears during the night
- neverending display of nights and days :D

Code: Select all

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define e = Character("Eileen")
image night = "night.png"
image bg plain = "bg plain.png"
image sun = "sun.png"
image moon = "moon.png"


init:
    $ timer_range = 0
    $ timer_jump = 0

# The game starts here.

label start:

transform alpha_dissolve:
    alpha 0.0
    linear 0.5 alpha 1.0
    on hide:
        linear 0.5 alpha 0
    # This is to fade the bar in and out, and is only required once in your script

screen countdown:
    timer 0.01 repeat True action If(time > 0, true=SetVariable('time', time - 0.01), false=[Hide('countdown'), Jump(timer_jump)])
    bar value time range timer_range xalign 0.5 yalign 0.06 left_bar "#FFE4C4" right_bar "#4169E1" xmaximum 600 at alpha_dissolve # This is the timer bar.
    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.
    
screen countdown2:
    timer 0.01 repeat True action If(time > 0, true=SetVariable('time', time - 0.01), false=[Hide('countdown'), Jump(timer_jump)])
    bar value time range timer_range xalign 0.5 yalign 0.06 left_bar "#4169E1" right_bar "#FFE4C4" xmaximum 600 at alpha_dissolve
        # This is the timer bar.
    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.
    
    
    
    
    # time = the time the timer takes to count down to 0.
# timer_range = a number matching time (bar only)
# timer_jump = the label to jump to when time runs out

scene bg plain


label day_slow:
    $ time = 5
    $ timer_range = 5
    $ timer_jump = 'night_slow'
    show screen countdown
    
    show sun at top
    
    hide moon
    hide night
    with dissolve
    $ renpy.pause (10.0, hard=True)
    jump day_slow
        
            
   
label night_slow:
    $ time = 5
    $ timer_range = 5
    $ timer_jump = 'day_slow'
    show screen countdown2
    
    show moon at top
    
    show night
    with dissolve
    hide sun
    $ renpy.pause (10.0, hard=True)
    jump night_slow
       
   
    show eileen happy

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return
What do I need?
- to know how to change the code in a way that it won't affect the gameplay - something working in the background


Thank you for any help.

Post Reply

Who is online

Users browsing this forum: No registered users