Regarding the script in the tutorial project : Pong
Hi. Sorry to keep bothering you guys. I am new to programming. I am learning the Simple 2D game project called Pong in the tutorial. From what I understand, the _process() function is some kind of loop that run for every second(please correct me if I am wrong. I thought I read about this in the previous chapters but everything is very difficult to understand for me and I cannot remember clearly). If that is the case, then the script in the sample project of Pong below is very confusing, and very inefficient in my understanding:
# Get ball position and pad rectangles
var ball_pos = get_node("ball").get_pos()
var left_rect = Rect2(get_node("left").get_pos() - pad_size*0.5, pad_size)
var right_rect = Rect2(get_node("right").get_pos() - pad_size*0.5, pad_size)
Is it correct to say that the coder declares ball_pos,left_rect,and right_rect with the var in front of them for every second the loop is run? If that is the case, does it mean the code has to allocate new var every second and then discard them at the end of the _process()? Should not the three of them be declared outside of this function? I find this very wrong practice(pardon my bad english). Am I missing something here? Thanks.