Help for image sequence

Questions, skill improvement, and respectful critique involving game writing.
Post Reply
Message
Author
maddens23
Newbie
Posts: 3
Joined: Fri Jun 17, 2022 7:41 am
Contact:

Help for image sequence

#1 Post by maddens23 »

Hi everyone, i'm creating my own VN and i wanted to implement this sort of visual "minigame" inside...

I would like to have a menu where you can choose a series of images, immediately after a button allows you to replicate them in sequence in the next scene.
Is it possible to recreate something like that or is it too complicated? Honestly, i wouldn't know where to start...

I post a demonstration image, thanks in advance for the help...

Image

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Help for image sequence

#2 Post by Alex »

maddens23 wrote: Fri Jun 17, 2022 8:04 am ...Is it possible to recreate something like that or is it too complicated? Honestly, i wouldn't know where to start...
This might help a bit - viewtopic.php?f=8&t=49213#p483820

maddens23
Newbie
Posts: 3
Joined: Fri Jun 17, 2022 7:41 am
Contact:

Re: Help for image sequence

#3 Post by maddens23 »

Yes, it might work, the problem is that not as well as modifying the code to replace the "textbuttons" with images

maddens23
Newbie
Posts: 3
Joined: Fri Jun 17, 2022 7:41 am
Contact:

Re: Help for image sequence

#4 Post by maddens23 »

can anyone find me a solution? maybe it's a simple thing that unfortunately i don't know :(

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Help for image sequence

#5 Post by Alex »

maddens23 wrote: Fri Jun 17, 2022 10:59 pm Yes, it might work, the problem is that not as well as modifying the code to replace the "textbuttons" with images

Code: Select all

image red:
    Solid("#c00")
    size(100, 100)
    
image green:
    Solid("#0c0")
    size(100, 100)
    
image blue:
    Solid("#00c")
    size(100, 100)
    
image purple:
    Solid("#c0c")
    size(100, 100)
    
image grey:
    Solid("#ccc")
    size(100, 100)

# game screen
screen match_game_scr():
    
    # buttons to click
    vbox:
        align (0.5, 0.6)
        spacing 10
        
        hbox:
            align (0.5,0.0)
            spacing 10
            
            # images
            for i in items_list:
                button:
                    add i
                    action Function(my_add_func, i)
                    sensitive can_click
                
            textbutton "remove" action Function(my_remove_func):
                sensitive can_click
                align (0.5, 0.5)
            
        textbutton "Done" action Return(player_sequence):
            sensitive can_click
            align (0.5, 1.0)
    
    # player's sequence
    hbox:
        align (0.5, 0.25)
        spacing 10
        for i in player_sequence:
            add i
            
    textbutton "hint" action ToggleScreen("show_sequence"):
        sensitive can_click
        align (0.95,0.05)

# screen to show puzzle sequence
screen show_sequence():
    
    frame:
        align (0.5,0.5)
        hbox:
            spacing 10
            for i in sequence:
                add i

init python:
    # functions to add/remove items to/from sequence
    def my_add_func(x):
        global player_sequence, sequence_length
        
        # will add items until player's sequence is shorter
        # than puzzle sequence
        if len(player_sequence) < sequence_length:
            player_sequence.append(x)
        
    def my_remove_func():
        global player_sequence
        player_sequence = player_sequence[:-1]

    
# The game starts here.
label start:
    
    scene black
    "..."
    # we can call game label with different values for
    # puzzle sequence length and list of possible images
    call match_game(3, ["red", "green", "blue"])
    
    "...and once again"
    call match_game(5, ["red", "green", "blue", "purple", "grey"])
    "That's all."
    return
    
# game label, should be called with
# puzzle sequence length and list of possible images specified
label match_game(seq_len, i):
    $ items_list = i
    $ sequence_length = seq_len
    $ sequence = []
    
    # creates puzzle sequence randomly
    python:
        for i in range(sequence_length):
            sequence.append(renpy.random.choice(items_list))
    
    $ player_sequence = []
    
    # flag to disable game buttons
    $ can_click = False
    
    # show puzzle sequence to player
    show screen show_sequence
    "Remember this..."
    hide screen show_sequence
    
    # show game screen
    show screen match_game_scr

    label loop:
        # player now can click buttons
        $ can_click = True
        # store the result of player's interaction in 'res'
        $ res = ui.interact()
        # now player unable to click buttons
        $ can_click = False
        
        # evaluate result of player's interaction
        if res == sequence:
            jump win
        else:
            "Wrong!"
            # drop player's sequence
            $ player_sequence = []
            # continue game
            jump loop
label win:
    "You win!"
    hide screen show_sequence
    hide screen match_game_scr
    "..."
    # return from game since we've called it
    return

Post Reply

Who is online

Users browsing this forum: No registered users