[SOLVED] Minigame Help - Screens, Inputs, Gameloops - tysm _ticlock_!

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.
Message
Author
thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

[SOLVED] Minigame Help - Screens, Inputs, Gameloops - tysm _ticlock_!

#1 Post by thexerox123 »

I'm trying my hand at making a Renpy minigame using creator-defined displayables for the first time, and I think I've reached a point where I could use a little guidance/advice on what I'm trying to do.

The gist is that you're an elf, wrapping gifts that are coming out on cranes. To wrap them, you have to input arrows matching those displayed on said cranes. I have a static background just using scene bg in Renpy.

For displayables, I want to have 3 on-screen touch buttons: left, up, and right. I'd like them to correspond to the keyboard arrow inputs to make either option available.

And then I have 4 different colors of cranes, and smaller versions of the left, up, and right arrows to be displayed on those cranes as prompts. There's space across the screen for up to 5 cranes at once.

I want the different colors of cranes to vary by how quickly they move and how long they stay on-screen. And I want there to be 4 difficulty levels. Easy would have, say, 20 easy cranes and 5 medium cranes. Normal would have 15 easy cranes, 10 medium cranes, and 5 hard cranes. Something along those lines.

So for the logic, I'm thinking that I'd have it set up to continue the loop until the pool of cranes appropriate to the difficulty level is expended. Something like:

Code: Select all

            if self.has_started:
                if Total_Cranes() == 0:
                    self.has_ended = True
                    renpy.timeout(0) # raise an event
                    return render
                    
And then I'd need it to check how many columns already have cranes in them, and if it's lower than 4, it can produce a new crane from the pool of available cranes, and assign it a new random 3-arrow prompt that can be input to successfully wrap its gift.

I have a lot of little bits of code that I've cobbled together that I think are mostly good starts, like the bit above, but it's really like a scratchpad that I made from using a rhythm game minigame displayable as a base and deleting most of it as I figured out what I did and didn't need... so it's useful for me, but it's, uh, pardon my french, a grow-er, not a show-er.

For instance, I think this would be how I'd want to group the classes in this displayable?

Code: Select all

init python:

    import os
    import pygame
    
    class CraneGameDisplayable(renpy.Displayable):

        def __init__(self, crane_group, control_arrows):
            super(CraneGameDisplayable, self).__init__()
            
But I guess my main question/stumbling block that has brought me here is how to implement the crane part of it. I'm guessing I'll have to use blit to pair the randomized arrow prompts onto the crane? And then have that base displayable move into its place in one of the 5 columns? And I'm assuming that I should have that laid out as a variable list?

Code: Select all

    class crane_group:
        def __init__(self, image):
            self.bluecrane = 'bluecrane.png'

        def __init__(self, image):
            self.redcrane = "redcrane.png"

        def __init__(self, image):
            self.greencrane = "greencrane.png"

        def __init__(self, image):
            self.goldcrane = "goldcrane.png"

        def R():
            return random.randint(1, 3) 

        def crane_symbols():        
            C1 = [R, R, R]
            C2 = [R, R, R]
            C3 = [R, R, R]
            C4 = [R, R, R]
            C5 = [R, R, R]
            
And then have R assign a blit for arrows assigned to 1-3 in a pos on the crane, so that they'd all move together? (And I'm not sure how to dictate the movement of displayables... is it the same way I'd deal with character sprites in Renpy proper?)


Am I at least somewhat on the right track? I feel like I have most of the elements I need, I just am not familiar enough with the syntax yet to put it all together.


So any advice at all would be most welcome! Thanks in advance to anyone willing to give some feedback! :)


(Also, random question, I saw that the rhythm game displayable I'm working from imports pygame but doesn't initialize it... what would be the purpose of that? Does it import the syntax or something?)
Last edited by thexerox123 on Thu Feb 09, 2023 4:33 pm, edited 2 times in total.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Minigame Help - Creator-Defined Displayables

#2 Post by _ticlock_ »

thexerox123 wrote: Fri Jan 20, 2023 3:32 pm
Side note: You can do this minigame using screen language. Actually, it could be easier using screen language than Creator-Defined Displayables.

Concerning CDD:
It could be done in various ways. Which one is better, depends on many factors. If you would like to create minigames using CDD It is generally better to create classes that are not specific to the current minigame, but that could be useful for other games.

Some logic you described can work, but class crane_group does not make any sense to me. What you want is probably something like this:

Code: Select all

class Crane(...):
    def __init__(self, color, speed, pos ...):
        self.child = renpy.displayable(color + "crane.png")
        self.speed = speed
        self.pos = pos
It also make sense to create some QuickTimeEvent class that implements basic functionality for your buttons and timing.

In your CraneGameDisplayable you can generate your cranes, which possibly could inherit from QuickTimeEvent. There is also a question of how you treat your buttons when you have several of them from different cranes. You can process in in your CraneGameDisplayable event and send the event to the appropriate crane event or to all of them.

I also recommend writing your code using simple steps, maybe start with quicktime displayable, then try one crane and so on.

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - Creator-Defined Displayables

#3 Post by thexerox123 »

Thank you so much for your response! :)

I hadn't thought of doing it in screen language -- I guess I could have separate crane and arrow screens and see if I can somehow summon both in sync?

A bit of context for why I'm going about it this way: I'm very new to Renpy, made 1 little proof-of-concept game in 3 days to teach myself Renpy and Python, and managed to integrate and adapt a rhythm game available in the big minigames thread here... so when going to try to make my own minigame, I took that .rpy file and deleted and adapted things to try to learn about it and suit my needs. So that grouping was modeled after the rhythm game displayable which brought up an overlay of the track lines and the arrow displayables. That class structure that you've posted makes a lot of sense too, though, I appreciate the suggestion!


I have thought about how to treat the buttons with several cranes, using the list to generate the arrows:

Code: Select all

        def crane_symbols():        
            C1 = [R, R, R]
            C2 = [R, R, R]
            C3 = [R, R, R]
            C4 = [R, R, R]
            C5 = [R, R, R]
For any cranes that are displayed on-screen, on one of the input presses, I'd have it check the first variable, and light up any that match. Then with the next button press, it would be checking applicable second columns only; light up those that match, and de-light the first column for ones that don't match. So theoretically, if it randomizes two cranes with the same three arrow inputs, you could clear them both at once. But otherwise, I think I can make that logic and variable referencing work.


I'll look into the QuickTimeEvent! I'd come across that class in my search for how to go about this, but ultimately got so mixed up in screen language vs creator-defined displayables and pygame and such, it all got a bit muddled. Thanks again! :)

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Minigame Help - Creator-Defined Displayables

#4 Post by _ticlock_ »

thexerox123 wrote: Mon Jan 23, 2023 1:44 pm but ultimately got so mixed up in screen language vs creator-defined displayables and pygame and such, it all got a bit muddled.
I'd compare Screen Language to LEGO, where you built something using existing blocks. It is quite fast, and suitable for lots of purposes, but has some limitations.

Creator-Defined Displayable is like 3D printing. You can build blocks that you can use in Screen Language, or build the whole thing. It is much more powerful, requires better knowledge of Python, and might take a lot of time to make the job done.

I think it is a good idea to learn using examples. I'd recommend studying from simple examples to more advanced ones. Also, check the documentation to figure out why something is done in a particular way.

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - Creator-Defined Displayables

#5 Post by thexerox123 »

Okay, I've given it another shot using screens, and I feel like I'm getting closer, but not sure yet... I probably need to get the input loop working before it's not just an infinite loop crash?

In my script, I declare:

Code: Select all

default crane_difficulty = "Easy"
default C1_1 = 0
default C1_2 = 0
default C1_3 = 0
default C2_1 = 0
default C2_2 = 0
default C2_3 = 0
default C3_1 = 0
default C3_2 = 0
default C3_3 = 0
default C4_1 = 0
default C4_2 = 0
default C4_3 = 0
default C5_1 = 0
default C5_2 = 0
default C5_3 = 0
And define the following images:

Code: Select all

    image Blue Crane = Image("BlueCrane.png")
    image Red Crane = Image("RedCrane.png")
    image Green Crane = Image("GreenCrane.png")
    image Gold Crane = Image("GoldCrane.png")
    image LeftSm = Image("LeftSm.png")
    image UpSm = Image("UpSm.png")
    image RightSm = Image("RightSm.png")
I have a difficulty selection label that I'm currently skipping past and keeping the difficulty at "Easy" for testing.

Code: Select all

label difficulty_select:
    menu:
        "Easy":
            $ crane_difficulty = "Easy"
            jump giftwrap
        "Medium":
            $ crane_difficulty = "Medium"
            jump giftwrap
        "Hard":
            $ crane_difficulty = "Hard"
            jump giftwrap
        "Ultra Hard":
            $ crane_difficulty = "Ultra"
            jump giftwrap
Then I have a label that sets my initial conditions for the game.

Code: Select all

label giftwrap:
    scene bg cranedesk
    play music MountainKing

    if crane_difficulty == "Easy":
        $ blue_cranes = 30
        $ red_cranes = 15
        $ green_cranes = 0
        $ gold_cranes = 0

    elif crane_difficulty == "Medium":
        $ blue_cranes = 25
        $ red_cranes =  25
        $ green_cranes = 0
        $ gold_cranes = 0

    elif crane_difficulty == "Hard":
        $ blue_cranes = 20
        $ red_cranes =  25
        $ green_cranes = 14
        $ gold_cranes = 1

    elif crane_difficulty == "Ultra":
        $ blue_cranes = 20
        $ red_cranes =  20
        $ green_cranes = 20
        $ gold_cranes = 10

    show screen crane_controls
    jump gameloop    
In my crane_game_displayable.rpy doc, I have this screen defined:

Code: Select all

    screen crane_controls:
        vbox:
            add "images/bg/bg CraneDesk.png"
        vbox:
            imagebutton:
                idle "images/Left_Idle.png"
                hover "images/Left_Hover.png"
                xpos 400 ypos 700
                at zoomless
        vbox:
            imagebutton:
                idle "images/Right_Idle.png"
                hover "images/Right_Hover.png"
                xpos 1000 ypos 700
                at zoomless
        vbox:
            imagebutton:
                idle "images/Up_Idle.png"
                hover "images/Up_Hover.png"
                xpos 700 ypos 600
                at zoomless
