@@ -2,7 +2,7 @@ use crate::pong::Pong;
22use godot:: classes:: { Area2D , IArea2D } ;
33use godot:: prelude:: * ;
44
5- const DEFAULT_SPEED : f64 = 100.0 ;
5+ const DEFAULT_SPEED : f32 = 100.0 ;
66
77#[ derive( GodotClass ) ]
88#[ class( init, base=Area2D ) ]
@@ -11,13 +11,13 @@ pub struct Ball {
1111 direction : Vector2 ,
1212 stopped : bool ,
1313 #[ init( val = DEFAULT_SPEED ) ]
14- speed : f64 ,
14+ speed : f32 ,
1515 base : Base < Area2D > ,
1616}
1717
1818#[ godot_api]
1919impl IArea2D for Ball {
20- fn process ( & mut self , delta : f64 ) {
20+ fn process ( & mut self , delta : f32 ) {
2121 let screen_size = self . base ( ) . get_viewport_rect ( ) . size ;
2222 self . speed += delta;
2323
@@ -26,7 +26,7 @@ impl IArea2D for Ball {
2626 // even if it's sightly out of sync between them,
2727 // so each player sees the motion as smooth and not jerky.
2828 let direction = self . direction ;
29- let translation = direction * ( self . speed * delta) as f32 ;
29+ let translation = direction * self . speed * delta;
3030 self . base_mut ( ) . translate ( translation) ;
3131 }
3232
@@ -39,8 +39,7 @@ impl IArea2D for Ball {
3939 }
4040
4141 let mut parent = self . base ( ) . get_parent ( ) . unwrap ( ) . cast :: < Pong > ( ) ;
42- // Allows re-entrancy – required if a game stops and we need to reset our ball.
43- // this help fixes the double bind error
42+ // Use base_mut() to allow for reentrancy – required if a game stops, and we need to reset our ball.
4443 let mut guard = self . base_mut ( ) ;
4544 if guard. is_multiplayer_authority ( ) {
4645 // Only the master will decide when the ball is out on
0 commit comments