We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fbdeb01 commit 50cc935Copy full SHA for 50cc935
1 file changed
project/scripts/player.gd
@@ -0,0 +1,26 @@
1
+
2
+extends RigidBody2D
3
4
+export var player_speed = 200
5
6
+var btn_right = Input.is_action_pressed("btn_right")
7
+var btn_left = Input.is_action_pressed("btn_left")
8
9
10
11
+func _ready():
12
+ # Initalization here
13
+ set_fixed_process(true)
14
15
+func _fixed_process(delta):
16
+ btn_right = Input.is_action_pressed("btn_right")
17
+ btn_left = Input.is_action_pressed("btn_left")
18
19
+ if btn_left:
20
+ set_linear_velocity(Vector2(-player_speed,get_linear_velocity().y))
21
+ elif btn_right:
22
+ set_linear_velocity(Vector2(player_speed,get_linear_velocity().y))
23
+ else:
24
+ set_linear_velocity(Vector2(0,get_linear_velocity().y))
25
26
0 commit comments