(I still don't have the inputs done, going to try to figure that out today.)
And I have these definitions in the init section of crane_game_displayable:

Code: Select all

    transform column1:
        xalign -0.1 yalign 0.1
        linear 2.0 xalign 0.1
    transform column2:
        xalign -0.1 yalign 0.1
        linear 2.0 xalign 0.3
    transform column3:
        xalign -0.1 yalign 0.1
        linear 2.0 xalign 0.5
    transform column4:
        xalign -0.1 yalign 0.1
        linear 2.0 xalign 0.7
    transform column5:
        xalign -0.1 yalign 0.1
        linear 2.0 xalign 0.9

    $ blue_cranes = 0
    $ red_cranes = 0
    $ green_cranes = 0
    $ gold_cranes = 0
    $ has_started = True
    $ has_ended = False
    $ Columns = ["C1", "C2", "C3", "C4", "C5"]
    $ ColumnNo = len(Columns)
    $ Col_1 = False
    $ Col_2 = False
    $ Col_3 = False
    $ Col_4 = False
    $ Col_5 = False
    $ P1 = False
    $ P2 = False
    $ P3 = False
    
And, back in script.rpy, here's my attempt at my gameloop so far:

Code: Select all

label gameloop:
    $ TotalNo = blue_cranes + red_cranes + green_cranes + gold_cranes
    if TotalNo == 0:
        $ has_started = False
        $ has_ended = True 
        jump gameend

        elif TotalNo >= 1:
        $ cranechoose = renpy.random.choice(["blue", "red", "green", "gold"])
        if cranechoose == "blue":
            if blue_cranes == 0:
                jump gameloop
            else:
                $ columnchoose = renpy.random.randint(1, 5)
                if columnchoose == 1:
                    if Col_1 == True:
                        jump gameloop
                    else:
                        show Blue Crane at column1
                        $ Col_1 = True
                        $ C1_1 = renpy.random.randint(1, 3)
                        if C1_1 == 1:
                          show LeftSm at column1
                        if C1_1 == 2:
                            show UpSm at column1
                        if C1_1 == 3:
                            show RightSm at column1
                        $ C1_2 = renpy.random.randint(1, 3)
                        if C1_2 == 1:
                            show LeftSm at column1
                        if C1_2 == 2:
                            show UpSm at column1
                        if C1_2 == 3:
                            show RightSm at column1                                
                        $ C1_3 = renpy.random.randint(1, 3)
                        if C1_3 == 1:
                            show LeftSm at column1
                        if C1_3 == 2:
                            show UpSm at column1
                        if C1_3 == 3:
                            show RightSm at column1

                
                if columnchoose == 2:
                    if Col_2 == True:
                        jump gameloop
                    else:
                        show Blue Crane at column2
                        $ Col_2 = True
                        $ C2_1 = renpy.random.randint(1, 3)
                        if C2_1 == 1:
                          show LeftSm at column2
                        if C2_1 == 2:
                            show UpSm at column2
                        if C2_1 == 3:
                            show RightSm at column2
                        $ C2_2 = renpy.random.randint(1, 3)
                        if C2_2 == 1:
                            show LeftSm at column2
                        if C2_2 == 2:
                            show UpSm at column2
                        if C2_2 == 3:
                            show RightSm at column2                                
                        $ C2_3 = renpy.random.randint(1, 3)
                        if C2_3 == 1:
                            show LeftSm at column2
                        if C2_3 == 2:
                            show UpSm at column2
                        if C2_3 == 3:
                            show RightSm at column2

                if columnchoose == 3:
                    if Col_3 == True:
                        jump gameloop
                    else:
                        show Blue Crane at column3
                        $ Col_3 = True
                        $ C3_1 = renpy.random.randint(1, 3)
                        if C3_1 == 1:
                          show LeftSm at column1
                        if C3_1 == 2:
                            show UpSm at column1
                        if C3_1 == 3:
                            show RightSm at column1
                        $ C3_2 = renpy.random.randint(1, 3)
                        if C3_2 == 1:
                            show LeftSm at column1
                        if C3_2 == 2:
                            show UpSm at column1
                        if C3_2 == 3:
                            show RightSm at column1                                
                        $ C3_3 = renpy.random.randint(1, 3)
                        if C3_3 == 1:
                            show LeftSm at column1
                        if C3_3 == 2:
                            show UpSm at column1
                        if C3_3 == 3:
                            show RightSm at column1
                if columnchoose == 4:
                    if Col_4 == True:
                        jump gameloop
                    else:
                        show Blue Crane at column4
                        $ Col_4 = True
                        $ C4_1 = renpy.random.randint(1, 3)
                        if C4_1 == 1:
                          show LeftSm at column1
                        if C4_1 == 2:
                            show UpSm at column1
                        if C4_1 == 3:
                            show RightSm at column1
                        $ C4_2 = renpy.random.randint(1, 3)
                        if C4_2 == 1:
                            show LeftSm at column1
                        if C4_2 == 2:
                            show UpSm at column1
                        if C4_2 == 3:
                            show RightSm at column1                                
                        $ C4_3 = renpy.random.randint(1, 3)
                        if C4_3 == 1:
                            show LeftSm at column1
                        if C4_3 == 2:
                            show UpSm at column1
                        if C4_3 == 3:
                            show RightSm at column1
                if columnchoose == 5:
                    if Col_5 == True:                        
                        jump gameloop
                    else:
                        show Blue Crane at column5
                        $ Col_5 = True
                        $ C5_1 = renpy.random.randint(1, 3)
                        if C5_1 == 1:
                          show LeftSm at column1
                        if C5_1 == 2:
                            show UpSm at column1
                        if C5_1 == 3:
                            show RightSm at column1
                        $ C5_2 = renpy.random.randint(1, 3)
                        if C5_2 == 1:
                            show LeftSm at column1
                        if C5_2 == 2:
                            show UpSm at column1
                        if C5_2 == 3:
                            show RightSm at column1                                
                        $ C5_3 = renpy.random.randint(1, 3)
                        if C5_3 == 1:
                            show LeftSm at column1
                        if C5_3 == 2:
                            show UpSm at column1
                        if C5_3 == 3:
                            show RightSm at column1


        if cranechoose == "red":
            if red_cranes == 0:
                jump gameloop
            else:
                $ columnchoose = renpy.random.randint(1, 5)
                if columnchoose == 1:
                    if Col_1 == True:
                        jump gameloop
                    else:
                        show Red Crane at column1
                        $ Col_1 = True
                        $ C1_1 = renpy.random.randint(1, 3)
                        if C1_1 == 1:
                          show LeftSm at column1
                        if C1_1 == 2:
                            show UpSm at column1
                        if C1_1 == 3:
                            show RightSm at column1
                        $ C1_2 = renpy.random.randint(1, 3)
                        if C1_2 == 1:
                            show LeftSm at column1
                        if C1_2 == 2:
                            show UpSm at column1
                        if C1_2 == 3:
                            show RightSm at column1                                
                        $ C1_3 = renpy.random.randint(1, 3)
                        if C1_3 == 1:
                            show LeftSm at column1
                        if C1_3 == 2:
                            show UpSm at column1
                        if C1_3 == 3:
                            show RightSm at column1

                if columnchoose == 2:
                    if Col_2 == True:
                        jump gameloop
                    else:
                        show Red Crane at column2
                        $ Col_2 = True
                        $ C2_1 = renpy.random.randint(1, 3)
                        if C2_1 == 1:
                          show LeftSm at column2
                        if C2_1 == 2:
                            show UpSm at column2
                        if C2_1 == 3:
                            show RightSm at column2
                        $ C2_2 = renpy.random.randint(1, 3)
                        if C2_2 == 1:
                            show LeftSm at column2
                        if C2_2 == 2:
                            show UpSm at column2
                        if C2_2 == 3:
                            show RightSm at column2                                
                        $ C2_3 = renpy.random.randint(1, 3)
                        if C2_3 == 1:
                            show LeftSm at column2
                        if C2_3 == 2:
                            show UpSm at column2
                        if C2_3 == 3:
                            show RightSm at column2

                if columnchoose == 3:
                    if Col_3 == True:
                        jump gameloop
                    else:
                        show Red Crane at column3
                        $ Col_3 = True
                        $ C3_1 = renpy.random.randint(1, 3)
                        if C3_1 == 1:
                          show LeftSm at column1
                        if C3_1 == 2:
                            show UpSm at column1
                        if C3_1 == 3:
                            show RightSm at column1
                        $ C3_2 = renpy.random.randint(1, 3)
                        if C3_2 == 1:
                            show LeftSm at column1
                        if C3_2 == 2:
                            show UpSm at column1
                        if C3_2 == 3:
                            show RightSm at column1                                
                        $ C3_3 = renpy.random.randint(1, 3)
                        if C3_3 == 1:
                            show LeftSm at column1
                        if C3_3 == 2:
                            show UpSm at column1
                        if C3_3 == 3:
                            show RightSm at column1

                if columnchoose == 4:
                    if Col_4 == True:
                        jump gameloop
                    else:
                        show Red Crane at column4
                        $ Col_4 = True
                        $ C4_1 = renpy.random.randint(1, 3)
                        if C4_1 == 1:
                          show LeftSm at column1
                        if C4_1 == 2:
                            show UpSm at column1
                        if C4_1 == 3:
                            show RightSm at column1
                        $ C4_2 = renpy.random.randint(1, 3)
                        if C4_2 == 1:
                            show LeftSm at column1
                        if C4_2 == 2:
                            show UpSm at column1
                        if C4_2 == 3:
                            show RightSm at column1                                
                        $ C4_3 = renpy.random.randint(1, 3)
                        if C4_3 == 1:
                            show LeftSm at column1
                        if C4_3 == 2:
                            show UpSm at column1
                        if C4_3 == 3:
                            show RightSm at column1

                if columnchoose == 5:
                    if Col_5 == True:
                        jump gameloop
                    else:
                        show Red Crane at column5
                        $ Col_5 = True
                        $ C5_1 = renpy.random.randint(1, 3)
                        if C5_1 == 1:
                          show LeftSm at column1
                        if C5_1 == 2:
                            show UpSm at column1
                        if C5_1 == 3:
                            show RightSm at column1
                        $ C5_2 = renpy.random.randint(1, 3)
                        if C5_2 == 1:
                            show LeftSm at column1
                        if C5_2 == 2:
                            show UpSm at column1
                        if C5_2 == 3:
                            show RightSm at column1                                
                        $ C5_3 = renpy.random.randint(1, 3)
                        if C5_3 == 1:
                            show LeftSm at column1
                        if C5_3 == 2:
                            show UpSm at column1
                        if C5_3 == 3:
                            show RightSm at column1

        if cranechoose == "green":
            if green_cranes == 0:
                jump gameloop
            else:
                $ columnchoose = renpy.random.randint(1, 5)
                if columnchoose == 1:
                    if Col_1 == True:
                        jump gameloop
                    else:
                        show Green Crane at column1
                        $ Col_1 = True
                        $ C1_1 = renpy.random.randint(1, 3)
                        if C1_1 == 1:
                          show LeftSm at column1
                        if C1_1 == 2:
                            show UpSm at column1
                        if C1_1 == 3:
                            show RightSm at column1
                        $ C1_2 = renpy.random.randint(1, 3)
                        if C1_2 == 1:
                            show LeftSm at column1
                        if C1_2 == 2:
                            show UpSm at column1
                        if C1_2 == 3:
                            show RightSm at column1                                
                        $ C1_3 = renpy.random.randint(1, 3)
                        if C1_3 == 1:
                            show LeftSm at column1
                        if C1_3 == 2:
                            show UpSm at column1
                        if C1_3 == 3:
                            show RightSm at column1

                if columnchoose == 2:
                    if Col_2 == True:
                        jump gameloop
                    else:
                        show Green Crane at column2
                        $ Col_2 = True
                        $ C2_1 = renpy.random.randint(1, 3)
                        if C2_1 == 1:
                          show LeftSm at column2
                        if C2_1 == 2:
                            show UpSm at column2
                        if C2_1 == 3:
                            show RightSm at column2
                        $ C2_2 = renpy.random.randint(1, 3)
                        if C2_2 == 1:
                            show LeftSm at column2
                        if C2_2 == 2:
                            show UpSm at column2
                        if C2_2 == 3:
                            show RightSm at column2                                
                        $ C2_3 = renpy.random.randint(1, 3)
                        if C2_3 == 1:
                            show LeftSm at column2
                        if C2_3 == 2:
                            show UpSm at column2
                        if C2_3 == 3:
                            show RightSm at column2

                if columnchoose == 3:
                    if Col_3 == True:
                        jump gameloop
                    else:
                        show Green Crane at column3
                        $ Col_3 = True
                        $ C3_1 = renpy.random.randint(1, 3)
                        if C3_1 == 1:
                          show LeftSm at column1
                        if C3_1 == 2:
                            show UpSm at column1
                        if C3_1 == 3:
                            show RightSm at column1
                        $ C3_2 = renpy.random.randint(1, 3)
                        if C3_2 == 1:
                            show LeftSm at column1
                        if C3_2 == 2:
                            show UpSm at column1
                        if C3_2 == 3:
                            show RightSm at column1                                
                        $ C3_3 = renpy.random.randint(1, 3)
                        if C3_3 == 1:
                            show LeftSm at column1
                        if C3_3 == 2:
                            show UpSm at column1
                        if C3_3 == 3:
                            show RightSm at column1

                if columnchoose == 4:
                    if Col_4 == True:
                        jump gameloop
                    else:
                        show Green Crane at column4
                        $ Col_4 = True
                        $ C4_1 = renpy.random.randint(1, 3)
                        if C4_1 == 1:
                          show LeftSm at column1
                        if C4_1 == 2:
                            show UpSm at column1
                        if C4_1 == 3:
                            show RightSm at column1
                        $ C4_2 = renpy.random.randint(1, 3)
                        if C4_2 == 1:
                            show LeftSm at column1
                        if C4_2 == 2:
                            show UpSm at column1
                        if C4_2 == 3:
                            show RightSm at column1                                
                        $ C4_3 = renpy.random.randint(1, 3)
                        if C4_3 == 1:
                            show LeftSm at column1
                        if C4_3 == 2:
                            show UpSm at column1
                        if C4_3 == 3:
                            show RightSm at column1

                if columnchoose == 5:
                    if Col_5 == True:
                        jump gameloop
                    else:
                        show Green Crane at column5
                        $ Col_5 = True
                        $ C5_1 = renpy.random.randint(1, 3)
                        if C5_1 == 1:
                          show LeftSm at column1
                        if C5_1 == 2:
                            show UpSm at column1
                        if C5_1 == 3:
                            show RightSm at column1
                        $ C5_2 = renpy.random.randint(1, 3)
                        if C5_2 == 1:
                            show LeftSm at column1
                        if C5_2 == 2:
                            show UpSm at column1
                        if C5_2 == 3:
                            show RightSm at column1                                
                        $ C5_3 = renpy.random.randint(1, 3)
                        if C5_3 == 1:
                            show LeftSm at column1
                        if C5_3 == 2:
                            show UpSm at column1
                        if C5_3 == 3:
                            show RightSm at column1

        if cranechoose == "gold":
            if gold_cranes == 0:
                jump gameloop
            else:
                $ columnchoose = renpy.random.randint(1, 5)
                if columnchoose == 1:
                    if Col_1 == True:
                        jump gameloop
                    else:
                        show Gold Crane at column1
                        $ Col_1 = True
                        $ C1_1 = renpy.random.randint(1, 3)
                        if C1_1 == 1:
                          show LeftSm at column1
                        if C1_1 == 2:
                            show UpSm at column1
                        if C1_1 == 3:
                            show RightSm at column1
                        $ C1_2 = renpy.random.randint(1, 3)
                        if C1_2 == 1:
                            show LeftSm at column1
                        if C1_2 == 2:
                            show UpSm at column1
                        if C1_2 == 3:
                            show RightSm at column1                                
                        $ C1_3 = renpy.random.randint(1, 3)
                        if C1_3 == 1:
                            show LeftSm at column1
                        if C1_3 == 2:
                            show UpSm at column1
                        if C1_3 == 3:
                            show RightSm at column1

                if columnchoose == 2:
                    if Col_2 == True:
                        jump gameloop
                    else:
                        show Gold Crane at column2
                        $ Col_2 = True
                        $ C2_1 = renpy.random.randint(1, 3)
                        if C2_1 == 1:
                          show LeftSm at column2
                        if C2_1 == 2:
                            show UpSm at column2
                        if C2_1 == 3:
                            show RightSm at column2
                        $ C2_2 = renpy.random.randint(1, 3)
                        if C2_2 == 1:
                            show LeftSm at column2
                        if C2_2 == 2:
                            show UpSm at column2
                        if C2_2 == 3:
                            show RightSm at column2                                
                        $ C2_3 = renpy.random.randint(1, 3)
                        if C2_3 == 1:
                            show LeftSm at column2
                        if C2_3 == 2:
                            show UpSm at column2
                        if C2_3 == 3:
                            show RightSm at column2

                if columnchoose == 3:
                    if Col_3 == True:
                        jump gameloop
                    else:
                        show Gold Crane at column3
                        $ Col_3 = True
                        $ C3_1 = renpy.random.randint(1, 3)
                        if C3_1 == 1:
                          show LeftSm at column1
                        if C3_1 == 2:
                            show UpSm at column1
                        if C3_1 == 3:
                            show RightSm at column1
                        $ C3_2 = renpy.random.randint(1, 3)
                        if C3_2 == 1:
                            show LeftSm at column1
                        if C3_2 == 2:
                            show UpSm at column1
                        if C3_2 == 3:
                            show RightSm at column1                                
                        $ C3_3 = renpy.random.randint(1, 3)
                        if C3_3 == 1:
                            show LeftSm at column1
                        if C3_3 == 2:
                            show UpSm at column1
                        if C3_3 == 3:
                            show RightSm at column1

                if columnchoose == 4:
                    if Col_4 == True:
                        jump gameloop
                    else:
                        show Gold Crane at column4
                        $ Col_4 = True
                        $ C4_1 = renpy.random.randint(1, 3)
                        if C4_1 == 1:
                          show LeftSm at column1
                        if C4_1 == 2:
                            show UpSm at column1
                        if C4_1 == 3:
                            show RightSm at column1
                        $ C4_2 = renpy.random.randint(1, 3)
                        if C4_2 == 1:
                            show LeftSm at column1
                        if C4_2 == 2:
                            show UpSm at column1
                        if C4_2 == 3:
                            show RightSm at column1                                
                        $ C4_3 = renpy.random.randint(1, 3)
                        if C4_3 == 1:
                            show LeftSm at column1
                        if C4_3 == 2:
                            show UpSm at column1
                        if C4_3 == 3:
                            show RightSm at column1

                if columnchoose == 5:
                    if Col_5 == True:
                        jump gameloop
                    else:
                        show Gold Crane at column5
                        $ Col_5 = True
                        $ C5_1 = renpy.random.randint(1, 3)
                        if C5_1 == 1:
                          show LeftSm at column1
                        if C5_1 == 2:
                            show UpSm at column1
                        if C5_1 == 3:
                            show RightSm at column1
                        $ C5_2 = renpy.random.randint(1, 3)
                        if C5_2 == 1:
                            show LeftSm at column1
                        if C5_2 == 2:
                            show UpSm at column1
                        if C5_2 == 3:
                            show RightSm at column1                                
                        $ C5_3 = renpy.random.randint(1, 3)
                        if C5_3 == 1:
                            show LeftSm at column1
                        if C5_3 == 2:
                            show UpSm at column1
                        if C5_3 == 3:
                            show RightSm at column1
                            
        $ renpy.pause(2.0, hard=True)
        jump gameloop
(I'll need to make new transforms for the arrows... but surely there's an easier way than what I've done here? lol)

And right now the gameend label is just a return.

I've gotten infinite loop errors a few times, which I assume, without input options so far, is actually what I am going for? It's better than syntax errors, at least... I wouldn't be surprised if there are easier ways to go about what I'm doing, but I've been having a hell of a time interpolating integers from strings when going between python and renpy. (I had been using more custom python functions at first, but transitioned a lot of those to logic using renpy syntax in script.rpy instead.)

Once again, I'd more than welcome any feedback on the best way to go about this, and how I might want to go about getting the actual gameplay loop and input checks working?

Edit: Here's what I have so far in trying to implement screens to call with the left, right, and up buttons and keys, and then to do a check against the variables for the prompts. Need to code it still to change the prompt appearance to have it light up, and then clear out when they're no longer relevant or clear and check a crane when it's done correctly. Phew! ...I hope I'm doing... any of this right. Haha.

Code: Select all

  

    screen leftbutt:
        if P1 == False:
            if C1_1 == 1:
                $ P1 = True
            if C2_1 == 1:
                $ P1 = True
            if C3_1 == 1:
                $ P1 = True
            if C4_1 == 1:
                $ P1 = True
            if C5_1 == 1:
                $ P1 = True
        elif P2 == False:
            if C1_2 == 1:
                $ P2 = True
            if C2_2 == 1:
                $ P2 = True
            if C3_2 == 1:
                $ P2 = True
            if C4_2 == 1:
                $ P2 = True
            if C5_2 == 1:
                $ P2 = True
        elif P3 == False:
            if C1_3 == 1:
                $ P3 = True
            if C2_3 == 1:
                $ P3 = True 
            if C3_3 == 1:
                $ P3 = True
            if C4_3 == 1:
                $ P3 = True
            if C5_3 == 1:
                $ P3 = True


    screen upbutt:
        if P1 == False:
            if C1_1 == 2:
                $ P1 = True
            if C2_1 == 2:
                $ P1 = True
            if C3_1 == 2:
                $ P1 = True
            if C4_1 == 2:
                $ P1 = True
            if C5_1 == 2:
                $ P1 = True
        elif P2 == False:
            if C1_2 == 2:
                $ P2 = True
            if C2_2 == 2:
                $ P2 = True
            if C3_2 == 2:
                $ P2 = True
            if C4_2 == 2:
                $ P2 = True
            if C5_2 == 2:
                $ P2 = True
        elif P3 == False:
            if C1_3 == 2:
                $ P3 = True
            if C2_3 == 2:
                $ P3 = True 
            if C3_3 == 2:
                $ P3 = True
            if C4_3 == 2:
                $ P3 = True
            if C5_3 == 2:
                $ P3 = True



    screen rightbutt:
        if P1 == False:
            if C1_1 == 3:
                $ P1 = True
            if C2_1 == 3:
                $ P1 = True
            if C3_1 == 3:
                $ P1 = True
            if C4_1 == 3:
                $ P1 = True
            if C5_1 == 3:
                $ P1 = True
        elif P2 == False:
            if C1_2 == 3:
                $ P2 = True
            if C2_2 == 3:
                $ P2 = True
            if C3_2 == 3:
                $ P2 = True
            if C4_2 == 3:
                $ P2 = True
            if C5_2 == 3:
                $ P2 = True
        elif P3 == False:
            if C1_3 == 3:
                $ P3 = True
            if C2_3 == 3:
                $ P3 = True 
            if C3_3 == 3:
                $ P3 = True
            if C4_3 == 3:
                $ P3 = True
            if C5_3 == 3:
                $ P3 = True

And I need to figure out the syntax for making the crane_controls imagebuttons do what I need them to... if I make the imagebutton represent K_LEFT, K_UP, K_DOWN, would the keyboard still also work for those inputs?

Edit: I guess now is the time that I need to figure out how to make a Quick Time Event class, as has been suggested!

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#6 Post by thexerox123 »

Ooh! I removed the redundant

Code: Select all

        vbox:
            add "images/bg/bg CraneDesk.png"
from my crane_controls screen, and the cranes actually started showing up! Still an utter mess that led to an infinite loop, but... one step closer!

Oh... realized that with only one variable for each colour of crane, I'm only allowing one crane of each colour at a time. :\ Can I append the variable based on which column it's in?

I guess the way I have it set up, I can just make Blue_Crane1 - BlueCrane5, etc, and match those to the logic that calls a crane image for a column. But I certainly know that this isn't an elegant way to code all of this, lol. Edit: Hm, that doesn't solve it. Do I need to make separate png files for each?

Edit: Hmm. Even duplicating and renaming the crane files, it seems to be unable to have more than one of each colour at a time. Whyyyy

Edit: Derp, my issue was that by naming it Blue Crane1, it was considering it an image named Blue with the attribute Crane1.
Last edited by thexerox123 on Sat Feb 04, 2023 11:31 am, edited 1 time in total.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#7 Post by _ticlock_ »

thexerox123 wrote: Fri Feb 03, 2023 1:05 pm Once again, I'd more than welcome any feedback
1) Personally, I'd use a screen for displaying cranes rather than `show` statements inside labels. I think. it is easier to write this type of logic using screen language. For this type of game, I would consider using this approach:

Code: Select all

label gameloop:
    # Possibly prepare some arguments for the screen, or do some python block to set up parameters, or even better call some function that would do that
    # Possibly show some additional screens here if necessary
    call screen mini_game(...)
    # Process the user input. Again you can do it in python, in a function.
    if <still_in_game>:
        jump gameloop
    #Game results
In screen, you can use add statements to place a displayable. You can place as many duplicates of cranes as necessary.
thexerox123 wrote: Fri Feb 03, 2023 1:05 pm Oh... realized that with only one variable for each colour of crane, I'm only allowing one crane of each colour at a time.
If you want to stick to `show` statements, you need to use as property:

Code: Select all

    show Blue Crane at column1 as crane_column_1
2) It is not recommended to build up indentations. Try to avoid it if possible. For example:

