Page 1 of 1

{code} A game for seven days

Posted: Sun Nov 03, 2013 5:04 pm
by nclm
Hi :)

Last winter, I began learning Ren'Py and started a game I never continued since. While I still plan to go back to it one day, I ran into the folder today and thought the base script.rpy code may perhaps be interesting if someone wants to do a game using the same concept.

The idea for the game is: it takes place in one week. You have to play each day to complete it.

Maybe you have to get an item each day to build something, or meet one character every morning to reach the end of the story? There's a different scenario for each day of the week, and the player must play all of them (not necessarily in order, if you miss the Tuesday, you can play the following Tuesday).

My original story was about someone arriving in a new town, moving in an empty flat, and trying to find a piece of furniture each day to fill the apartment, meeting new people on the way — but I'm curious to see what other stories people can come up with using this principle.

Here is the base script.rpy without stories. Just a framework with date detection, completed/non-completed days switching, and place-holder sentences about “items”.

Code: Select all

## script.rpy for a game in seven days
## original base code by nicolas (

init -1 python:
    import time
    time = time.localtime(time.time()).tm_wday
    days = ['Monday',    # 0
            'Tuesday',   # 1    
            'Wednesday', # 2
            'Thursday',  # 3
            'Friday',    # 4
            'Saturday',  # 5
            'Sunday']    # 6

label start:
    # What time is it?
    $day = time
    $dayname = days[time]
    # Check if game already completed.
    if persistent.all_items:
        centered "I already got all the items."
    # Shared beginning.
    centered "[dayname]"
    "I woke up."
    # First time explaination
    if not persistent.first_exp:
        "I need to get 7 items"
        $persistent.first_exp = True
    jump gotoday

label gotoday:
    # Jump to daily script.
    if   day == 0:
        jump mon_start    
    elif day == 1:
        jump tue_start
    elif day == 2:
        jump wed_start
    elif day == 3:
        jump thu_start
    elif day == 4:
        jump fri_start
    elif day == 5:
        jump sat_start
    elif day == 6:
        jump sun_start
        "Out of time!"

label mon_start:
    # Check past
    if   persistent.mon_item:
        "I already got the Monday item."
        jump closing
    elif persistent.mon_started:
        "Last Monday, I didn't found anything."

    # Flag day as started
    $persistent.mon_started = True
    "This Monday, I'll get the Monday item."
        "Get Monday item":
            $persistent.mon_item = True
            "You got the Monday item!"
            jump closing
label tue_start:
    # Check past
    if   persistent.tue_item:
        "I already got the Tuesday item."
        jump closing
    elif persistent.tue_started:
        "Last Tuesday, I didn't found anything."

    # Flag day as started
    $persistent.tue_started = True
    "This Tuesday, I'll get the Tuesday item."
        "Get Tuesday item":
            $persistent.tue_item = True
            "You got the Tuesday item!"
            jump closing

label wed_start:
    # Check past
    if   persistent.wed_item:
        "I already got the Wednesday item."
        jump closing
    elif persistent.wed_started:
        "Last Wednesday, I didn't found anything."

    # Flag day as started
    $persistent.wed_started = True
    "This Wednesday, I'll get the Wednesday item."
        "Get Wednesday item":
            $persistent.wed_item = True
            "You got the Wednesday item!"
            jump closing

label thu_start:
    # Check past
    if   persistent.thu_item:
        "I already got the Thurday item."
        jump closing
    elif persistent.thu_started:
        "Last Thurday, I didn't found anything."

    # Flag day as started
    $persistent.thu_started = True
    "This Thurday, I'll get the Thurday item."
        "Get Thurday item":
            $persistent.thu_item = True
            "You got the Thurday item!"
            jump closing

label fri_start:
    # Check past
    if   persistent.fri_item:
        "I already got the Friday item."
        jump closing
    elif persistent.fri_started:
        "Last Friday, I didn't found anything."

    # Flag day as started
    $persistent.fri_started = True
    "This Friday, I'll get the Friday item."
        "Get Friday item":
            $persistent.fri_item = True
            "You got the Friday item!"
            jump closing

label sat_start:
    # Check past
    if   persistent.sat_item:
        "I already got the Saturday item."
        jump closing
    elif persistent.sat_started:
        "Last Saturday, I didn't found anything."

    # Flag day as started
    $persistent.sat_started = True
    "This Saturday, I'll get the Saturday item."
        "Get Saturday item":
            $persistent.sat_item = True
            "You got the Saturday item!"
            jump closing
label sun_start:
    # Check past
    if   persistent.sun_item:
        "I already got the Sunday item."
        jump closing
    elif persistent.sun_started:
        "Last Sunday, I didn't found anything."

    # Flag day as started
    $persistent.sun_started = True
    "This Sunday, I'll get the Sunday item."
        "Get Sunday item":
            $persistent.sun_item = True
            "You got the Sunday item!"
            jump closing

## END
label closing:
    if persistent.mon_item and persistent.tue_item and persistent.wed_item and persistent.thu_item and persistent.fri_item and persistent.sat_item and persistent.sun_item:
        $persistent.all_items = True
        centered "I got all the 7 items!"

        centered "See you tommorow!"

Have a nice evening :)

~ nicolas

Re: {code} A game for seven days

Posted: Sat Nov 16, 2013 2:22 am
by erinism
This is amazing.

Seriously, thank you.

Re: {code} A game for seven days

Posted: Thu Apr 07, 2016 2:11 pm
by SilverSnow
This could be very useful, thank you for sharing! ^^