Code: Select all
init -1:
transform throw_ball():
subpixel True
xpos 960
ypos 1080
rotate -360
linear 0.5 xpos 0 ypos 0
init -1 python:
# Set up some objects to track the game state.
ball = Ball("baseball")
user = Player("Sam", baseball=ball)
game_world = World(ball, user)
screen doit():
imagebutton:
action Return(user.name)
idle "images/player.png"
xpos 400
ypos 0
screen render_ball():
add "images/ball.png" at throw_ball()
label start():
scene bg background
while True:
call screen doit()
$ res = _return
if res == user.name:
show screen render_ball()
$ game_world.updateScore()
$ ball.checkAndUpdate()
$ renpy.pause(0.5)
hide screen render_ball
return- Player clicks on the player's icon (the imagebutton). The action is returned, and the result is checked.
- If result is the player's name, render the ball ATL, update the mini game logic, wait for the ATL to finish (0.5s), then hide the ball because we've thrown it.
- Game while loops back and begins the interaction again, waiting for the player to click on his icon.
There are two problems I'm seeing here:
1) When the ball screen renders, everything else on the screen disappears, and after the ball screen is hidden, the displayables in the main screen returns again. @rames44 mentioned in another thread that it's because when action Returns back to the label, it hides the default screen, which is why I see them disappear. If I put the ball screen in the doit() screen, how can I conditionally render throwing my ball there?
2) I have to also update the game world logic. How do I also conditionally update the game logic if I move the ball screen code into the doit() screen?
I guess I don't understand how to handle the overall user interaction with the screen. Can someone help?