Code: Select all

    if TotalNo == 0:
        jump gameend
     
    #You don't need `else` Just continue with the same indentation.
    ...
3) You should try to avoid repetitive lines of code. Generally, you should try to use function with arguments, In case of RenPy, it could be a `screen` with arguments of a `label` with arguments. (For example, you can try to place repetitive lines for each crane and columns inside a label or in a function)

4)
thexerox123 wrote: Fri Feb 03, 2023 1:05 pm if I make the imagebutton represent K_LEFT, K_UP, K_DOWN, would the keyboard still also work for those inputs?
You need to use key. It could be separate from imagebuttons but also part of a button. For example check the save button code from screens.rpy:

Code: Select all

                   button:
        
                        action FileAction(slot)

                        has vbox

                        add FileScreenshot(slot) xalign 0.5

                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
                            style "slot_time_text"

                        text FileSaveName(slot):
                            style "slot_name_text"

                        key "save_delete" action FileDelete(slot)
5)
thexerox123 wrote: Thu Feb 02, 2023 2:21 pm (I still don't have the inputs done, going to try to figure that out today.)
thexerox123 wrote: Fri Feb 03, 2023 1:05 pm Edit: I guess now is the time that I need to figure out how to make a Quick Time Event class, as has been suggested!
Basically, it is a good idea to have a class for your game, that would do the logic, and process input.
In a screen you can use `button` and `key` actions to get user input and timer to process time events.
Also, Function action can be useful.

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#8 Post by thexerox123 »

_ticlock_ wrote: Fri Feb 03, 2023 4:40 pm 1) Personally, I'd use a screen for displaying cranes rather than `show` statements inside labels. I think. it is easier to write this type of logic using screen language. For this type of game, I would consider using this approach:

