[SOLVED] "Fox, Goose, Beans" puzzle button issues

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
User avatar
Mole-chan
Veteran
Posts: 333
Joined: Thu Aug 27, 2009 12:46 am
Completed: DUAEL, Escape from Puzzlegate
Projects: A Bird with Gold-Mended Wings
Deviantart: mole-chan
Skype: mole-chan
itch: moleworks
Contact:

[SOLVED] "Fox, Goose, Beans" puzzle button issues

#1 Post by Mole-chan »

So I'm trying to do a simple "fox, goose, bag of beans" style riddle utilizing buttons and moving images.

The basic gist is that the player clicks the button, a variable is switched that hides the button and moves an image that was hidden underneath it. Pretty simple.

But for some reason the buttons stop working in one of two scenarios:

1. Two turns pass.

2. The button is supposed to reappear at the left side. It never does.

Also, the last image (in this case, the bag of beans), has a habit of jumping around if transported first. If it's removed, the next set up does this. Oddly enough, the bag of beans seem to be the only ones where the button makes it to the left correctly.

Considering all the objects are handled identically..I'm not sure what the deal is.

Here is the code, if it helps.

Code: Select all

label init_puzzle:
    $ renpy.block_rollback()
    python:
        fox_position = 'right'
        fox_moving = False
        goose_position = 'right'
        goose_moving = False
        beans_position = 'right'
        beans_moving = False
        raft_position = 'right'
        raft_moving = False
        RAFT_Y = .6
        
        FOX_Y = .1
        GOOSE_Y = .25
        BEANS_Y = .4
        RAFT_Y = .6
        
        RIGHT_X = .8
        LEFT_X = .2
        
        firstMove = False
        solved = False
    
