diff --git a/Playa.gd b/Playa.gd index 7e84473..4d64f05 100644 --- a/Playa.gd +++ b/Playa.gd @@ -1,16 +1,33 @@ extends KinematicBody2D +export var ACCELERATION = 50 +export var MAX_SPEED = 100 +export var FRICTION = 30 -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" +var velocity = Vector2.ZERO -# Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass +func _physics_process(delta): + var direction = Vector2.UP.rotated(rotation).normalized() #Playerrotation nehmen ist sicherer + var is_accellerating = Input.is_action_pressed("ui_up") + + if is_accellerating: + velocity = velocity.move_toward(direction * MAX_SPEED, ACCELERATION * delta) + else: + velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta) + + var steering_right = Input.is_action_pressed("ui_right") + + if steering_right: + var direction_new = direction.rotated(PI/128 * delta) + velocity = velocity.rotated(direction_new.angle()) + rotate(direction_new.angle()) + print(direction_new.angle_to(direction)) + + + #print(velocity) + move_and_collide(velocity * delta) diff --git a/Playa.tscn b/Playa.tscn index 21ba079..72de51b 100644 --- a/Playa.tscn +++ b/Playa.tscn @@ -4,8 +4,8 @@ [ext_resource path="res://Playa.gd" type="Script" id=2] [sub_resource type="CapsuleShape2D" id=1] -radius = 34.9782 -height = 106.041 +radius = 33.6545 +height = 72.4629 [node name="Playa" type="KinematicBody2D"] script = ExtResource( 2 ) @@ -14,11 +14,10 @@ __meta__ = { } [node name="Sprite" type="Sprite" parent="."] -position = Vector2( 20, 5 ) -rotation = -1.5708 +position = Vector2( 5.25562, -20.8122 ) +rotation = 3.14159 scale = Vector2( 2, 2 ) texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -rotation = 1.5708 shape = SubResource( 1 ) diff --git a/World.tscn b/World.tscn index aff4d5a..843ba1e 100644 --- a/World.tscn +++ b/World.tscn @@ -43,6 +43,9 @@ 1/shapes = [ ] 1/z_index = 0 +[sub_resource type="ConvexPolygonShape2D" id=2] +points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) + [sub_resource type="ConvexPolygonShape2D" id=3] points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) @@ -91,10 +94,7 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) [sub_resource type="ConvexPolygonShape2D" id=18] points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) -[sub_resource type="ConvexPolygonShape2D" id=19] -points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) - -[sub_resource type="TileSet" id=2] +[sub_resource type="TileSet" id=19] 0/name = "Buildings.png 0" 0/texture = ExtResource( 2 ) 0/tex_offset = Vector2( 0, 0 ) @@ -114,110 +114,110 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) 0/navigation_offset = Vector2( 0, 0 ) 0/shape_offset = Vector2( 0, 0 ) 0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) -0/shape = SubResource( 3 ) +0/shape = SubResource( 2 ) 0/shape_one_way = false 0/shape_one_way_margin = 1.0 0/shapes = [ { "autotile_coord": Vector2( 0, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 3 ), +"shape": SubResource( 2 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 1, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 4 ), +"shape": SubResource( 3 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 2, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 5 ), +"shape": SubResource( 4 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 3, 0 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 6 ), +"shape": SubResource( 5 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 0, 3 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 7 ), +"shape": SubResource( 6 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 1, 3 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 8 ), +"shape": SubResource( 7 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 2, 3 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 9 ), +"shape": SubResource( 8 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 3, 3 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 10 ), +"shape": SubResource( 9 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 4, 4 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 11 ), +"shape": SubResource( 10 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 5, 4 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 12 ), +"shape": SubResource( 11 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 6, 4 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 13 ), +"shape": SubResource( 12 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 4, 6 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 14 ), +"shape": SubResource( 13 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 5, 6 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 15 ), +"shape": SubResource( 14 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 6, 6 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 16 ), +"shape": SubResource( 15 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 4, 5 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 17 ), +"shape": SubResource( 16 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 6, 5 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 18 ), +"shape": SubResource( 17 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) }, { "autotile_coord": Vector2( 5, 5 ), "one_way": false, "one_way_margin": 1.0, -"shape": SubResource( 19 ), +"shape": SubResource( 18 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) } ] 0/z_index = 0 @@ -252,7 +252,7 @@ format = 1 tile_data = PoolIntArray( 131076, 1, 0, 131077, 1, 0, 131078, 1, 0, 131079, 1, 0, 131080, 1, 0, 131081, 1, 0, 131082, 1, 0, 131083, 1, 0, 131084, 1, 0, 131085, 1, 0, 131086, 1, 0, 131087, 1, 0, 131088, 1, 0, 131089, 1, 0, 131090, 1, 0, 131091, 1, 0, 131092, 1, 0, 131093, 1, 0, 131094, 1, 0, 131095, 1, 0, 131096, 1, 0, 196612, 1, 0, 196627, 1, 0, 196632, 1, 0, 262148, 1, 0, 262163, 1, 0, 262168, 1, 0, 327684, 1, 0, 327699, 1, 0, 327704, 1, 0, 393220, 1, 0, 393231, 1, 0, 393232, 1, 0, 393233, 1, 0, 393234, 1, 0, 393235, 1, 0, 393240, 1, 0, 458756, 1, 0, 458767, 1, 0, 458776, 1, 0, 524292, 1, 0, 524303, 1, 0, 524312, 1, 0, 589828, 1, 0, 589829, 1, 0, 589830, 1, 0, 589831, 1, 0, 589832, 1, 0, 589833, 1, 0, 589834, 1, 0, 589835, 1, 0, 589836, 1, 0, 589837, 1, 0, 589838, 1, 0, 589839, 1, 0, 589848, 1, 0, 655364, 1, 0, 655371, 1, 0, 655384, 1, 0, 720900, 1, 0, 720907, 1, 0, 720920, 1, 0, 786436, 1, 0, 786443, 1, 0, 786444, 1, 0, 786445, 1, 0, 786446, 1, 0, 786447, 1, 0, 786448, 1, 0, 786449, 1, 0, 786450, 1, 0, 786451, 1, 0, 786452, 1, 0, 786453, 1, 0, 786454, 1, 0, 786455, 1, 0, 786456, 1, 0, 851972, 1, 0, 851979, 1, 0, 851988, 1, 0, 851992, 1, 0, 917508, 1, 0, 917509, 1, 0, 917510, 1, 0, 917511, 1, 0, 917512, 1, 0, 917513, 1, 0, 917514, 1, 0, 917515, 1, 0, 917524, 1, 0, 917528, 1, 0, 983044, 1, 0, 983048, 1, 0, 983060, 1, 0, 983064, 1, 0, 1048580, 1, 0, 1048584, 1, 0, 1048585, 1, 0, 1048586, 1, 0, 1048587, 1, 0, 1048588, 1, 0, 1048589, 1, 0, 1048590, 1, 0, 1048591, 1, 0, 1048592, 1, 0, 1048593, 1, 0, 1048594, 1, 0, 1048595, 1, 0, 1048596, 1, 0, 1048597, 1, 0, 1048598, 1, 0, 1048599, 1, 0, 1048600, 1, 0, 1114116, 1, 0, 1114126, 1, 0, 1114136, 1, 0, 1179652, 1, 0, 1179662, 1, 0, 1179672, 1, 0, 1245188, 1, 0, 1245189, 1, 0, 1245190, 1, 0, 1245191, 1, 0, 1245192, 1, 0, 1245193, 1, 0, 1245194, 1, 0, 1245195, 1, 0, 1245196, 1, 0, 1245197, 1, 0, 1245198, 1, 0, 1245199, 1, 0, 1245200, 1, 0, 1245201, 1, 0, 1245202, 1, 0, 1245203, 1, 0, 1245204, 1, 0, 1245205, 1, 0, 1245206, 1, 0, 1245207, 1, 0, 1245208, 1, 0 ) [node name="Buildings" type="TileMap" parent="."] -tile_set = SubResource( 2 ) +tile_set = SubResource( 19 ) cell_size = Vector2( 16, 16 ) show_collision = true format = 1