Code: Select all

label gameloop:
    # Possibly prepare some arguments for the screen, or do some python block to set up parameters, or even better call some function that would do that
    # Possibly show some additional screens here if necessary
    call screen mini_game(...)
    # Process the user input. Again you can do it in python, in a function.
    if <still_in_game>:
        jump gameloop
    #Game results
In screen, you can use add statements to place a displayable. You can place as many duplicates of cranes as necessary.

3) You should try to avoid repetitive lines of code. Generally, you should try to use function with arguments, In case of RenPy, it could be a `screen` with arguments of a `label` with arguments. (For example, you can try to place repetitive lines for each crane and columns inside a label or in a function)

Basically, it is a good idea to have a class for your game, that would do the logic, and process input.
In a screen you can use `button` and `key` actions to get user input and timer to process time events.
Also, Function action can be useful.
Thank you again for your responses... I'm trying to switch it all over to functions and screens as you suggest, but I remember why I ended up getting frustrated with that originally and swapped stuff over to script.rpy... I can't even get the display part working, let alone any inputs. I am having a nightmare trying to get functions to interpolate into variables between python and renpy screen language... how on earth do I get these functioning? I either get nameerrors or typeerrors, and I cannot figure out how to actually access the return of a random.choice function as anything that I can use.

Here's what I have at the moment...

Crane_Game_Displayable.rpy

Code: Select all

