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!