File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed
Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,14 @@ pub fn physics_handle(
66 on_ground : & mut bool ,
77 velocity_y : & Cell < f32 > ,
88 gravity : & Cell < f32 > ,
9+ jump_force : & Cell < f32 > ,
910 player_y : & mut f32
1011) {
1112 velocity_y. set ( velocity_y. get ( ) + gravity. get ( ) ) ;
1213
1314 if * on_ground && ( is_mouse_button_pressed ( MouseButton :: Left ) || is_key_pressed ( KeyCode :: Space ) || is_key_pressed ( KeyCode :: Up ) ) {
1415 gravity. set ( -gravity. get ( ) ) ;
16+ jump_force. set ( -jump_force. get ( ) ) ;
1517 * player_y = if gravity. get ( ) > 0.0 { * player_y + 1.0 } else { * player_y - 1.0 } ;
1618 velocity_y. set ( if gravity. get ( ) > 0.0 { 5.0 } else { -5.0 } ) ;
1719 * on_ground = false ;
Original file line number Diff line number Diff line change @@ -905,7 +905,8 @@ async fn main() {
905905 & mut on_ground,
906906 & velocity_y. 0 ,
907907 & gravity. 0 ,
908- & mut player. y
908+ & jump_force. 0 ,
909+ & mut player. y ,
909910 ) ;
910911 }
911912
You can’t perform that action at this time.
0 commit comments