init:

    transform column1:
        xalign -0.1 yalign 0.1
        linear 0.3 xalign 0.1
    transform column2:
        xalign -0.1 yalign 0.1
        linear 0.5 xalign 0.3
    transform column3:
        xalign -0.1 yalign 0.1
        linear 0.7 xalign 0.5
    transform column4:
        xalign -0.1 yalign 0.1
        linear 0.9 xalign 0.7
    transform column5:
        xalign -0.1 yalign 0.1
        linear 1.1 xalign 0.9

    $ blue_cranes = 0
    $ red_cranes = 0
    $ green_cranes = 0
    $ gold_cranes = 0
    $ has_started = True
    $ has_ended = False
    $ Columns = ["C1", "C2", "C3", "C4", "C5"]
    $ ColumnNo = len(Columns)
    $ CraneList = ["blue", "red", "green", "gold"]
    $ Col_1 = False
    $ Col_2 = False
    $ Col_3 = False
    $ Col_4 = False
    $ Col_5 = False
    $ P1 = False
    $ P2 = False
    $ P3 = False
    $ GL1 = False
    $ GL2 = False
    $ GL3 = False
    $ GL4 = False
    $ GL5 = False
    $ GL6 = False
    $ GL7 = False
    $ GL8 = False
    $ GL9 = False
    $ GL10 = False
    $ GL11 = False
    $ GL12 = False
    $ GL13 = False
    $ GL14 = False
    $ GL15 = False
    $ GU1 = False
    $ GU2 = False
    $ GU3 = False
    $ GU4 = False
    $ GU5 = False
    $ GU6 = False
    $ GU7 = False
    $ GU8 = False
    $ GU9 = False
    $ GU10 = False
    $ GU11 = False
    $ GU12 = False
    $ GU13 = False
    $ GU14 = False
    $ GU15 = False



    init python:

  
        class crane_buttons():

            def cranechoose():
                renpy.random.choice("CraneList") 
            def columnchoose():
                renpy.random.randint(1, 5)
            def wait1():
                renpy.pause(0.3)
            def wait2():
                renpy.pause(0.5)
            def wait3():
                renpy.pause(0.7)
            def wait4():
                renpy.pause(0.9)
            def wait5():
                renpy.pause(1.1)
            def C1_1():
                renpy.random.randint(1, 3)
            def C1_2():
                renpy.random.randint(1, 3)
            def C1_3():
                renpy.random.randint(1, 3)
            def C1_4():
                renpy.random.randint(1, 3)
            def C1_5():
                renpy.random.randint(1, 3)
            def C2_1():
                renpy.random.randint(1, 3)
            def C2_2():
                renpy.random.randint(1, 3)
            def C2_3():
                renpy.random.randint(1, 3)
            def C2_4():
                renpy.random.randint(1, 3)
            def C2_5():
                renpy.random.randint(1, 3)
            def C3_1():
                renpy.random.randint(1, 3)
            def C3_2():
                renpy.random.randint(1, 3)
            def C3_3():
                renpy.random.randint(1, 3)
            def C3_4():
                renpy.random.randint(1, 3)
            def C3_5():
                renpy.random.randint(1, 3)
            def C4_1():
                renpy.random.randint(1, 3)
            def C4_2():
                renpy.random.randint(1, 3)
            def C4_3():
                renpy.random.randint(1, 3)
            def C4_4():
                renpy.random.randint(1, 3)
            def C4_5():
                renpy.random.randint(1, 3)
            def C5_1():
                renpy.random.randint(1, 3)
            def C5_2():
                renpy.random.randint(1, 3)
            def C5_3():
                renpy.random.randint(1, 3)
            def C5_4():
                renpy.random.randint(1, 3)
            def C5_5():
                renpy.random.randint(1, 3)
            def loop():
                renpy.jump("gameloop")
            def column1log():
                C1_1()
                C1_2()                               
                C1_3()
            def column2log():
                C2_1()
                C2_2()                              
                C2_3()
            def column3log():
                C3_1()
                C3_2()                              
                C3_3()
            def column4log():
                C4_1()
                C4_2()                              
                C4_3()
            def column5log():
                C5_1()
                C5_2()                              
                C5_3()

    screen leftbutt():
        if P1 == False:
            if C1_1 == 1:
                $ GL1 = True
                $ P1 = True
            if C2_1 == 1:
                $ GL4 = True
                $ P1 = True
            if C3_1 == 1:
                $ GL7 = True
                $ P1 = True
            if C4_1 == 1:
                $ GL10 = True
                $ P1 = True
            if C5_1 == 1:
                $ GL13 = True
                $ P1 = True
        elif P2 == False:
            if C1_2 == 1:
                $ GL2 = True
                $ P2 = True
            if C2_2 == 1:
                $ GL5 = True
                $ P2 = True
            if C3_2 == 1:
                $ GL8 = True
                $ P2 = True
            if C4_2 == 1:
                $ GL11 = True
                $ P2 = True
            if C5_2 == 1:
                $ GL14 = True
                $ P2 = True
        elif P3 == False:
            if C1_3 == 1:
                $ GL3 = True
                $ P3 = True
            if C2_3 == 1:
                $ GL6 = True
                $ P3 = True 
            if C3_3 == 1:
                $ GL9 = True
                $ P3 = True
            if C4_3 == 1:
                $ GL12 = True
                $ P3 = True
            if C5_3 == 1:
                $ GL15 = True
                $ P3 = True


    screen upbutt():
        if P1 == False:
            if C1_1 == 2:
                $ P1 = True
            if C2_1 == 2:
                $ P1 = True
            if C3_1 == 2:
                $ P1 = True
            if C4_1 == 2:
                $ P1 = True
            if C5_1 == 2:
                $ P1 = True
        elif P2 == False:
            if C1_2 == 2:
                $ P2 = True
            if C2_2 == 2:
                $ P2 = True
            if C3_2 == 2:
                $ P2 = True
            if C4_2 == 2:
                $ P2 = True
            if C5_2 == 2:
                $ P2 = True
        elif P3 == False:
            if C1_3 == 2:
                $ P3 = True
            if C2_3 == 2:
                $ P3 = True 
            if C3_3 == 2:
                $ P3 = True
            if C4_3 == 2:
                $ P3 = True
            if C5_3 == 2:
                $ P3 = True



    screen rightbutt():
        if P1 == False:
            if C1_1 == 3:
                $ P1 = True
            if C2_1 == 3:
                $ P1 = True
            if C3_1 == 3:
                $ P1 = True
            if C4_1 == 3:
                $ P1 = True
            if C5_1 == 3:
                $ P1 = True
        elif P2 == False:
            if C1_2 == 3:
                $ P2 = True
            if C2_2 == 3:
                $ P2 = True
            if C3_2 == 3:
                $ P2 = True
            if C4_2 == 3:
                $ P2 = True
            if C5_2 == 3:
                $ P2 = True
        elif P3 == False:
            if C1_3 == 3:
                $ P3 = True
            if C2_3 == 3:
                $ P3 = True 
            if C3_3 == 3:
                $ P3 = True
            if C4_3 == 3:
                $ P3 = True
            if C5_3 == 3:
                $ P3 = True

    screen crane_controls():

        vbox:
            imagebutton:
                idle "images/Left_Idle.png"
                hover "images/Left_Hover.png"
                xpos 400 ypos 700
                action [Show("leftbutt")]
                at zoomless
        vbox:
            imagebutton:
                idle "images/Right_Idle.png"
                hover "images/Right_Hover.png"
                xpos 1000 ypos 700
                action [Show("rightbutt")]
                at zoomless
        vbox:
            imagebutton:
                idle "images/Up_Idle.png"
                hover "images/Up_Hover.png"
                xpos 700 ypos 600
                action [Show("upbutt")]
                at zoomless


    screen sloop():
        $ cranechoose()
        if cranechoose == "blue":
            if blue_cranes == 0:
                $ loop()
            else:
                $ columnchoose()
                if columnchoose == 1:
                    if Col_1 == True:
                        $ loop()
                    else:
                        add BlueCrane1 at column1
                        $ Col_1 = True
                        $ column1log()
                        if C1_1 == 1:
                            $ wait1()
                            add "L1" xalign 0.14 yalign 0.13
                        if C1_1 == 2:
                            $ wait1()
                            add "U1" xalign 0.14 yalign 0.13
                        if C1_1 == 3:
                            $ wait1()
                            add "R1" xalign 0.14 yalign 0.13
                        if C1_2 == 1:
                            $ wait1()
                            add "L2" xalign 0.17 yalign 0.13  
                        if C1_2 == 2:
                            $ wait1()
                            add "U2" xalign 0.17 yalign 0.13
                        if C1_2 == 3:
                            $ wait1()
                            add "R2" xalign 0.17 yalign 0.13 
                        if C1_3 == 1:
                            $ wait1()
                            add "L3" xalign 0.2 yalign 0.13 
                        if C1_3 == 2:
                            $ wait1()
                            add "U3" xalign 0.2 yalign 0.13
                        if C1_3 == 3:
                            $ wait1()
                            add "R3" xalign 0.2 yalign 0.13 

                if columnchoose == 2:
                    if Col_2 == True:
                        $ loop()
                    else:
                        add BlueCrane2 at column2
                        $ Col_2 = True
                        $ column2log()
                        if C2_1 == 1:
                            $ wait2()
                            add "L4" xalign 0.305 yalign 0.17 
                        if C2_1 == 2:
                            $ wait2()
                            add "U4" xalign 0.305 yalign 0.17 
                        if C2_1 == 3:
                            $ wait2()
                            add "R4" xalign 0.305 yalign 0.17
                        if C2_2 == 1:
                            $ wait2()
                            add "L5" xalign 0.335 yalign 0.17
                        if C2_2 == 2:
                            $ wait2()
                            add "U5" xalign 0.335 yalign 0.17
                        if C2_2 == 3:
                            $ wait2()
                            add "R5" xalign 0.335 yalign 0.17
                        if C2_3 == 1:
                            $ wait2()
                            add "L6" xalign 0.365 yalign 0.17
                        if C2_3 == 2:
                            $ wait2()
                            add "U6" xalign 0.365 yalign 0.17
                        if C2_3 == 3:
                            $ wait2()
                            add "R6" xalign 0.365 yalign 0.17



                if columnchoose == 3:
                    if Col_3 == True:
                        $ loop()
                    else:
                        add BlueCrane3 at column3
                        $ Col_3 = True
                        $ column3log()
                        if C3_1 == 1:
                            $ wait3()
                            add "L7" xalign 0.47 yalign 0.17
                        if C3_1 == 2:
                            $ wait3()
                            add "U7" xalign 0.47 yalign 0.17 
                        if C3_1 == 3:
                            $ wait3()
                            add "R7" xalign 0.47 yalign 0.17 
                        if C3_2 == 1:
                            $ wait3()
                            add "L8" xalign 0.5 yalign 0.17 
                        if C3_2 == 2:
                            $ wait3()
                            add "U8" xalign 0.5 yalign 0.17 
                        if C3_2 == 3:
                            $ wait3()
                            add "R8" xalign 0.5 yalign 0.17 
                        if C3_3 == 1:
                            $ wait3()
                            add "L9" xalign 0.53 yalign 0.17 
                        if C3_3 == 2:
                            $ wait3()
                            add "U9" xalign 0.53 yalign 0.17 
                        if C3_3 == 3:
                            $ wait3()
                            add "R9" xalign 0.53 yalign 0.17


                if columnchoose == 4:
                    if Col_4 == True:
                        $ loop()
                    else:
                        add BlueCrane4 at column4
                        $ Col_4 = True
                        $ column4log()
                        if C4_1 == 1:
                            $ wait4()
                            add "L10" xalign 0.635 yalign 0.17 
                        if C4_1 == 2:
                            $ wait4()
                            add "U10" xalign 0.635 yalign 0.17 
                        if C4_1 == 3:
                            $ wait4()
                            add "R10" xalign 0.635 yalign 0.17 
                        if C4_2 == 1:
                            $ wait4()
                            add "L11" xalign 0.665 yalign 0.17
                        if C4_2 == 2:
                            $ wait4()
                            add "U11" xalign 0.665 yalign 0.17
                        if C4_2 == 3:
                            $ wait4()
                            add "R11" xalign 0.665 yalign 0.17 
                        if C4_3 == 1:
                            $ wait4()
                            add "L12" xalign 0.695 yalign 0.17 
                        if C4_3 == 2:
                            $ wait4()
                            add "U12" xalign 0.695 yalign 0.17 
                        if C4_3 == 3:
                            $ wait4()
                            add "R12" xalign 0.695 yalign 0.17 


                if columnchoose == 5:
                    if Col_5 == True:                        
                        $ loop()
                    else:
                        add BlueCrane5 at column5
                        $ Col_5 = True
                        $ column5log()
                        if C5_1 == 1:
                            $ wait5()
                            add "L13" xalign 0.805 yalign 0.17 
                        if C5_1 == 2:
                            $ wait5()
                            add "U13" xalign 0.805 yalign 0.17 
                        if C5_1 == 3:
                            $ wait5()
                            add "R13" xalign 0.805 yalign 0.17 
                        if C5_2 == 1:
                            $ wait5()
                            add "L14" xalign 0.835 yalign 0.17
                        if C5_2 == 2:
                            $ wait5()
                            add "U14" xalign 0.835 yalign 0.17 
                        if C5_2 == 3:
                            $ wait5()
                            add "R14" xalign 0.835 yalign 0.17
                        if C5_3 == 1:
                            $ wait5()
                            add "L15" xalign 0.865 yalign 0.17 
                        if C5_3 == 2:
                            $ wait5()
                            add "U15" xalign 0.865 yalign 0.17
                        if C5_3 == 3:
                            $ wait5()
                            add "R15" xalign 0.865 yalign 0.17 



        elif cranechoose == "red":
            if red_cranes == 0:
                $ loop()
            else:
                $ columnchoose()
                if columnchoose == 1:
                    if Col_1 == True:
                        $ loop()
                    else:
                        add RedCrane1 at column1
                        $ Col_1 = True
                        $ column1log()
                        if C1_1 == 1:
                            $ wait1()
                            add "L1" xalign 0.14 yalign 0.13
                        if C1_1 == 2:
                            $ wait1()
                            add "U1" xalign 0.14 yalign 0.13
                        if C1_1 == 3:
                            $ wait1()
                            add "R1" xalign 0.14 yalign 0.13
                        if C1_2 == 1:
                            $ wait1()
                            add "L2" xalign 0.17 yalign 0.13  
                        if C1_2 == 2:
                            $ wait1()
                            add "U2" xalign 0.17 yalign 0.13
                        if C1_2 == 3:
                            $ wait1()
                            add "R2" xalign 0.17 yalign 0.13 
                        if C1_3 == 1:
                            $ wait1()
                            add "L3" xalign 0.2 yalign 0.13 
                        if C1_3 == 2:
                            $ wait1()
                            add "U3" xalign 0.2 yalign 0.13
                        if C1_3 == 3:
                            $ wait1()
                            add "R3" xalign 0.2 yalign 0.13 

                if columnchoose == 2:
                    if Col_2 == True:
                        $ loop()
                    else:
                        add RedCrane2 at column2
                        $ Col_2 = True
                        $ column2log()
                        if C2_1 == 1:
                            $ wait2()
                            add "L4" xalign 0.305 yalign 0.17 
                        if C2_1 == 2:
                            $ wait2()
                            add "U4" xalign 0.305 yalign 0.17 
                        if C2_1 == 3:
                            $ wait2()
                            add "R4" xalign 0.305 yalign 0.17
                        if C2_2 == 1:
                            $ wait2()
                            add "L5" xalign 0.335 yalign 0.17
                        if C2_2 == 2:
                            $ wait2()
                            add "U5" xalign 0.335 yalign 0.17
                        if C2_2 == 3:
                            $ wait2()
                            add "R5" xalign 0.335 yalign 0.17
                        if C2_3 == 1:
                            $ wait2()
                            add "L6" xalign 0.365 yalign 0.17
                        if C2_3 == 2:
                            $ wait2()
                            add "U6" xalign 0.365 yalign 0.17
                        if C2_3 == 3:
                            $ wait2()
                            add "R6" xalign 0.365 yalign 0.17

                if columnchoose == 3:
                    if Col_3 == True:
                        $ loop()
                    else:
                        add RedCrane3 at column3
                        $ Col_3 = True
                        $ column3log()
                        if C3_1 == 1:
                            $ wait3()
                            add "L7" xalign 0.47 yalign 0.17
                        if C3_1 == 2:
                            $ wait3()
                            add "U7" xalign 0.47 yalign 0.17 
                        if C3_1 == 3:
                            $ wait3()
                            add "R7" xalign 0.47 yalign 0.17 
                        if C3_2 == 1:
                            $ wait3()
                            add "L8" xalign 0.5 yalign 0.17 
                        if C3_2 == 2:
                            $ wait3()
                            add "U8" xalign 0.5 yalign 0.17 
                        if C3_2 == 3:
                            $ wait3()
                            add "R8" xalign 0.5 yalign 0.17 
                        if C3_3 == 1:
                            $ wait3()
                            add "L9" xalign 0.53 yalign 0.17 
                        if C3_3 == 2:
                            $ wait3()
                            add "U9" xalign 0.53 yalign 0.17 
                        if C3_3 == 3:
                            $ wait3()
                            add "R9" xalign 0.53 yalign 0.17

                if columnchoose == 4:
                    if Col_4 == True:
                        $ loop()
                    else:
                        add RedCrane4 at column4
                        $ Col_4 = True
                        $ column4log()
                        if C4_1 == 1:
                            $ wait4()
                            add "L10" xalign 0.635 yalign 0.17 
                        if C4_1 == 2:
                            $ wait4()
                            add "U10" xalign 0.635 yalign 0.17 
                        if C4_1 == 3:
                            $ wait4()
                            add "R10" xalign 0.635 yalign 0.17 
                        if C4_2 == 1:
                            $ wait4()
                            add "L11" xalign 0.665 yalign 0.17
                        if C4_2 == 2:
                            $ wait4()
                            add "U11" xalign 0.665 yalign 0.17
                        if C4_2 == 3:
                            $ wait4()
                            add "R11" xalign 0.665 yalign 0.17 
                        if C4_3 == 1:
                            $ wait4()
                            add "L12" xalign 0.695 yalign 0.17 
                        if C4_3 == 2:
                            $ wait4()
                            add "U12" xalign 0.695 yalign 0.17 
                        if C4_3 == 3:
                            $ wait4()
                            add "R12" xalign 0.695 yalign 0.17

                if columnchoose == 5:
                    if Col_5 == True:
                        $ loop()
                    else:
                        add RedCrane5 at column5
                        $ Col_5 = True
                        $ column5log()
                        if C5_1 == 1:
                            $ wait5()
                            add "L13" xalign 0.805 yalign 0.17 
                        if C5_1 == 2:
                            $ wait5()
                            add "U13" xalign 0.805 yalign 0.17 
                        if C5_1 == 3:
                            $ wait5()
                            add "R13" xalign 0.805 yalign 0.17 
                        if C5_2 == 1:
                            $ wait5()
                            add "L14" xalign 0.835 yalign 0.17
                        if C5_2 == 2:
                            $ wait5()
                            add "U14" xalign 0.835 yalign 0.17 
                        if C5_2 == 3:
                            $ wait5()
                            add "R14" xalign 0.835 yalign 0.17
                        if C5_3 == 1:
                            $ wait5()
                            add "L15" xalign 0.865 yalign 0.17 
                        if C5_3 == 2:
                            $ wait5()
                            add "U15" xalign 0.865 yalign 0.17
                        if C5_3 == 3:
                            $ wait5()
                            add "R15" xalign 0.865 yalign 0.17

        elif cranechoose == "green":
            if green_cranes == 0:
                $ loop()
            else:
                $ columnchoose()
                if columnchoose == 1:
                    if Col_1 == True:
                        $ loop()
                    else:
                        add GreenCrane1 at column1
                        $ Col_1 = True
                        $ column1log()
                        if C1_1 == 1:
                            $ wait1()
                            add "L1" xalign 0.14 yalign 0.13
                        if C1_1 == 2:
                            $ wait1()
                            add "U1" xalign 0.14 yalign 0.13
                        if C1_1 == 3:
                            $ wait1()
                            add "R1" xalign 0.14 yalign 0.13
                        if C1_2 == 1:
                            $ wait1()
                            add "L2" xalign 0.17 yalign 0.13  
                        if C1_2 == 2:
                            $ wait1()
                            add "U2" xalign 0.17 yalign 0.13
                        if C1_2 == 3:
                            $ wait1()
                            add "R2" xalign 0.17 yalign 0.13 
                        if C1_3 == 1:
                            $ wait1()
                            add "L3" xalign 0.2 yalign 0.13 
                        if C1_3 == 2:
                            $ wait1()
                            add "U3" xalign 0.2 yalign 0.13
                        if C1_3 == 3:
                            $ wait1()
                            add "R3" xalign 0.2 yalign 0.13 

                if columnchoose == 2:
                    if Col_2 == True:
                        $ loop()
                    else:
                        add GreenCrane2 at column2
                        $ Col_2 = True
                        $ column2log()
                        if C2_1 == 1:
                            $ wait2()
                            add "L4" xalign 0.305 yalign 0.17 
                        if C2_1 == 2:
                            $ wait2()
                            add "U4" xalign 0.305 yalign 0.17 
                        if C2_1 == 3:
                            $ wait2()
                            add "R4" xalign 0.305 yalign 0.17
                        if C2_2 == 1:
                            $ wait2()
                            add "L5" xalign 0.335 yalign 0.17
                        if C2_2 == 2:
                            $ wait2()
                            add "U5" xalign 0.335 yalign 0.17
                        if C2_2 == 3:
                            $ wait2()
                            add "R5" xalign 0.335 yalign 0.17
                        if C2_3 == 1:
                            $ wait2()
                            add "L6" xalign 0.365 yalign 0.17
                        if C2_3 == 2:
                            $ wait2()
                            add "U6" xalign 0.365 yalign 0.17
                        if C2_3 == 3:
                            $ wait2()
                            add "R6" xalign 0.365 yalign 0.17

                if columnchoose == 3:
                    if Col_3 == True:
                        $ loop()
                    else:
                        add GreenCrane3 at column3
                        $ Col_3 = True
                        $ column3log()
                        if C3_1 == 1:
                            $ wait3()
                            add "L7" xalign 0.47 yalign 0.17
                        if C3_1 == 2:
                            $ wait3()
                            add "U7" xalign 0.47 yalign 0.17 
                        if C3_1 == 3:
                            $ wait3()
                            add "R7" xalign 0.47 yalign 0.17 
                        if C3_2 == 1:
                            $ wait3()
                            add "L8" xalign 0.5 yalign 0.17 
                        if C3_2 == 2:
                            $ wait3()
                            add "U8" xalign 0.5 yalign 0.17 
                        if C3_2 == 3:
                            $ wait3()
                            add "R8" xalign 0.5 yalign 0.17 
                        if C3_3 == 1:
                            $ wait3()
                            add "L9" xalign 0.53 yalign 0.17 
                        if C3_3 == 2:
                            $ wait3()
                            add "U9" xalign 0.53 yalign 0.17 
                        if C3_3 == 3:
                            $ wait3()
                            add "R9" xalign 0.53 yalign 0.17

                if columnchoose == 4:
                    if Col_4 == True:
                        $ loop()
                    else:
                        add GreenCrane4 at column4
                        $ Col_4 = True
                        $ column4log()
                        if C4_1 == 1:
                            $ wait4()
                            add "L10" xalign 0.635 yalign 0.17 
                        if C4_1 == 2:
                            $ wait4()
                            add "U10" xalign 0.635 yalign 0.17 
                        if C4_1 == 3:
                            $ wait4()
                            add "R10" xalign 0.635 yalign 0.17 
                        if C4_2 == 1:
                            $ wait4()
                            add "L11" xalign 0.665 yalign 0.17
                        if C4_2 == 2:
                            $ wait4()
                            add "U11" xalign 0.665 yalign 0.17
                        if C4_2 == 3:
                            $ wait4()
                            add "R11" xalign 0.665 yalign 0.17 
                        if C4_3 == 1:
                            $ wait4()
                            add "L12" xalign 0.695 yalign 0.17 
                        if C4_3 == 2:
                            $ wait4()
                            add "U12" xalign 0.695 yalign 0.17 
                        if C4_3 == 3:
                            $ wait4()
                            add "R12" xalign 0.695 yalign 0.17

                if columnchoose == 5:
                    if Col_5 == True:
                        $ loop()
                    else:
                        add GreenCrane5 at column5
                        $ Col_5 = True
                        $ column5log()
                        if C5_1 == 1:
                            $ wait5()
                            add "L13" xalign 0.805 yalign 0.17 
                        if C5_1 == 2:
                            $ wait5()
                            add "U13" xalign 0.805 yalign 0.17 
                        if C5_1 == 3:
                            $ wait5()
                            add "R13" xalign 0.805 yalign 0.17 
                        if C5_2 == 1:
                            $ wait5()
                            add "L14" xalign 0.835 yalign 0.17
                        if C5_2 == 2:
                            $ wait5()
                            add "U14" xalign 0.835 yalign 0.17 
                        if C5_2 == 3:
                            $ wait5()
                            add "R14" xalign 0.835 yalign 0.17
                        if C5_3 == 1:
                            $ wait5()
                            add "L15" xalign 0.865 yalign 0.17 
                        if C5_3 == 2:
                            $ wait5()
                            add "U15" xalign 0.865 yalign 0.17
                        if C5_3 == 3:
                            $ wait5()
                            add "R15" xalign 0.865 yalign 0.17

        elif cranechoose == "gold":
            if gold_cranes == 0:
                $ loop()
            else:
                $ columnchoose()
                if columnchoose == 1:
                    if Col_1 == True:
                        $ loop()
                    else:
                        add GoldCrane1 at column1
                        $ Col_1 = True
                        $ column1log()
                        if C1_1 == 1:
                            $ wait1()
                            add "L1" xalign 0.14 yalign 0.13
                        if C1_1 == 2:
                            $ wait1()
                            add "U1" xalign 0.14 yalign 0.13
                        if C1_1 == 3:
                            $ wait1()
                            add "R1" xalign 0.14 yalign 0.13
                        if C1_2 == 1:
                            $ wait1()
                            add "L2" xalign 0.17 yalign 0.13  
                        if C1_2 == 2:
                            $ wait1()
                            add "U2" xalign 0.17 yalign 0.13
                        if C1_2 == 3:
                            $ wait1()
                            add "R2" xalign 0.17 yalign 0.13 
                        if C1_3 == 1:
                            $ wait1()
                            add "L3" xalign 0.2 yalign 0.13 
                        if C1_3 == 2:
                            $ wait1()
                            add "U3" xalign 0.2 yalign 0.13
                        if C1_3 == 3:
                            $ wait1()
                            add "R3" xalign 0.2 yalign 0.13 

                if columnchoose == 2:
                    if Col_2 == True:
                        $ loop()
                    else:
                        add GoldCrane2 at column2
                        $ Col_2 = True
                        $ column2log()
                        if C2_1 == 1:
                            $ wait2()
                            add "L4" xalign 0.305 yalign 0.17 
                        if C2_1 == 2:
                            $ wait2()
                            add "U4" xalign 0.305 yalign 0.17 
                        if C2_1 == 3:
                            $ wait2()
                            add "R4" xalign 0.305 yalign 0.17
                        if C2_2 == 1:
                            $ wait2()
                            add "L5" xalign 0.335 yalign 0.17
                        if C2_2 == 2:
                            $ wait2()
                            add "U5" xalign 0.335 yalign 0.17
                        if C2_2 == 3:
                            $ wait2()
                            add "R5" xalign 0.335 yalign 0.17
                        if C2_3 == 1:
                            $ wait2()
                            add "L6" xalign 0.365 yalign 0.17
                        if C2_3 == 2:
                            $ wait2()
                            add "U6" xalign 0.365 yalign 0.17
                        if C2_3 == 3:
                            $ wait2()
                            add "R6" xalign 0.365 yalign 0.17

                if columnchoose == 3:
                    if Col_3 == True:
                        $ loop()
                    else:
                        add GoldCrane3 at column3
                        $ Col_3 = True
                        $ column3log()
                        if C3_1 == 1:
                            $ wait3()
                            add "L7" xalign 0.47 yalign 0.17
                        if C3_1 == 2:
                            $ wait3()
                            add "U7" xalign 0.47 yalign 0.17 
                        if C3_1 == 3:
                            $ wait3()
                            add "R7" xalign 0.47 yalign 0.17 
                        if C3_2 == 1:
                            $ wait3()
                            add "L8" xalign 0.5 yalign 0.17 
                        if C3_2 == 2:
                            $ wait3()
                            add "U8" xalign 0.5 yalign 0.17 
                        if C3_2 == 3:
                            $ wait3()
                            add "R8" xalign 0.5 yalign 0.17 
                        if C3_3 == 1:
                            $ wait3()
                            add "L9" xalign 0.53 yalign 0.17 
                        if C3_3 == 2:
                            $ wait3()
                            add "U9" xalign 0.53 yalign 0.17 
                        if C3_3 == 3:
                            $ wait3()
                            add "R9" xalign 0.53 yalign 0.17

                if columnchoose == 4:
                    if Col_4 == True:
                        $ loop()
                    else:
                        add GoldCrane4 at column4
                        $ Col_4 = True
                        $ column4log()
                        if C4_1 == 1:
                            $ wait4()
                            add "L10" xalign 0.635 yalign 0.17 
                        if C4_1 == 2:
                            $ wait4()
                            add "U10" xalign 0.635 yalign 0.17 
                        if C4_1 == 3:
                            $ wait4()
                            add "R10" xalign 0.635 yalign 0.17 
                        if C4_2 == 1:
                            $ wait4()
                            add "L11" xalign 0.665 yalign 0.17
                        if C4_2 == 2:
                            $ wait4()
                            add "U11" xalign 0.665 yalign 0.17
                        if C4_2 == 3:
                            $ wait4()
                            add "R11" xalign 0.665 yalign 0.17 
                        if C4_3 == 1:
                            $ wait4()
                            add "L12" xalign 0.695 yalign 0.17 
                        if C4_3 == 2:
                            $ wait4()
                            add "U12" xalign 0.695 yalign 0.17 
                        if C4_3 == 3:
                            $ wait4()
                            add "R12" xalign 0.695 yalign 0.17

                if columnchoose == 5:
                    if Col_5 == True:
                        $ loop()
                    else:
                        add GoldCrane5 at column5
                        $ Col_5 = True
                        $ column5log()
                        if C5_1 == 1:
                            $ wait5()
                            add "L13" xalign 0.805 yalign 0.17 
                        if C5_1 == 2:
                            $ wait5()
                            add "U13" xalign 0.805 yalign 0.17 
                        if C5_1 == 3:
                            $ wait5()
                            add "R13" xalign 0.805 yalign 0.17 
                        if C5_2 == 1:
                            $ wait5()
                            add "L14" xalign 0.835 yalign 0.17
                        if C5_2 == 2:
                            $ wait5()
                            add "U14" xalign 0.835 yalign 0.17 
                        if C5_2 == 3:
                            $ wait5()
                            add "R14" xalign 0.835 yalign 0.17
                        if C5_3 == 1:
                            $ wait5()
                            add "L15" xalign 0.865 yalign 0.17 
                        if C5_3 == 2:
                            $ wait5()
                            add "U15" xalign 0.865 yalign 0.17
                        if C5_3 == 3:
                            $ wait5()
                            add "R15" xalign 0.865 yalign 0.17

