Skip to content

Commit 50cc935

Browse files
committed
Commit for Tutorial 03
1 parent fbdeb01 commit 50cc935

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

project/scripts/player.gd

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)