Simple minigames (Screen Language only).

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.
Message
Author
User avatar
Alex
Eileen-Class Veteran
Posts: 1829
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Simple minigames (Screen Language only).

#31 Post by Alex » Sat Feb 27, 2016 4:52 pm

Tower of Hanoi

Code: Select all

image pole = "pole.png"

define texture1 = "texture1.png"
define texture2 = "texture2.png"
define texture3 = "texture3.png"
define texture4 = "texture4.png"

####
# main game screen
screen hanoi_game_screen(towers):
    textbutton "Click me!" action Show("moves_count_scr") align (0.95, 0.05)
    
    vbox:
        align (0.05, 0.05)
        textbutton "autosolve" action [ToggleVariable("autosolve", False, True), SetVariable("create_movements_list", True), Return("start_autosolving")]
        textbutton "give up" action Jump("give_up")
    
    text "Moves made: [player_moves]" size 35 align (0.5, 0.05)
    
    for i, each_tower in enumerate(towers):
        
        ####
        # pole and mark
        vbox:
            pos each_tower["tower_pos"] anchor(0.5, 1.0)
            xalign 0.5
            
            if each_tower["mark"] == "start":
                text "Start" size 25 xalign 0.5
                null height (block_size*1)
                
            elif each_tower["mark"] == "finish":
                text "Goal" size 25 xalign 0.5
                null height (block_size*1)
                
            else:
                text "" size 25 xalign 0.5
                null height (block_size*1)
                
            add "pole"
            
        ####
        # blocks
        vbox:
            pos each_tower["tower_pos"] anchor(0.5, 1.0)
            xalign 0.5 yoffset -20
            
            for each_block in each_tower["blocks"]:
                frame:
                    xpadding 0 ypadding 0
                    xmargin 0 ymargin 0
                    background Frame(each_block["color"], 10, 10) # color
                    xminimum (block_size*(each_block["size"]+2)) xmaximum (block_size*(each_block["size"]+2)) # the width of block
                    yminimum block_size ymaximum block_size
                    xalign 0.5
                        
        ####
        # buttons to operate the game
        if can_click:
            ####
            # if player haven't decided yet what block to move
            # and there is some blocks on the pole
            if start_from_tower < 0 and len(each_tower["blocks"])>0:
                button:
                    xminimum 125 xmaximum 125
                    pos each_tower["tower_pos"] anchor(0.5, 0.0) yoffset 10
                    text "↑" size 35 xalign 0.5
                    action SetVariable("start_from_tower", i)
            
            ####
            # if player decided to move block from this pole
            elif start_from_tower == i:
                button:
                    xminimum 125 xmaximum 125
                    pos each_tower["tower_pos"] anchor(0.5, 0.0) yoffset 10
                    text "undo" size 35 xalign 0.5
                    action SetVariable("start_from_tower", -1)
            
            ####
            # if block that player decided to move is smaller
            # than top block on this pole
            elif (start_from_tower >= 0) and (towers[i]["blocks"] == [] or towers[start_from_tower]["blocks"][0]["size"]<towers[i]["blocks"][0]["size"]):
                button:
                    xminimum 125 xmaximum 125
                    pos each_tower["tower_pos"] anchor(0.5, 0.0) yoffset 10
                    text "[i] ↓" size 35 xalign 0.5
                    action [SetVariable("finish_to_tower", i), Return("move_done")]
            
            ####
            # if block can't be moved on this pole
            else:
                button:
                    xminimum 125 xmaximum 125
                    pos each_tower["tower_pos"] anchor(0.5, 0.0) yoffset 10
                    text " " size 35 xalign 0.5
                    action [[]]
        
        ####
        # if interactions disabled
        else:
            button:
                xminimum 125 xmaximum 125
                pos each_tower["tower_pos"] anchor(0.5, 0.0) yoffset 10
                text " " size 35 xalign 0.5
                action [[]]
            