In script.rpy..

Code: Select all

default crane_difficulty = "Easy"
default C1_1 = 0
default C1_2 = 0
default C1_3 = 0
default C2_1 = 0
default C2_2 = 0
default C2_3 = 0
default C3_1 = 0
default C3_2 = 0
default C3_3 = 0
default C4_1 = 0
default C4_2 = 0
default C4_3 = 0
default C5_1 = 0
default C5_2 = 0
default C5_3 = 0

Code: Select all

  image BlueCrane1 = Image("BlueCrane.png")
    image BlueCrane2 = Image("BlueCrane.png")
    image BlueCrane3 = Image("BlueCrane.png")
    image BlueCrane4 = Image("BlueCrane.png")
    image BlueCrane5 = Image("BlueCrane.png")
    image RedCrane1 = Image("RedCrane.png")
    image RedCrane2 = Image("RedCrane.png")
    image RedCrane3 = Image("RedCrane.png")
    image RedCrane4 = Image("RedCrane.png")
    image RedCrane5 = Image("RedCrane.png")
    image GreenCrane1 = Image("GreenCrane.png")
    image GreenCrane2 = Image("GreenCrane.png")
    image GreenCrane3 = Image("GreenCrane.png")
    image GreenCrane4 = Image("GreenCrane.png")
    image GreenCrane5 = Image("GreenCrane.png")
    image GoldCrane1 = Image("GoldCrane.png")
    image GoldCrane2 = Image("GoldCrane.png")
    image GoldCrane3 = Image("GoldCrane.png")
    image GoldCrane4 = Image("GoldCrane.png")
    image GoldCrane5 = Image("GoldCrane.png")
    if GL1 == False:
        image L1 = Image("LeftSm.png")
    if GL1 == True:
        image L1 = Image("LeftGr.png")
    if GL2 == False:
        image L2 = Image("LeftSm.png")
    if GL2 == True:
        image L2 = Image("LeftGr.png")
    if GL3 == False:
        image L3 = Image("LeftSm.png")
    if GL3 == True:
        image L3 = Image("LeftGr.png")
    if GL4 == False:
        image L4 = Image("LeftSm.png")
    if GL4 == True:
        image L4 = Image("LeftGr.png")
    if GL5 == False:
        image L5 = Image("LeftSm.png")
    if GL5 == True:
        image L5 = Image("LeftGr.png")
    if GL6 == False:
        image L6 = Image("LeftSm.png")
    if GL6 == True:
        image L6 = Image("LeftGr.png")
    if GL7 == False:
        image L7 = Image("LeftSm.png")
    if GL7 == True:
        image L7 = Image("LeftGr.png")
    if GL8 == False:
        image L8 = Image("LeftSm.png")
    if GL8 == True:
        image L8 = Image("LeftGr.png")
    if GL9 == False:
        image L9 = Image("LeftSm.png")
    if GL9 == True:
        image L9 = Image("LeftGr.png")
    if GL10 == False:
        image L10 = Image("LeftSm.png")
    if GL10 == True:
        image L10 = Image("LeftGr.png")
    if GL11 == False:
        image L11 = Image("LeftSm.png")
    if GL11 == True:
        image L11 = Image("LeftGr.png")
    if GL12 == False:
        image L12 = Image("LeftSm.png")
    if GL12 == True:
        image L12 = Image("LeftGr.png")
    if GL13 == False:
        image L13 = Image("LeftSm.png")
    if GL13 == True:
        image L13 = Image("LeftGr.png")
    if GL14 == False:
        image L14 = Image("LeftSm.png")
    if GL14 == True:
        image L14 = Image("LeftGr.png")
    if GL15 == False:
        image L15 = Image("LeftSm.png")
    if GL15 == True:
        image L15 = Image("LeftGr.png")

    if GU1 == False:
        image U1 = Image("UpSm.png")
    if GU1 == True:
        image U1 = Image("UpGr.png")
    if GU2 == False:
        image U2 = Image("UpSm.png")
    if GU2 == True:
        image U2 = Image("UpGr.png")
    if GU3 == False:
        image U3 = Image("UpSm.png")
    if GU3 == True:
        image U3 = Image("UpGr.png")
    if GU4 == False:
        image U4 = Image("UpSm.png")
    if GU4 == True:
        image U4 = Image("UpGr.png")
    if GU5 == False:
        image U5 = Image("UpSm.png")
    if GU5 == True:
        image U5 = Image("UpGr.png")
    if GU6 == False:
        image U6 = Image("UpSm.png")
    if GU6 == True:
        image U6 = Image("UpGr.png")
    if GU7 == False:
        image U7 = Image("UpSm.png")
    if GU7 == True:
        image U7 = Image("UpGr.png")
    if GU8 == False:
        image U8 = Image("UpSm.png")
    if GU8 == True:
        image U8 = Image("UpGr.png")
    if GU9 == False:
        image U9 = Image("UpSm.png")
    if GU9 == True:
        image U9 = Image("UpGr.png")
    if GU10 == False:
        image U10 = Image("UpSm.png")
    if GU10 == True:
        image U10 = Image("UpGr.png")
    if GU11 == False:
        image U11 = Image("UpSm.png")
    if GU11 == True:
        image U11 = Image("UpGr.png")
    if GU12 == False:
        image U12 = Image("UpSm.png")
    if GU12 == True:
        image U12 = Image("UpGr.png")
    if GU13 == False:
        image U13 = Image("UpSm.png")
    if GU13 == True:
        image U13 = Image("UpGr.png")
    if GU14 == False:
        image U14 = Image("UpSm.png")
    if GU14 == True:
        image U14 = Image("UpGr.png")
    if GU15 == False:
        image U15 = Image("UpSm.png")
    if GU15 == True:
        image U15 = Image("UpGr.png")
    image R1 = Image("RightSm.png")
    image R2 = Image("RightSm.png")
    image R3 = Image("RightSm.png")
    image R4 = Image("RightSm.png")
    image R5 = Image("RightSm.png")
    image R6 = Image("RightSm.png")
    image R7 = Image("RightSm.png")
    image R8 = Image("RightSm.png")
    image R9 = Image("RightSm.png")
    image R10 = Image("RightSm.png")
    image R11 = Image("RightSm.png")
    image R12 = Image("RightSm.png")
    image R13 = Image("RightSm.png")
    image R14 = Image("RightSm.png")
    image R15 = Image("RightSm.png")