label transport_puzzle:
    
    scene puzzle_river
   
    show raft:
        xpos RIGHT_X ypos RAFT_Y
    
    show fox:
        xpos RIGHT_X ypos FOX_Y
    show goose:
        xpos RIGHT_X ypos GOOSE_Y
    show beans:
        xpos RIGHT_X ypos BEANS_Y
    
    #set up all the buttons/images according to variables

    #FOX
    if fox_position == 'right' and fox_moving == False:
        show fox:
            xpos RIGHT_X ypos FOX_Y
        $ui.imagebutton("gfx/fox.png", "gfx/fox.png", clicked=ui.returns(("fox", None)), xpos = RIGHT_X, ypos = FOX_Y )

    elif fox_position == 'right' and fox_moving:
        
        if raft_position != fox_position:
            show raft:
                xpos LEFT_X ypos RAFT_Y
                ease 3.0 xpos RIGHT_X ypos FOX_Y
            $renpy.pause(3.0)
        show raft:
            xpos RIGHT_X ypos FOX_Y
            ease 3.0 xpos LEFT_X ypos FOX_Y
        show fox:
            xpos RIGHT_X ypos FOX_Y
            ease 3.0 xpos LEFT_X ypos FOX_Y
        $raft_position = fox_position = "left"
        $fox_moving = False
        $RAFT_Y = FOX_Y
    elif fox_position == "left" and fox_moving == False:
        show fox:
            xpos LEFT_X ypos FOX_Y
        $ui.imagebutton("gfx/fox.png", "gfx/fox.png", clicked=ui.returns(("fox", None)), xpos = LEFT_X, ypos = FOX_Y )
        
    else:
        
        if raft_position != fox_position:
            show raft:
                xpos RIGHT_X ypos RAFT_Y
                ease 3.0 xpos LEFT_X ypos FOX_Y
            $renpy.pause(3.0)
        show fox:
            xpos LEFT_X ypos FOX_Y
            ease 3.0 xpos RIGHT_X ypos FOX_Y
        show raft:
            xpos LEFT_X ypos FOX_Y
            ease 3.0 xpos RIGHT_X ypos FOX_Y
        $raft_position = fox_position = "right"
        $fox_moving = False
        $RAFT_Y = FOX_Y
    #GOOSE        
    
    if goose_position == 'right' and goose_moving == False:
        show goose:
            xpos RIGHT_X ypos GOOSE_Y
        $ui.imagebutton("gfx/goose.png", "gfx/goose.png", clicked=ui.returns(("goose", None)), xpos = RIGHT_X, ypos = GOOSE_Y )

    elif goose_position == 'right' and goose_moving:

        if raft_position != goose_position:
            show raft:
                xpos LEFT_X ypos RAFT_Y
                ease 3.0 xpos RIGHT_X ypos GOOSE_Y
            $renpy.pause(3.0)
        show goose:
            xpos RIGHT_X ypos GOOSE_Y
            ease 3.0 xpos LEFT_X ypos GOOSE_Y
            
        show raft:
            xpos RIGHT_X ypos GOOSE_Y
            ease 3.0 xpos LEFT_X ypos GOOSE_Y
        $raft_position = goose_position = "left"
        $goose_moving = False
        $RAFT_Y = GOOSE_Y
    elif goose_position == "left" and goose_moving == False:
        show goose:
            xpos LEFT_X ypos GOOSE_Y
        $ui.imagebutton("gfx/goose.png", "gfx/goose.png", clicked=ui.returns(("goose", None)), xpos = LEFT_X, ypos = GOOSE_Y )
        
    else:
        
        if raft_position != goose_position:
            show raft:
                xpos LEFT_X ypos RAFT_Y
                ease 3.0 xpos RIGHT_X ypos GOOSE_Y
            $renpy.pause(3.0)
        show goose:
            xpos LEFT_X ypos GOOSE_Y
            ease 3.0 xpos RIGHT_X ypos GOOSE_Y
            
        show raft:
            xpos LEFT_X ypos GOOSE_Y
            ease 3.0 xpos RIGHT_X ypos GOOSE_Y
        $raft_position = goose_position = "right"
        $goose_moving = False
        $RAFT_Y = GOOSE_Y
        
    #BEANS
    
    if beans_position == 'right' and beans_moving == False:
        show beans:
            xpos RIGHT_X ypos BEANS_Y
        $ui.imagebutton("gfx/beans.png", "gfx/beans.png", clicked=ui.returns(("beans", None)), xpos = RIGHT_X, ypos = BEANS_Y )

    elif beans_position == 'right' and beans_moving:
        
        if raft_position != beans_position:
            show raft:
                xpos LEFT_X ypos RAFT_Y
                ease 3.0 xpos RIGHT_X ypos BEANS_Y
            $renpy.pause(3.0)
        show raft:
            xpos RIGHT_X ypos BEANS_Y
            ease 3.0 xpos LEFT_X ypos BEANS_Y
        show beans:
            xpos RIGHT_X ypos BEANS_Y
            ease 3.0 xpos LEFT_X ypos BEANS_Y
        $raft_position = beans_position = "left"
        $RAFT_Y = BEANS_Y
        $beans_moving = False
    elif beans_position == "left" and beans_moving == False:
        show beans:
            xpos LEFT_X ypos BEANS_Y
        $ui.imagebutton("gfx/beans.png", "gfx/beans.png", clicked=ui.returns(("beans", None)), xpos = LEFT_X, ypos = BEANS_Y )
        
    else:
        
        if raft_position != beans_position:
            show raft:
                xpos RIGHT_X ypos RAFT_Y
                ease 3.0 xpos LEFT_X ypos BEANS_Y
            $renpy.pause(3.0)
        show raft:
            xpos LEFT_X ypos BEANS_Y
            ease 3.0 xpos RIGHT_X ypos BEANS_Y
        show beans:
            xpos LEFT_X ypos BEANS_Y
            ease 3.0 xpos RIGHT_X ypos BEANS_Y
        $raft_position = beans_position = "right"
        $RAFT_Y = BEANS_Y
        $beans_moving = False
        
    $result = ui.interact()
    $moveWhat =result[0]
    
    if moveWhat == "fox":
        if not firstMove:
            $firstMove = True
        $fox_moving = True
        
    if moveWhat == "goose":
        if not firstMove:
            $firstMove = True
        $goose_moving = True
    if moveWhat == "beans":
        if not firstMove:
            $firstMove = True
        $beans_moving = True
        
    if firstMove and not solved:
        if fox_position == 'left' and goose_position == 'left' and goose_position != beans_position:
            jump final_puzzle_lose
            #puzzle lost
            
        if goose_position == 'left' and beans_position == 'left' and fox_position != goose_position:
            jump final_puzzle_lose
            #puzzle lost
        if goose_position == 'left' and fox_position == 'left' and beans_position == 'left':
            jump final_puzzle_win
            $solved = True
            #puzzle won
        
    jump transport_puzzle
        