screen moves_count_scr():
    modal True
    
    default i = 0
    $ n = hanoi_moves_count(i)
    
    frame:
        align (0.5,0.5)
        vbox:
            text"Minimal number of moves to solve [i] blocks tower:"
            text "[n]" size 35 xalign 0.5
            null height 20
            hbox:
                xalign 0.5
                textbutton "<" action SetScreenVariable("i", max(0, i-1))
                null width 20
                textbutton ">" action SetScreenVariable("i", i+1)
            null height 20
            textbutton "close" action Hide("moves_count_scr") xalign 0.5
        

init python:
    def check_game_state():
        '''
        This function checks if all the blocks are in one
        tower at the finish pole and return True or False.
        '''
                
        global towers, finish_tower, blocks_number
        if len(towers[finish_tower]["blocks"]) == blocks_number:
            return True
        return False


    def hanoi_moves_count(x):
        '''
        This function counts the number of moves one must proceed
        to move the whole tower from start pole to finish one.
        x - number of blocks in tower
        '''
        
        if x == 1:
            return 1
        elif x > 1:
            return 1 + hanoi_moves_count(x-1) * 2
        else:
            return 0
            
        
    
    def make_path_2(t, x, f):
        '''
        Use this function to get result of "hanoi_func_2"
        t - towers description that should be a list
            of 3 lists which  contents the blocks numbers
        x - number of the biggest block
        f - number of the pole where tower should be moved to
        
        This function will work even if some blocks was already moved
        from start tower to another pole.
        Note that this function will work correct only if blocks
        in each tower placed correct (the small one over the large, like
        [ [3], [1, 2, 4], [] ]), in case you will try to randomly
        generate the game state.
        '''
        
        ####
        # the general list of moves
        global res_2
        res_2 = []
        
        return hanoi_func_2(t, x, f)
        
        


    def hanoi_func_2(t, x, f):
        '''
        t - towers description that should be a list
            of 3 lists which  contents the blocks numbers
        x - number of the biggest block
        f - number of the pole where tower should be moved to
        
        The function returns the list of tuples that are
        (start_pole, finish_pole) that describes moves that
        should be made from last to first to win the game.
        
        So when function will return that list, one should pop
        tuples out of it one after another and move blocks
        from "start_pole" position to "finish_pole" position.
        '''
        
        global res_2
        
        ####
        # s - is the pole where the biggest block is located
        if x in t[0]:
            s = 0
        elif x in t[1]:
            s = 1
        else:
            s = 2
            
        ####
        # if the biggest block is already on finish pole
        # and this block's number is 1
        # then we got nothing else to do
        if (s == f) and (x == 1):
            pass
        
        ####
        # if the biggest block is already on finish pole
        # and this block's number is not 1
        # then we should move the tower of (x-1) blocks upon it
        elif (s == f) and (x != 1):
            hanoi_func_2(t, x-1, f)
            
        ####
        # if the biggest block is not in finish pole
        # and this block's number is 1
        # then move it to finish pole
        elif (s != f) and (x == 1):
            res_2.append((s, f))
            
        ####
        # otherwise we need to create a list of moves
        # [to move (x-1) tower from free pole to finish one,
        #  to move x-block to the finish pole,
        #  to set (x-1) tower on the free pole from blocks on different poles]
        # then we should make the moves from this list
        # from last one to first.
        #
        # So to move (x-1) tower to finish pole
        # we should use make_path_1 function,
        # and to set all the blocks to (x-1) tower on the free pole
        # we should use make_path_2 function
        else:
            ####
            # ss is the free pole that neither start nor finish one
            # for current tower
            ss = [0,1,2]
            ss.remove(s)
            ss.remove(f)
            ss = ss[0]
            make_path_1(x-1, ss, f)
            res_2.append((s, f))
            ####
            # ff is the free pole that neither start nor finish one
            # for current tower
            ff = [0,1,2]
            ff.remove(s)
            ff.remove(f)
            ff = ff[0]
            hanoi_func_2(t, x-1, ff)
        return res_2
    
    
    def make_path_1(x, s, f):
        '''
        Use this function to get result of "hanoi_func_1"
        x - number of blocks in tower
        s - number of pole where tower is located
        f - number of pole where tower should be moved to
        
        This function is used when all the blocks are in one tower.
        '''
        
        global res_1, res_2
        res_1 = []
        hanoi_func_1(x, s, f)
        
        ####
        # adds all the moves to the general list of moves
        #
        for i in res_1:
            res_2.append(i)

        
    def hanoi_func_1(x, s, f):
        '''
        x - number of blocks in tower
        s - number of pole where tower is located
        f - number of pole where tower should be moved to
        
        The function returns the list of tuples that are
        (start_pole, finish_pole) that describes moves that
        should be made from last to first to win the game.
        
        So when function will return that list, one should pop
        tuples out of it one after another and move blocks
        from "start_pole" position to "finish_pole" position.
        
        In general, to move n-block tower from start pole to finish pole,
        one must move (n-1)-block tower to the pole
        that is neither start nor finish one,
        then move the n-block to the finish pole
        and move (n-1)-block tower to the finish pole
        '''
        
        global res_1
        if x == 1:
            res_1.append((s, f))
        else:
            ####
            # ff is the free pole that neither start nor finish one
            # for current tower
            ff = [0,1,2]
            ff.remove(s)
            ff.remove(f)
            ff = ff[0]
            hanoi_func_1(x-1, ff, f)
            res_1.append((s, f))
            hanoi_func_1(x-1, s, ff)
        return res_1




label hanoi_game(blocks_number=8): # sets the default number of blocks
    
    ####
    # a list of colors for maximum number of blocks
    # this can be colors or images,
    # if you need all the blocks to be the same color
    # just add this color to the list several times
    $ block_colors = ["#c00", "#0c0", "#00c", "#cc0", "#c0c", "#0cc", "#930", "#ccc"]

    $ block_colors = [texture1, texture2, texture3, texture4, texture1, texture2, texture3, texture4]
    
    ####
    # number of blocks in tower shouldn't be greater
    # then the number of colors in block_colors list
    if blocks_number > len(block_colors):
        $ blocks_number = len(block_colors)
        
    ####
    # creates the blocks description
    $ blocks_set = []
    python:
        for b in range(1, blocks_number+1):
            blocks_set.append({"size": b, "color":block_colors[b-1]} )
    
    ####
    # randomly sets the start and finish poles
    $ a = [0,1,2]
    $ start_tower = renpy.random.choice(a)
    $ a.remove(start_tower)
    $ finish_tower = renpy.random.choice(a)
    
    ####
    # the height of the block in pixels
    $ block_size = 20
    
    ####
    # the positions for all 3 towers
    $ towers_pos = [(0.25, 0.65), (0.5, 0.65), (0.75, 0.65)]
    
    ####
    # main game variable - description of towers
    $ towers = [ {"tower_pos":towers_pos[0],"blocks":[], "mark":None},
        {"tower_pos":towers_pos[1],"blocks":[], "mark":None},
        {"tower_pos":towers_pos[2],"blocks":[], "mark":None}
        ]
    
    ####
    # put the blocks, start and finish marks on their places
    $ towers[start_tower]["blocks"] = blocks_set
    $ towers[start_tower]["mark"] = "start"
    $ towers[finish_tower]["mark"] = "finish"
    
    ####
    # flags that are used for autosolve function
    $ autosolve = False
    $ create_movements_list = False
    
    ####
    # game variables
    $ delay_time = 0.2
    $ player_moves = 0
    $ minimal_moves = hanoi_moves_count(blocks_number)
    
    ####
    # let's show the game screen
    show screen hanoi_game_screen(towers=towers)
    
    
    ####
    # main game loop
    label hanoi_loop:
        
        ####
        # default values that shows that player haven't decided yet
        # what move to do
        $ start_from_tower = -1
        $ finish_to_tower = -1
        
        ####
        # wait for user interact
        if not autosolve:
            $ can_click = True
            $ ui.interact()
        
        ####
        # to prevent farther interactions
        $ can_click = False
        
        ####
        # autosolve function
        if autosolve:
            
            ####
            # create list of moves
            if create_movements_list:
                ####
                # we need to make this list only once
                $ create_movements_list = False
                
                ####
                # make_path_2 function needs "t" - that is list of 3 list
                # that contains only blocks numbers
                # so create it from main game variable "towers"
                $ t = []
                python:
                    for i in towers:
                        tt = []
                        for j in i["blocks"]:
                            tt.append(j["size"])
                            
                        t.append(tt)
                
                ####
                # and now, let's make the list of moves
                $ movements_list = make_path_2(t, blocks_number, finish_tower)
                
            ####
            # move to make (the last one in movements_list)
            $ start_from_tower, finish_to_tower = movements_list.pop()
            
        
        ####
        # move the block
        $ block_to_move = towers[start_from_tower]["blocks"][0]
        
        $ towers[start_from_tower]["blocks"] = towers[start_from_tower]["blocks"][1:]
        $ towers[finish_to_tower]["blocks"].insert(0, block_to_move)
        
        ####
        # add one "move" to counter
        $ player_moves += 1
        
        ####
        # check the game state
        if check_game_state():
            jump win
            
        ####
        # make pause between moves if autosolve is enaible
        if autosolve:
            $ renpy.pause(delay_time)
            
        ####
        # next move
        jump hanoi_loop
        
        
label win:
    ####
    # to prevent farther interactions
    $ can_click = False
    
    if player_moves > minimal_moves:
        "You Win!\nIt takes [player_moves] moves."
    else:
        "Perfect Win!\nIt takes [player_moves] moves."
        
    hide screen hanoi_game_screen
    
    return
    
label give_up:
    ####
    # to prevent farther interactions
    $ can_click = False
    
    ####
    # to stop autosolve
    $ autosolve = False
    
    "Good luck next time..."
    
    hide screen hanoi_game_screen
    
    return
    



# The game starts here.
label start:
    scene black
    "..."
    call hanoi_game(blocks_number=8) # pass the desireble number of blocks

    jump start
pole.png
pole.png (6.33 KiB) Viewed 894 times
texture1.png
texture1.png (52.21 KiB) Viewed 894 times
texture2.png
texture2.png (55.89 KiB) Viewed 894 times
texture3.png
texture3.png (41.3 KiB) Viewed 894 times
texture4.png
texture4.png (56.48 KiB) Viewed 894 times

User avatar
Helyees
Regular
Posts: 102
Joined: Tue Mar 08, 2016 3:14 pm
Projects: Panzer Hearts
Contact:

Re: Simple minigames (Screen Language only).

#32 Post by Helyees » Tue Mar 08, 2016 3:24 pm

Hi!

I have one question concerning my modification of the "Numbers" mini game. I im trying to change numbers into pictures, but have trouble having them shown correctly on the hint bar.
Only one picture (which should be last in line) is show but not the others. The one picture is also not fitting into the bar too well. I wonder what could I do?
THis is my code:

Code: Select all

transform roto_transform (roto_var):
    # ATL transform that will rotate our displayables to "roto_var" degrees
    rotate roto_var
    rotate_pad False

##### The game screen
screen numbers_scr:
    
    ##### Timer
    #
    # It returns "smth" every second and "win" (if all buttons were clicked) or "lose" (if time was up)
    timer 1 action [Return("smth"), If( game_timer>1, If( numbers_buttons[-1]["b_to_show"] == False, Return("win"), SetVariable("game_timer", game_timer-1) ), Return("lose") ) ] repeat True
    text "[game_timer]" size 25 xpos 10 ypos 10

    
    for each_b in sorted(numbers_buttons, reverse=True):
        if each_b["b_to_show"]:
            $ text_var = each_b["b_value"]
            $ i = each_b["b_number"] - 1
            button:
                
                # Will show image if "b_value" was set as file name or displayable.
                background None
                add each_b["b_value"]
                # Also it is neccessary to comment out the next  4 lines.
                

                xminimum 100 xmaximum 100
                yminimum 100 ymaximum 100
                xpos each_b["b_x_pos"]
                ypos each_b["b_y_pos"]
                anchor (0.5, 0.5)
                action If (i == -1, SetDict(numbers_buttons[each_b["b_number"] ], "b_to_show", False),
                    If (numbers_buttons[i]["b_to_show"] == False,
                        SetDict(numbers_buttons[each_b["b_number"] ], "b_to_show", False),
                        SetVariable("game_timer", game_timer-1) )  )          # Wrong click reduces the time left by 1 second
                at roto_transform (renpy.random.randint (0, 10)*36)
        
                
    
    # It might be usefull to show the order of buttons to click if it's not obvious.
    side "c b":
        area (150, 05, 640, 70)         # The size of hint's area
        
        viewport id "vp":
            draggable False
            
            hbox:
                xalign 1.0
                
                # The same buttons declaration, but they will be scaled down
                for each_b in numbers_buttons:
                    $ text_var = each_b["b_value"]

                button:
                        
                                        
                        # Will show image if "b_value" was set as file name or displayable.
                        background None
                        add each_b["b_value"]
                        # Also it is neccessary to comment out the next  4 lines.
                
                        #background "image.png"          # Sets button's appearance
                        xminimum 100 xmaximum 100
                        yminimum 100 ymaximum 100
                        action If (each_b["b_to_show"], Hide("nonexistent_screen"), None)
                        at Transform(zoom=0.5)           # Size
        
        bar value XScrollValue("vp")
        

image img1 = "img1.png"
image img2 = "img2.png"
image img3 = "img3.png"

label start:
    
    #####
    #
    # At first, let's set the values for buttons
    $ numbers_buttons = []
    $ buttons_values = ["img1.png", "img2.png", "img3.png"]
    
    # This might be numbers,
    #python:
    #    for i in range (1, renpy.random.randint (10, 15) ):
    #       buttons_values.append (str(i) )
    
    # or letters,
    #$ buttons_values = [u"а", u"б", u"в", u"г", u"д", u"е", u"ё", u"ж", u"з", u"и", u"й", u"к", u"л", u"м", u"н", u"о", u"п", u"р", u"с", u"т", u"у", u"ф", u"х", u"ц", u"ч", u"ш", u"щ", u"ъ", u"ы", u"ь", u"э", u"ю", u"я" ]

    #or images,
    $ buttons_values = ["img1.png", "img2.png", "img3.png"]

    # This will make the description for all buttons (numbers, values and positions)

    
    python:
        for i in range (0, len(buttons_values) ):
            numbers_buttons.append ( {"b_number":i, "b_value":buttons_values[i], "b_x_pos":(renpy.random.randint (10, 70))*10, "b_y_pos":(renpy.random.randint (15, 50))*10, "b_to_show":True} )
    
    "To win the game - click all the buttons one after another (start from \"1\")."
    
    # Before start the game, let's set the timer
    $ game_timer = 20
    
    # Shows the game screen
    show screen numbers_scr
    
    # The loop will exist untill game screen returns win or lose
    label loop:
        $ result = ui.interact()
        $ game_timer = game_timer
        if result == "smth":
            jump loop

    if result == "lose":
        hide screen numbers_scr
        $ renpy.pause (0.1, hard = True)
        $ renpy.pause (0.1, hard = True)
        $ renpy.pause (0.1, hard = True)
        $ renpy.pause (0.1, hard = True)
        "You lose! Try again."
        jump numbers_game
        
    if result == "win":
        hide screen numbers_scr
        $ renpy.pause (0.1, hard = True)
        $ renpy.pause (0.1, hard = True)
        $ renpy.pause (0.1, hard = True)
        $ renpy.pause (0.1, hard = True)
        "You win!"
        return
Added a screenshot about how it looks at the moment.
Any help is much appreciated!
BR/ Esko

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

Re: Simple minigames (Screen Language only).

#33 Post by Alex » Thu Mar 10, 2016 12:56 pm

Hi, Esco!
The first problem is caused by wrong indentation (for now all the hint images shown one over another, so you can see only the top one), try

Code: Select all

# It might be usefull to show the order of buttons to click if it's not obvious.
    side "c b":
        area (150, 05, 640, 70)         # The size of hint's area
        
        viewport id "vp":
            draggable False
            
            hbox:
                xalign 1.0
                
                # The same buttons declaration, but they will be scaled down
                for each_b in numbers_buttons:
                    $ text_var = each_b["b_value"]

                    button:    <-------- here it is
                        
                                        
                        # Will show image if "b_value" was set as file name or displayable.
                        background None
                        add each_b["b_value"]
                        # Also it is neccessary to comment out the next  4 lines.
                
                        #background "image.png"          # Sets button's appearance
                        xminimum 100 xmaximum 100
                        yminimum 100 ymaximum 100
                        action If (each_b["b_to_show"], Hide("nonexistent_screen"), None)
                        at Transform(zoom=0.5)           # Size
        
        bar value XScrollValue("vp")
And as for the size of hint images - you need to tweak the code a bit.

Code: Select all

area (150, 05, 640, 70)         # The size of hint's area
this line sets the hints area to be at position (150, 05) and 640 / 70 pxls width / height, so try to change 70 to some greater value.

Also, this line

Code: Select all

at Transform(zoom=0.5)           # Size
creates hint image from the original one by scaling it 50% down, try to make hint image smaller, like

Code: Select all

at Transform(zoom=0.2)           # Size 

User avatar
Helyees
Regular
Posts: 102
Joined: Tue Mar 08, 2016 3:14 pm
Projects: Panzer Hearts
Contact:

Re: Simple minigames (Screen Language only).

#34 Post by Helyees » Fri Mar 11, 2016 4:42 am

Thank you Alex for this!

User avatar
Boniae
Regular
Posts: 164
Joined: Fri Apr 10, 2009 4:10 pm
Completed: I want 2 be single and Forget-Me-Not
Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
Organization: Rosewater Games
Tumblr: boniae
Location: Cleveland, OH
Contact:

Re: Simple minigames (Screen Language only).

#35 Post by Boniae » Sun Jun 05, 2016 9:22 pm

Hi Alex! I've set up the memoria game and it works great. I do have a question about adding a feature in the game, I just don't know how to execute it. Each of my cards have a face of a character in the game (2 pairs each, 12 cards total), and I want to make it so that the first match the player finds will go to a scene with that character upon winning. So if the player picks a card value of A on the first try, and also finishes finding the matches, it will go to x. I can't really wrap my head around going about it though, so any help would be appreciated. Thanks for reading!

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

Re: Simple minigames (Screen Language only).

#36 Post by Alex » Tue Jun 07, 2016 2:00 pm

Hi, Boniae!
You can make another variable, like "first_match" give it any default value, then add some checking in code - if cards match and your variable has default value then set it to value of matched cards. So later in game you'll be able to use the value of this variable.

Code: Select all

label memoria_game:
    $  first_match = " "
... etc.

Code: Select all

# If cards are matched, will check if player has opened all the cards
        else:
            if first_match == " ":
                $ first_match = str(turned_cards_values[0])

            $ renpy.pause (1.0, hard = True)
            python: 
                
                # Let's remove opened cards from game field
                # But if you prefere to let them stay - just comment out next 2 lines
                for i in range (0, len(turned_cards_numbers) ):
                    cards_list[turned_cards_numbers[i]]["c_value"] = Null()

                for j in cards_list:
                    if j["c_chosen"] == False:
                        renpy.jump ("memo_game_loop")
                renpy.jump ("memo_game_win")
 ...etc.
And somewhere in game script

Code: Select all

if first_match == "A":   # "A", "B", etc. are the names of images that was used as values for cards

User avatar
Boniae
Regular
Posts: 164
Joined: Fri Apr 10, 2009 4:10 pm
Completed: I want 2 be single and Forget-Me-Not
Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
Organization: Rosewater Games
Tumblr: boniae
Location: Cleveland, OH
Contact:

Re: Simple minigames (Screen Language only).

#37 Post by Boniae » Sat Jun 11, 2016 8:07 pm

Thanks so much Alex, it works like a charm!

TrebleTriangle
Newbie
Posts: 6
Joined: Sat Jun 04, 2016 11:37 am
Location: A place with lots of mountains and trees.
Contact:

Re: Simple minigames (Screen Language only).

#38 Post by TrebleTriangle » Fri Jun 17, 2016 4:20 pm

Hello.
I have a question about the "numbers" minigame.

How do I make the hints show up?

(Sorry if this isn't the right place to ask this. I'm still new so I'm a bit confused...)

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

Re: Simple minigames (Screen Language only).

#39 Post by Alex » Fri Jun 17, 2016 5:16 pm

Hi! This is the right place to ask. But what do you mean by "make hints show up"? If you've copy/pasted the code as is then there should be the hints area where the order of buttons is shown. If the hints area is not shown then you need to show the code you have to check what's wrong.

TrebleTriangle
Newbie
Posts: 6
Joined: Sat Jun 04, 2016 11:37 am
Location: A place with lots of mountains and trees.
Contact:

Re: Simple minigames (Screen Language only).

#40 Post by TrebleTriangle » Sat Jun 18, 2016 5:27 am

I copy and pasted the code EXACTLY as is:

Code: Select all

    # It might be usefull to show the order of buttons to click if it's not obvious.
    side "c b":
        area (150, 05, 640, 70)         # The size of hint's area
        
        viewport id "vp":
            draggable True
            
            hbox:
                xalign 1.0
                
                # The same buttons declaration, but they will be scaled down
                for each_b in numbers_buttons:
                    $ text_var = each_b["b_value"]
                    button:
                                        
                        # Will show image if "b_value" was set as file name or displayable.
                        #background None
                        #add each_b["b_value"]
                        # Also it is neccessary to comment out the next  4 lines.
                
                        #background "image.png"          # Sets button's appearance
                        text '[text_var]{size=18}.{/size}' size 30 align (0.5, 0.55) color "#000"
                        xminimum 100 xmaximum 100
                        yminimum 100 ymaximum 100
                        action If (each_b["b_to_show"], Hide("nonexistent_screen"), None)
                        at Transform(zoom=0.5)           # Size
        
        bar value XScrollValue("vp")
That's the code in my script.rpy
When I tested it, the hints aren't there...

The hints are supposed to be above that bar, right? :?
Attachments
screenshot0004.png
Hints not there

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

Re: Simple minigames (Screen Language only).

#41 Post by Alex » Sat Jun 18, 2016 12:25 pm

That's strange... I've copy/pasted the code and it worked fine...
Try to move the thumb of horizontal scrollbar to the left - maybe hint are hiden outside the area? Could you send the zip of the project to let me see the problem?

TrebleTriangle
Newbie
Posts: 6
Joined: Sat Jun 04, 2016 11:37 am
Location: A place with lots of mountains and trees.
Contact:

Re: Simple minigames (Screen Language only).

#42 Post by TrebleTriangle » Sun Jun 19, 2016 12:41 am

I just realized I copied the code into a project I used to test a different code. Woops!
And I did changed the code slightly, but I only added images.

I recopy/pasted the code in a new project just to be sure.
It still doesn't work... :(
Attachments
junm.zip
(300.8 KiB) Downloaded 56 times
screenshot0008.png
in new project

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

Re: Simple minigames (Screen Language only).

#43 Post by Alex » Sun Jun 19, 2016 6:44 am

Hm, I ran the project you've posted and it worked fine for me... Try to run your project on a different computer to see if it will work. Also, try to run the tutorial game that is shipped with Ren'Py - do you have any glitches with buttons when you choosing the topic to learn? If it works fine then I just have no clue what's causing this problem.

TrebleTriangle
Newbie
Posts: 6
Joined: Sat Jun 04, 2016 11:37 am
Location: A place with lots of mountains and trees.
Contact:

Re: Simple minigames (Screen Language only).

#44 Post by TrebleTriangle » Sun Jun 19, 2016 9:32 am

When I first ran the tutorial game, the buttons to choose the topics worked just fine.
But at some point they disappeared.
When I deleted the persistent data of the tutorial the buttons reappeared.

I tried to do the same with that project, but didn't worked...

I also tried it in a different computer, and it also didn't work.

Maybe it has something to do with my operating system?
(Both computers used the same one, which is Windows 7 Service Pack 1)

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

Re: Simple minigames (Screen Language only).

#45 Post by Alex » Sun Jun 19, 2016 2:27 pm

Uh, then run your project, press Shift+G, and try the different options. Hope this will help...

Post Reply

Who is online

Users browsing this forum: No registered users