Code: Select all

label giftwrap:
    scene bg cranedesk
    play music MountainKing

    if crane_difficulty == "Easy":
        $ blue_cranes = 30
        $ red_cranes = 15
        $ green_cranes = 0
        $ gold_cranes = 0

    elif crane_difficulty == "Medium":
        $ blue_cranes = 25
        $ red_cranes =  25
        $ green_cranes = 0
        $ gold_cranes = 0

    elif crane_difficulty == "Hard":
        $ blue_cranes = 20
        $ red_cranes =  25
        $ green_cranes = 14
        $ gold_cranes = 1

    elif crane_difficulty == "Ultra":
        $ blue_cranes = 20
        $ red_cranes =  20
        $ green_cranes = 20
        $ gold_cranes = 10

    show screen crane_controls
    jump gameloop    


label gameloop:
    hide screen loop
    show screen crane_controls
    $ TotalNo = blue_cranes + red_cranes + green_cranes + gold_cranes
    if TotalNo == 0:
        $ has_started = False
        $ has_ended = True 
        jump gameend

    elif TotalNo >= 1:
        show screen sloop
        $ renpy.pause(2.0, hard=True)
        jump gameloop



label gameend:
    return

Basically, I cannot for the life of me figure out how, using functions and screens, I can get a variable that is randomly defined as one of four strings in a list to then output cranes with my if/then statements. :\

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#9 Post by thexerox123 »

An instance of one of my attempted fixes:
in crane_game_displayable:

Code: Select all

            def cranechoice():
                cranechoose = renpy.random.choice("CraneList") 

Code: Select all

   screen sloop():
        $ cranechoice()
        if cranechoose == "blue":
            if blue_cranes == 0:
                $ loop()
in script.rpy:

Code: Select all

define CraneList = ["blue", "red", "green", "gold"]
default cranechoose = "blue"
I get NameError: name "cranechoice" is not defined.

I've tried putting $ cranechoose = return(cranechoice) in sloop, I've tried SetVariable, I've tried a bunch of things. Keep looking up how to go from a python function to a renpy screen and cannot find an answer yet. :(

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#10 Post by thexerox123 »

Oop, nevermind, I found my issue, I had the defs within a class rather than straight in the init python. *facepalm*

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#11 Post by thexerox123 »