label final_puzzle_lose:
    "You lose. Try again?" #obviously placeholder
    jump init_puzzle
     
label final_puzzle_win:
    "You win! Yay!" #again, really placeholder
I'm aware the rules handling right now is pretty spotty. For now I just want to get the images working.

Any help would be appreciated, thank you!
Last edited by Mole-chan on Sun Mar 16, 2014 9:27 pm, edited 1 time in total.

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: "Fox, Goose, Beans" puzzle button issues

#2 Post by apricotorange »

1. You should really consider using screen language. It generally makes your code easier to read for complicated UIs, and you're much less likely to make subtle mistakes like you did in this example.

2. After every interaction (when you call renpy.pause(), when you call ui.interact(), when a character speaks, etc.), all UI gets cleared away automatically so it can be recomputed. The buttons get cleared away after each call to renpy.pause().

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

Re: "Fox, Goose, Beans" puzzle button issues

#3 Post by Alex »

Kind of example (looks terrible, but seems to be working...)

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")

screen boat_scr:
    zorder 3
    
    if boat_start:
        if boat == "left":
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click, [ToggleVariable("boat", "right", "left"), SetVariable("boat_start", False), Show("boat_scr"), Return("smth")], None) xalign 0.4 yalign 0.5
        else:
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click,[ToggleVariable("boat", "right", "left"), SetVariable("boat_start", False), Show("boat_scr"), Return("smth")], None) xalign 0.6 yalign 0.5
            
    else:
        if boat == "left":
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click,[ToggleVariable("boat", "right", "left"), Show("boat_scr"), Return("smth")], None) at boat_left
        else:
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click,[ToggleVariable("boat", "right", "left"), Show("boat_scr"), Return("smth")], None) at boat_right
            
            
screen fox_scr:
    zorder 5
    
    if fox_start:
        if fox == "left":
            textbutton "fox" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), ToggleVariable("fox_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) xalign 0.3 yalign 0.4
        else:
            textbutton "fox" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), ToggleVariable("fox_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) xalign 0.7 yalign 0.4
            
    else:
        if fox == "left":
            textbutton "fox" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) at fox_left
        else:
            textbutton "fox" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) at fox_right
            
            
screen goose_scr:
    zorder 5
    
    if goose_start:
        if goose == "left":
            textbutton "goose" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), ToggleVariable("goose_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) xalign 0.3 yalign 0.5
        else:
            textbutton "goose" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), ToggleVariable("goose_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) xalign 0.7 yalign 0.5
            
    else:
        if goose == "left":
            textbutton "goose" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) at goose_left
        else:
            textbutton "goose" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) at goose_right
            
            
screen beans_scr:
    zorder 5
    
    if beans_start:
        if beans == "left":
            textbutton "beans" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), ToggleVariable("beans_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) xalign 0.3 yalign 0.6
        else:
            textbutton "beans" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), ToggleVariable("beans_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) xalign 0.7 yalign 0.6
            
    else:
        if beans == "left":
            textbutton "beans" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) at beans_left
        else:
            textbutton "beans" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) at beans_right
            
        
transform boat_left:

        xalign 0.6 yalign 0.5
        0.5
        linear 1.0 xalign 0.4

transform boat_right:

        xalign 0.4 yalign 0.5
        0.5
        linear 1.0 xalign 0.6

transform fox_left:

        xalign 0.7 yalign 0.4

        parallel:
            linear 0.5 xalign 0.6
            linear 1.0 xalign 0.4
            linear 0.5 xalign 0.3
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.4

transform fox_right:
 
        xalign 0.3 yalign 0.4
        
        parallel:
            linear 0.5 xalign 0.4
            linear 1.0 xalign 0.6
            linear 0.5 xalign 0.7
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.4
            

transform goose_left:

        xalign 0.7 yalign 0.5

        parallel:
            linear 0.5 xalign 0.6
            linear 1.0 xalign 0.4
            linear 0.5 xalign 0.3
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.5

transform goose_right:
 
        xalign 0.3 yalign 0.5
        
        parallel:
            linear 0.5 xalign 0.4
            linear 1.0 xalign 0.6
            linear 0.5 xalign 0.7
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.5
            

transform beans_left:

        xalign 0.7 yalign 0.6

        parallel:
            linear 0.5 xalign 0.6
            linear 1.0 xalign 0.4
            linear 0.5 xalign 0.3
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.6

