Kaen wrote:Your code was very helpful, thank you xela! I changed it a bit and got some questions.
Code: Select all
screen ball(ball):
text "[ball.xpos], [ball.ypos]"
default xy = "%d,%d" % (ball.xpos, ball.ypos)
timer 0.1 action (SetScreenVariable("xy", xy + " _ %d,%d" % (ball.xpos, ball.ypos)), renpy.restart_interaction) repeat True
timer 2.0 action Return(xy)
label start:
$ ball = At(ImageReference("ball"), move_ball)
show expression ball
call screen ball(ball)
$ value = _return
$ renpy.log(value)
return
• I wanna store the positions on a variable but it seems I'm not getting the updated positions. Any idea on how to fix this? On the log file I always get tons of "0,0 _ 0,0 _..."
You can try this, screen will act as a timer reporting the values. It should work:
Code: Select all
screen ball(ball):
text "[ball.xpos], [ball.ypos]"
timer 0.1 action (Function(renpy.log, "%d,%d" % (ball.xpos, ball.ypos)), renpy.restart_interaction) repeat True
label start:
$ ball = At(ImageReference("ball"), move_ball)
show expression ball
call screen ball(ball)
Kaen wrote:• The positions displayed on the ball screen are on the form of values from 0 to 1. There is a way to get those values as pixels?
[/code]
Take the width/height of the screen and multiply with the values accordingly. If you need them to report in that way, you need to define them like that in the transform (pos(100, 100) instead of pos(0.1, 0.1) for a 1000 by 1000 resolution for example). If there is another way, I am not aware of it without digging in code/docs.
Kaen wrote:• I wanna the pixel values so I can use them on the update function for the rhythm game. That function can work with values from 0 to 1 form?
I am not sure, I never use positions as floats. You can always try
==========================================================
I assume that you understood the code in the last post well enough to provide positions and speed to the sprites so why are you doing this?