And added quotes around "cranechoose" in the screen.

And added extra brackets for my randoms:

Code: Select all

        def cranechoice():
            cranechoose = renpy.random.choice(("blue","red","green","gold"))
        def columnchoice():
            columnchoose = renpy.random.randint((1,5))
Still only getting my buttons displayed, but no cranes.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#12 Post by _ticlock_ »

thexerox123 wrote: Sat Feb 04, 2023 8:10 pm my buttons displayed, but no cranes.
Basically you can make all logic inside python and set necessary variables as a result. Ideally you should use class for this purpose.

The screen can use if statements to build the logic what and how should be displayed.

Having a lot of similar lines of code is hard to work with and even harder to modify if needed.

I can make a simple version of your game as an example. Let me know if you’re interested.

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#13 Post by thexerox123 »

_ticlock_ wrote: Mon Feb 06, 2023 4:21 am
thexerox123 wrote: Sat Feb 04, 2023 8:10 pm my buttons displayed, but no cranes.
Basically you can make all logic inside python and set necessary variables as a result. Ideally you should use class for this purpose.

The screen can use if statements to build the logic what and how should be displayed.

Having a lot of similar lines of code is hard to work with and even harder to modify if needed.

I can make a simple version of your game as an example. Let me know if you’re interested.
That... would be amazing. Thank you so much for your patience and generosity!
I've been pretty good at implementing existing code to my purposes (have managed to get a navigation system and an inventory working with some tweaks), but yeah, I got in over my head syntactically with this one, but it's been a great learning experience, and seeing the proper way to do it would be even more instructive! :)

Here are the assets, if that helps!

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#14 Post by _ticlock_ »

thexerox123 wrote: Mon Feb 06, 2023 10:47 am That... would be amazing.
Here is a working example. I used function renpy.random.choices for simplicity that uses python 3, so this example is for Renpy 8. I didn't comment much, so if something is unclear, you can always ask.

I defined crane images as colored rectangles and arrows as text symbols:

Code: Select all

image blue_crane = Solid("#88f", xysize=(200,200))
image red_crane = Solid("#f88", xysize=(200,200))
image green_crane = Solid("#8f8", xysize=(200,200))
image gold_crane = Solid("#f8f", xysize=(200,200))

image a_right = Text('\u27A1', size=60, color='#fff')
image a_left = Text('\u2B05', size=60, color='#fff')
image a_up = Text('\u2B06', size=60, color='#fff')
image a_down = Text('\u2B07', size=60, color='#fff')
I tested for game resolution (1920, 1080). It may look bad in different resolution.

class Crane and CraneGame:
attribute progress (class Crane) show how many arrows are pressed correctly
progress = "start" - for appearing animation
progress = "done" - all arrows pressed successfully
progress = "miss" - the crane is timed out.
dt_start = 1.0 - appearing animation time
dt_end = 1.0 - disappearing animation time

Code: Select all

init python:
   class Crane():
        def __init__(self, crane_type, start_st, duration,
                    number_of_arrows = 3, dt_start = 1.0, dt_end = 1.0):
            self.d = crane_type
            self.start_st = start_st
            self.duration = duration
            self.dt_start = dt_start
            self.dt_end = dt_end

            self.arrows = []
            for i in range(0,number_of_arrows):
                self.arrows.append(renpy.random.choice(
                                    ["a_right", "a_left", "a_up", "a_down"]))
            self.progress = "start"

        def input_handler(self, key, st):
            try:
                if self.arrows[self.progress] == key:
                    self.progress += 1
                    if self.progress == len(self.arrows):
                        self.progress = "done"
                        self.end_st = st
                        return True
                else:
                    self.progress == 0
            except TypeError:
                return

        def time_handler(self, st):
            if self.progress == "start":
                if self.timer(st) <= 0:
                    self.progress = 0
            else:
                if self.timer(st) <= 0:
                    if self.progress == "done" or self.progress == "miss":
                        return True
                    else:
                        self.end_st = st
                        self.progress = "miss"

        def timer(self, st):
            if self.progress == "start":
                return self.start_st + self.dt_start - st
            elif self.progress == "done" or self.progress == "miss":
                return self.end_st + self.dt_end - st
            else:
                return self.start_st + self.dt_start + self.duration - st



    class CraneGame():
        def __init__(self, difficulty):
            self.game_finished = False
            self.score = 0
            self.difficulty = difficulty
            self.time = 0
            if difficulty == "easy":
                self.cranes_left = [30,15,0,0]
            elif difficulty == "medium":
                self.cranes_left = [25,25,0,0]
            elif difficulty == "hard":
                self.cranes_left = [20,20,10,5]
            else:
                self.cranes_left = [20,20,20,10]

            self.columns = [[],[],[],[],[]]


        def generate_crane(self):
            if self.cranes_left == [0,0,0,0]:
                return

            # generate crane in empty columns
            weights = [(1 if i == [] else 0) for i in self.columns]
            if weights == [0]*len(self.columns):
                weights = [1]*len(self.columns)
            column = renpy.random.choices(range(0,5), weights=weights, k=1)[0]

            crane_types = ["blue_crane", "red_crane", "green_crane", "gold_crane"]
            crane_id = renpy.random.choices(range(0,4), weights=self.cranes_left, k=1)[0]
            self.cranes_left[crane_id] -= 1
            crane_type = crane_types[crane_id]
            duration = 5.0 - 1.0*crane_id
            dt_start = 0.2 + 0.2*column
            crane = Crane(crane_type, self.time, duration, dt_start = dt_start)


            self.columns[column].append(crane)

        def number_of_shown_cranes(self):
            n = 0
            for column in self.columns:
                for crane in column:
                    n += 1
            return n

        def set_screen_timer(self):
            t = 1000
            for column in self.columns:
                for crane in column:
                    new_t = crane.timer(self.time)
                    if new_t < t:
                        t = new_t
            if t != 1000:
                self.timer = t
            else:
                self.game_finished = True



        def handler(self, key = None):
            if key:
                for column in self.columns:
                    for crane in column:
                        if crane.input_handler(key, self.time):
                            self.score += 1

            for column in self.columns:
                for crane in column:
                    remove_crane = crane.time_handler(self.time)
                    if remove_crane:
                        column.pop()
            # Check if necessary to generate new cranes
            n = self.number_of_shown_cranes()
            if n < 5:
                for i in range(0, 5-n):
                    self.generate_crane()

            self.set_screen_timer()
The screen and transforms
I created only one transform for the crane to appear as an example. You can create other transforms if you'd like (Check the screen comments).

Please note, since each crane has its own timing, transforms need to calculate position based on current crane timing (check how transform crane_appear is defined).

Arrows are shown only once the crane appearing animation is finished. Also, I added animated bar to see how much time left for each crane combination.

Code: Select all

transform crane_appear(col, left_st):
    xalign (0.1 + 0.2*col - left_st) yalign 0.5
    linear left_st  xalign (0.1 + 0.2*col)

Code: Select all

screen s_crane_game():
    for col, column in enumerate(crane_game.columns):
        for crane in column:
            $ left_time = crane.timer(crane_game.time)
            if crane.progress == "start":
                # move_in animation
                add crane.d at crane_appear(col, left_time)
            elif crane.progress == "done":
                # success animation
                pass
            elif crane.progress == "miss":
                # fail animation
                pass
            else:
                add crane.d:
                    xalign (0.1 + 0.2*col) yalign 0.5
                hbox:
                    xalign (0.1 + 0.2*col) yalign 0.3
                    for j, arrow in enumerate(crane.arrows):
                        frame:
                            if crane.progress > j:
                                background "#8f8"
                            else:
                                background "#888"
                            add arrow
                bar:
                    xsize 200 ysize 50
                    xalign (0.1 + 0.2*col) yalign 0.7
                    value AnimatedValue(value=0.0,
                        range=crane.duration,
                        delay=left_time,
                        old_value=left_time)
    hbox:
        xalign 0.5 yalign 0.9 spacing 100
        for btn_img in ["a_left", "a_right", "a_up", "a_down"]:
            imagebutton:
                idle btn_img action Return(btn_img)
                hover Transform(btn_img, matrixcolor=TintMatrix("#f00"))

    text "Score = {}".format(crane_game.score) xalign 1.0 yalign 1.0
    text "Cranes left = {}".format(sum(crane_game.cranes_left)) xalign 0.5 yalign 1.0
    timer crane_game.timer action Return()
    key "input_left" action Return("a_left")
    key "input_right" action Return("a_right")
    key "input_up" action Return("a_up")
    key "input_down" action Return("a_down")
It turned out that using a simple timer to check the current game time was buggy for some reason. I didn't want to try to figure out what was the problem, so I decided to use the following timer:

Code: Select all

init python:
    class TimerObj(renpy.Displayable):
        def __init__(self, obj, name, **kwargs):
            super(TimerObj, self).__init__(**kwargs)
            self.obj = obj
            self.name = name
            setattr(self.obj, self.name, 0)
        def render(self, width, height, st, at):
            if getattr(self.obj, self.name) < st:
                setattr(self.obj, self.name, st)
            return renpy.Render(0, 0)
Finally the label statements:

Code: Select all

label start:
    call l_crane_game

Code: Select all

label l_crane_game:
    menu:
        "Easy":
            $ crane_difficulty = "easy"
        "Medium":
            $ crane_difficulty = "medium"
        "Hard":
            $ crane_difficulty = "hard"
        "Ultra Hard":
            $ crane_difficulty = "ultra"
    $ _rollback = False
    $ crane_game = CraneGame(crane_difficulty)
    show expression TimerObj(crane_game, "time") as crane_timer
    $ key = None
label .loop:
    $ crane_game.handler(key)
    if crane_game.game_finished:
        jump .results
    call screen s_crane_game
    if _return:
        $ key = _return
    else:
        $ key = None
    jump .loop

label .results:
    hide crane_timer
    "Your score is [crane_game.score]"
    return

thexerox123
Regular
Posts: 140
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Minigame Help - (Update) Screens, Inputs, Gameloops

#15 Post by thexerox123 »

Holy shit, thank you so much, I'm already starting to copy that over and go through it.

A couple of questions already: where does the timer go? In the init of the displayable, but after the screen?

And the other question, I wanted to introduce the game first through narrative, going up through the difficulties, and then have it available after that as a replayable minigame with selectable difficulty. Will that still work, or will I need to shift some things from l_crane_game over to .loop?

Edit: Hmm, but I'm not sure how to jump to .loop from earlier. I'm guessing I need to put a new label before .loop, put the stuff aside from the difficulty select into there, and jump to that instead? ---- I think I solved that as described.

But now... sorry, but I'm still a bit confused about what col and left_st refer to in the transform.

And is this the right way/place to define the different crane speeds?

Code: Select all

                crane_types = ["blue_crane", "red_crane", "green_crane", "gold_crane"]
                crane_id = renpy.random.choices(range(0,4), weights=self.cranes_left, k=1)[0]
                self.cranes_left[crane_id] -= 1
                crane_type = crane_types[crane_id]
                duration = 5.0 - 1.0*crane_id
                dt_start = 0.2 + 0.2*column
                crane = Crane(crane_type, self.time, duration, dt_start = dt_start)
                blue = Crane("blue_crane", 1.0, 6.0)
                red = Crane("red_crane", 1.0, 5.0)
                green = Crane("green_crane", 1.0, 4.5)
                gold = Crane("gold_crane", 1.0, 4.0)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot]