updated player script with basic movement logic updated project keybindings so WASD can be used along with arrowsmaster
parent
e561c8009b
commit
9178c777b9
@ -1,26 +1,57 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://images/test_char.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://images/test_char.png" type="Texture" id=2]
|
||||
|
||||
[node name="Player" type="KinematicBody2D" index="0"]
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
|
||||
input_pickable = false
|
||||
collision_layer = 1
|
||||
collision_mask = 14
|
||||
collision/safe_margin = 0.08
|
||||
_sections_unfolded = [ "Collision" ]
|
||||
script = ExtResource( 1 )
|
||||
Speed = 5
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="." index="0"]
|
||||
|
||||
editor/display_folded = true
|
||||
position = Vector2( 0.00320625, -0.00740051 )
|
||||
scale = Vector2( 0.403093, 0.403093 )
|
||||
build_mode = 0
|
||||
polygon = PoolVector2Array( -26.5097, -40.0408, -36.4849, -29.9804, -36.3144, 14.9503, -16.4493, 40.016, 18.5063, 40.016, 36.4956, 14.9503, 36.4956, -4.82946, 23.4512, -39.9556 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="CollisionPolygon2D" index="0"]
|
||||
|
||||
texture = ExtResource( 1 )
|
||||
texture = ExtResource( 2 )
|
||||
hframes = 3
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 73, 80 )
|
||||
_sections_unfolded = [ "Region" ]
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." index="1"]
|
||||
|
||||
anchor_mode = 1
|
||||
rotating = false
|
||||
current = true
|
||||
zoom = Vector2( 1, 1 )
|
||||
limit_left = -10000000
|
||||
limit_top = -10000000
|
||||
limit_right = 10000000
|
||||
limit_bottom = 10000000
|
||||
limit_smoothed = false
|
||||
drag_margin_h_enabled = true
|
||||
drag_margin_v_enabled = true
|
||||
smoothing_enabled = true
|
||||
smoothing_speed = 5.0
|
||||
offset_v = 0.0
|
||||
offset_h = 0.0
|
||||
drag_margin_left = 0.2
|
||||
drag_margin_top = 0.2
|
||||
drag_margin_right = 0.2
|
||||
drag_margin_bottom = 0.2
|
||||
editor_draw_screen = true
|
||||
editor_draw_limits = true
|
||||
editor_draw_drag_margin = true
|
||||
_sections_unfolded = [ "Editor", "Smoothing" ]
|
||||
|
||||
|
||||
|
@ -1,4 +1,27 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
export var Speed = 5
|
||||
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
var velocity = Vector2()
|
||||
|
||||
if Input.is_action_pressed('ui_left'):
|
||||
velocity.x -= Speed
|
||||
elif Input.is_action_pressed('ui_right'):
|
||||
velocity.x += Speed
|
||||
|
||||
if Input.is_action_pressed('ui_up'):
|
||||
velocity.y -= Speed
|
||||
elif Input.is_action_pressed('ui_down'):
|
||||
velocity.y += Speed
|
||||
|
||||
if Input.is_key_pressed(KEY_SHIFT):
|
||||
velocity *= 2
|
||||
|
||||
move_and_slide(velocity)
|
||||
|
||||
pass
|
||||
|
Loading…
Reference in new issue