transform beans_right:
 
        xalign 0.3 yalign 0.6
        
        parallel:
            linear 0.5 xalign 0.4
            linear 1.0 xalign 0.6
            linear 0.5 xalign 0.7
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.6
            
     
label fgb_puzzle:
    $ river_side, target_side = renpy.random.choice([("left", "right"), ("right", "left")])
    $ fox = river_side
    $ goose = river_side
    $ beans = river_side
    $ boat = river_side
    $ fox_start = True
    $ goose_start = True
    $ beans_start = True
    $ boat_start = True
    $ counter = 0
    $ can_click = False
    
    scene black # background
    
    show screen boat_scr
    show screen fox_scr
    show screen goose_scr
    show screen beans_scr
    
    
    label fgb_loop:
        $ can_click = True
        $ res = ui.interact()
        $ can_click = False
        $ counter += 1
        $ renpy.pause(2.0, hard=True)
        if fox == goose and fox != boat:
            hide screen goose_scr
            with dissolve
            "Fox ate goose..."
            jump fgb_loose
        elif goose == beans and goose != boat:
            hide screen beans_scr
            with dissolve
            "Goose ate beans..."
            jump fgb_loose
        elif fox == target_side and goose == target_side and beans == target_side:
            "Well done. (it takes [counter] moves)"
            return
        else:
            jump fgb_loop
    
label fgb_loose:
    hide screen boat_scr
    hide screen fox_scr
    hide screen goose_scr
    hide screen beans_scr
    
    "Try again"
    jump fgb_puzzle
    
    
    
    
# The game starts here.
label start:

    e "You've created a new Ren'Py game."
    call fgb_puzzle from fgb_1
    "and once again..."
    call fgb_puzzle from fgb_2
    e "Once you add a story, pictures, and music, you can release it to the world!"

    return

User avatar
Mole-chan
Veteran
Posts: 333
Joined: Thu Aug 27, 2009 12:46 am
Completed: DUAEL, Escape from Puzzlegate
Projects: A Bird with Gold-Mended Wings
Deviantart: mole-chan
Skype: mole-chan
itch: moleworks
Contact:

Re: "Fox, Goose, Beans" puzzle button issues

#4 Post by Mole-chan »

apricotorange wrote:1. You should really consider using screen language. It generally makes your code easier to read for complicated UIs, and you're much less likely to make subtle mistakes like you did in this example.

2. After every interaction (when you call renpy.pause(), when you call ui.interact(), when a character speaks, etc.), all UI gets cleared away automatically so it can be recomputed. The buttons get cleared away after each call to renpy.pause().
Oh, of course! Well don't I feel stupid. That's really obvious in retrospect. ;v;
Alex wrote:Kind of example (looks terrible, but seems to be working...)

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")

screen boat_scr:
    zorder 3
    
    if boat_start:
        if boat == "left":
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click, [ToggleVariable("boat", "right", "left"), SetVariable("boat_start", False), Show("boat_scr"), Return("smth")], None) xalign 0.4 yalign 0.5
        else:
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click,[ToggleVariable("boat", "right", "left"), SetVariable("boat_start", False), Show("boat_scr"), Return("smth")], None) xalign 0.6 yalign 0.5
            
    else:
        if boat == "left":
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click,[ToggleVariable("boat", "right", "left"), Show("boat_scr"), Return("smth")], None) at boat_left
        else:
            textbutton "XXXXXX\nXXXXXX\nXXXXXX" action If(can_click,[ToggleVariable("boat", "right", "left"), Show("boat_scr"), Return("smth")], None) at boat_right
            
            
screen fox_scr:
    zorder 5
    
    if fox_start:
        if fox == "left":
            textbutton "fox" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), ToggleVariable("fox_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) xalign 0.3 yalign 0.4
        else:
            textbutton "fox" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), ToggleVariable("fox_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) xalign 0.7 yalign 0.4
            
    else:
        if fox == "left":
            textbutton "fox" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) at fox_left
        else:
            textbutton "fox" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("fox", "right", "left"), Show("boat_scr"), Show("fox_scr"), Return("smth")], None) at fox_right
            
            
screen goose_scr:
    zorder 5
    
    if goose_start:
        if goose == "left":
            textbutton "goose" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), ToggleVariable("goose_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) xalign 0.3 yalign 0.5
        else:
            textbutton "goose" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), ToggleVariable("goose_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) xalign 0.7 yalign 0.5
            
    else:
        if goose == "left":
            textbutton "goose" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) at goose_left
        else:
            textbutton "goose" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("goose", "right", "left"), Show("boat_scr"), Show("goose_scr"), Return("smth")], None) at goose_right
            
            
screen beans_scr:
    zorder 5
    
    if beans_start:
        if beans == "left":
            textbutton "beans" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), ToggleVariable("beans_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) xalign 0.3 yalign 0.6
        else:
            textbutton "beans" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), ToggleVariable("beans_start"), SetVariable("boat_start", False), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) xalign 0.7 yalign 0.6
            
    else:
        if beans == "left":
            textbutton "beans" action If(boat == "left" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) at beans_left
        else:
            textbutton "beans" action If(boat == "right" and can_click, [ToggleVariable("boat", "right", "left"), ToggleVariable("beans", "right", "left"), Show("boat_scr"), Show("beans_scr"), Return("smth")], None) at beans_right
            
        
transform boat_left:

        xalign 0.6 yalign 0.5
        0.5
        linear 1.0 xalign 0.4

transform boat_right:

        xalign 0.4 yalign 0.5
        0.5
        linear 1.0 xalign 0.6

transform fox_left:

        xalign 0.7 yalign 0.4

        parallel:
            linear 0.5 xalign 0.6
            linear 1.0 xalign 0.4
            linear 0.5 xalign 0.3
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.4

transform fox_right:
 
        xalign 0.3 yalign 0.4
        
        parallel:
            linear 0.5 xalign 0.4
            linear 1.0 xalign 0.6
            linear 0.5 xalign 0.7
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.4
            

transform goose_left:

        xalign 0.7 yalign 0.5

        parallel:
            linear 0.5 xalign 0.6
            linear 1.0 xalign 0.4
            linear 0.5 xalign 0.3
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.5

transform goose_right:
 
        xalign 0.3 yalign 0.5
        
        parallel:
            linear 0.5 xalign 0.4
            linear 1.0 xalign 0.6
            linear 0.5 xalign 0.7
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.5
            

transform beans_left:

        xalign 0.7 yalign 0.6

        parallel:
            linear 0.5 xalign 0.6
            linear 1.0 xalign 0.4
            linear 0.5 xalign 0.3
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.6

transform beans_right:
 
        xalign 0.3 yalign 0.6
        
        parallel:
            linear 0.5 xalign 0.4
            linear 1.0 xalign 0.6
            linear 0.5 xalign 0.7
        parallel:
            linear 0.5 yalign 0.5
            1.0
            linear 0.5 yalign 0.6
            
     
label fgb_puzzle:
    $ river_side, target_side = renpy.random.choice([("left", "right"), ("right", "left")])
    $ fox = river_side
    $ goose = river_side
    $ beans = river_side
    $ boat = river_side
    $ fox_start = True
    $ goose_start = True
    $ beans_start = True
    $ boat_start = True
    $ counter = 0
    $ can_click = False
    
    scene black # background
    
    show screen boat_scr
    show screen fox_scr
    show screen goose_scr
    show screen beans_scr
    
    
    label fgb_loop:
        $ can_click = True
        $ res = ui.interact()
        $ can_click = False
        $ counter += 1
        $ renpy.pause(2.0, hard=True)
        if fox == goose and fox != boat:
            hide screen goose_scr
            with dissolve
            "Fox ate goose..."
            jump fgb_loose
        elif goose == beans and goose != boat:
            hide screen beans_scr
            with dissolve
            "Goose ate beans..."
            jump fgb_loose
        elif fox == target_side and goose == target_side and beans == target_side:
            "Well done. (it takes [counter] moves)"
            return
        else:
            jump fgb_loop
    
label fgb_loose:
    hide screen boat_scr
    hide screen fox_scr
    hide screen goose_scr
    hide screen beans_scr
    
    "Try again"
    jump fgb_puzzle
    
    
    
    
# The game starts here.
label start:

    e "You've created a new Ren'Py game."
    call fgb_puzzle from fgb_1
    "and once again..."
    call fgb_puzzle from fgb_2
    e "Once you add a story, pictures, and music, you can release it to the world!"

    return
Ooh, this makes sense! Thank you ;v;

Post Reply

Who is online

Users browsing this forum: Google [Bot]