Bounded Camera
This commit is contained in:
parent
43fd5da73a
commit
d87f1a7a68
8
meta/BoundedCamera.tscn
Normal file
8
meta/BoundedCamera.tscn
Normal file
|
@ -0,0 +1,8 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://script/player camera.gd" type="Script" id=1]
|
||||
|
||||
[node name="Node2D" type="Camera2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
|
@ -1,593 +1,10 @@
|
|||
[gd_scene load_steps=97 format=2]
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://art/DungeonTiles.png" type="Texture" id=1]
|
||||
[ext_resource path="res://meta/DungeonTilemap.tres" type="TileSet" id=1]
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=1]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=2]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=3]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=4]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=5]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=6]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=7]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=8]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=9]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=10]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=11]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=12]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=13]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=14]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=15]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=16]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=17]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=18]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=19]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=20]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=21]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=22]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=23]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=24]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=25]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=26]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=27]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=28]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=29]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=30]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=31]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=32]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=33]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=34]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=35]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=36]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=37]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=38]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=39]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=40]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=41]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=42]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=43]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=44]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=45]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=46]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=47]
|
||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=48]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=49]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=50]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=51]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=52]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=53]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=54]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=55]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=56]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=57]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=58]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=59]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=60]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=61]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=62]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=63]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=64]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=65]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=66]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=67]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=68]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=69]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=70]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=71]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=72]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=73]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=74]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=75]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=76]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=77]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=78]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=79]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=80]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=81]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=82]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=83]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=84]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=85]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=86]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=87]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=88]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=89]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=90]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=91]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=92]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=93]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id=94]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="TileSet" id=95]
|
||||
0/name = "DungeonTiles.png 0"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 0, 0, 192, 64 )
|
||||
0/tile_mode = 1
|
||||
0/autotile/bitmask_mode = 1
|
||||
0/autotile/bitmask_flags = [ Vector2( 0, 0 ), 144, Vector2( 0, 1 ), 146, Vector2( 0, 2 ), 18, Vector2( 0, 3 ), 16, Vector2( 1, 0 ), 176, Vector2( 1, 1 ), 178, Vector2( 1, 2 ), 50, Vector2( 1, 3 ), 48, Vector2( 2, 0 ), 184, Vector2( 2, 1 ), 186, Vector2( 2, 2 ), 58, Vector2( 2, 3 ), 56, Vector2( 3, 0 ), 152, Vector2( 3, 1 ), 154, Vector2( 3, 2 ), 26, Vector2( 3, 3 ), 24, Vector2( 4, 0 ), 187, Vector2( 4, 1 ), 434, Vector2( 4, 2 ), 182, Vector2( 4, 3 ), 250, Vector2( 5, 0 ), 440, Vector2( 5, 1 ), 510, Vector2( 5, 2 ), 447, Vector2( 5, 3 ), 62, Vector2( 6, 0 ), 248, Vector2( 6, 1 ), 507, Vector2( 6, 2 ), 255, Vector2( 6, 3 ), 59, Vector2( 7, 0 ), 190, Vector2( 7, 1 ), 218, Vector2( 7, 2 ), 155, Vector2( 7, 3 ), 442, Vector2( 8, 0 ), 432, Vector2( 8, 1 ), 438, Vector2( 8, 2 ), 446, Vector2( 8, 3 ), 54, Vector2( 9, 0 ), 506, Vector2( 9, 1 ), 254, Vector2( 9, 2 ), 511, Vector2( 9, 3 ), 63, Vector2( 10, 0 ), 504, Vector2( 10, 2 ), 443, Vector2( 10, 3 ), 191, Vector2( 11, 0 ), 216, Vector2( 11, 1 ), 251, Vector2( 11, 2 ), 219, Vector2( 11, 3 ), 27 ]
|
||||
0/autotile/icon_coordinate = Vector2( 0, 0 )
|
||||
0/autotile/tile_size = Vector2( 16, 16 )
|
||||
0/autotile/spacing = 0
|
||||
0/autotile/occluder_map = [ Vector2( 0, 0 ), SubResource( 1 ), Vector2( 0, 1 ), SubResource( 2 ), Vector2( 0, 2 ), SubResource( 3 ), Vector2( 0, 3 ), SubResource( 4 ), Vector2( 1, 0 ), SubResource( 5 ), Vector2( 1, 1 ), SubResource( 6 ), Vector2( 1, 2 ), SubResource( 7 ), Vector2( 1, 3 ), SubResource( 8 ), Vector2( 2, 0 ), SubResource( 9 ), Vector2( 2, 1 ), SubResource( 10 ), Vector2( 2, 2 ), SubResource( 11 ), Vector2( 2, 3 ), SubResource( 12 ), Vector2( 3, 0 ), SubResource( 13 ), Vector2( 3, 1 ), SubResource( 14 ), Vector2( 3, 2 ), SubResource( 15 ), Vector2( 3, 3 ), SubResource( 16 ), Vector2( 4, 0 ), SubResource( 17 ), Vector2( 4, 1 ), SubResource( 18 ), Vector2( 4, 2 ), SubResource( 19 ), Vector2( 4, 3 ), SubResource( 20 ), Vector2( 5, 0 ), SubResource( 21 ), Vector2( 5, 1 ), SubResource( 22 ), Vector2( 5, 2 ), SubResource( 23 ), Vector2( 5, 3 ), SubResource( 24 ), Vector2( 6, 0 ), SubResource( 25 ), Vector2( 6, 1 ), SubResource( 26 ), Vector2( 6, 2 ), SubResource( 27 ), Vector2( 6, 3 ), SubResource( 28 ), Vector2( 7, 0 ), SubResource( 29 ), Vector2( 7, 1 ), SubResource( 30 ), Vector2( 7, 2 ), SubResource( 31 ), Vector2( 7, 3 ), SubResource( 32 ), Vector2( 8, 0 ), SubResource( 33 ), Vector2( 8, 1 ), SubResource( 34 ), Vector2( 8, 2 ), SubResource( 35 ), Vector2( 8, 3 ), SubResource( 36 ), Vector2( 9, 0 ), SubResource( 37 ), Vector2( 9, 1 ), SubResource( 38 ), Vector2( 9, 2 ), SubResource( 39 ), Vector2( 9, 3 ), SubResource( 40 ), Vector2( 10, 0 ), SubResource( 41 ), Vector2( 10, 2 ), SubResource( 42 ), Vector2( 10, 3 ), SubResource( 43 ), Vector2( 11, 0 ), SubResource( 44 ), Vector2( 11, 1 ), SubResource( 45 ), Vector2( 11, 2 ), SubResource( 46 ), Vector2( 11, 3 ), SubResource( 47 ) ]
|
||||
0/autotile/navpoly_map = [ ]
|
||||
0/autotile/priority_map = [ ]
|
||||
0/autotile/z_index_map = [ ]
|
||||
0/occluder_offset = Vector2( 0, 0 )
|
||||
0/navigation_offset = Vector2( 0, 0 )
|
||||
0/shapes = [ {
|
||||
"autotile_coord": Vector2( 0, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 48 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 0, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 49 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 0, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 50 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 0, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 51 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 1, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 52 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 1, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 53 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 1, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 54 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 1, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 55 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 2, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 56 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 2, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 57 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 2, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 58 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 2, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 59 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 3, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 60 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 3, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 61 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 3, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 62 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 3, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 63 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 4, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 64 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 4, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 65 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 4, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 66 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 4, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 67 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 5, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 68 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 5, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 69 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 5, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 70 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 5, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 71 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 6, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 72 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 6, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 73 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 6, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 74 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 6, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 75 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 7, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 76 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 7, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 77 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 7, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 78 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 7, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 79 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 8, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 80 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 8, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 81 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 8, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 82 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 8, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 83 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 9, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 84 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 9, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 85 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 9, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 86 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 9, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 87 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 10, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 88 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 10, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 89 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 10, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 90 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 11, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 91 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 11, 1 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 92 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 11, 2 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 93 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
}, {
|
||||
"autotile_coord": Vector2( 11, 3 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": SubResource( 94 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
} ]
|
||||
0/z_index = 0
|
||||
|
||||
[node name="TileMap" type="TileMap"]
|
||||
tile_set = SubResource( 95 )
|
||||
[node name="TileMap" type="TileMap" groups=[
|
||||
"Tilemap",
|
||||
]]
|
||||
tile_set = ExtResource( 1 )
|
||||
cell_size = Vector2( 16, 16 )
|
||||
format = 1
|
||||
|
|
70
script/PlayerStateMachine.gd
Normal file
70
script/PlayerStateMachine.gd
Normal file
|
@ -0,0 +1,70 @@
|
|||
extends StateMachine
|
||||
|
||||
|
||||
func _ready():
|
||||
add_state("idle")
|
||||
add_state("run")
|
||||
add_state("jump")
|
||||
add_state("fall")
|
||||
add_state("wallslide")
|
||||
call_deferred("set_state", states.idle)
|
||||
|
||||
|
||||
func _input(event):
|
||||
if [states.idle, states.run, states.wallslide].has(state) or !parent.CoyoteTimer.is_stopped():
|
||||
if event.is_action_pressed("up"):
|
||||
parent.jump()
|
||||
if state == states.jump:
|
||||
if event.is_action_released("up") and parent.velocity.y < parent.min_jump_velocity:
|
||||
parent.velocity.y = parent.min_jump_velocity
|
||||
|
||||
|
||||
func state_logic(delta):
|
||||
parent.handle_move_input()
|
||||
parent.apply_gravity(delta)
|
||||
parent.apply_movement()
|
||||
|
||||
|
||||
func get_next_state(delta):
|
||||
match state:
|
||||
states.idle:
|
||||
if !parent.is_on_floor():
|
||||
if parent.velocity.y < 0:
|
||||
return states.jump
|
||||
elif parent.velocity.y > 0:
|
||||
return states.fall
|
||||
elif parent.velocity.x != 0:
|
||||
return states.run
|
||||
states.run:
|
||||
if !parent.is_on_floor():
|
||||
if parent.velocity.y < 0:
|
||||
return states.jump
|
||||
elif parent.velocity.y > 0:
|
||||
return states.fall
|
||||
elif parent.velocity.x == 0:
|
||||
return states.idle
|
||||
states.jump:
|
||||
if parent.is_on_floor():
|
||||
return states.idle
|
||||
elif parent.velocity.y > 0:
|
||||
return states.fall
|
||||
states.fall:
|
||||
if parent.velocity.y < 0:
|
||||
return states.jump
|
||||
elif parent.is_on_floor():
|
||||
return states.idle
|
||||
return null
|
||||
|
||||
|
||||
func enter_state(new_state, old_state):
|
||||
match new_state:
|
||||
states.idle:
|
||||
parent.Anim.play("Idle")
|
||||
states.run:
|
||||
parent.Anim.play("Running")
|
||||
states.jump:
|
||||
parent.Anim.play("Jumping")
|
||||
|
||||
|
||||
func exit_state(old_state, new_state):
|
||||
pass
|
43
script/StateMachine.gd
Normal file
43
script/StateMachine.gd
Normal file
|
@ -0,0 +1,43 @@
|
|||
extends Node
|
||||
|
||||
class_name StateMachine
|
||||
|
||||
var state = null setget set_state
|
||||
var prev_state = null
|
||||
|
||||
var states = {}
|
||||
|
||||
onready var parent = get_parent()
|
||||
|
||||
func _physics_process(delta):
|
||||
if state != null:
|
||||
state_logic(delta)
|
||||
var new = get_next_state(delta)
|
||||
if new != null:
|
||||
set_state(new)
|
||||
|
||||
func state_logic(delta):
|
||||
pass
|
||||
|
||||
func get_next_state(delta):
|
||||
return null
|
||||
|
||||
func enter_state(new_state, old_state):
|
||||
pass
|
||||
|
||||
func exit_state(old_state, new_state):
|
||||
pass
|
||||
|
||||
func set_state(new_state):
|
||||
prev_state = state
|
||||
state = new_state
|
||||
|
||||
if prev_state != null:
|
||||
exit_state(prev_state, new_state)
|
||||
if new_state != null:
|
||||
enter_state(new_state, prev_state)
|
||||
|
||||
func add_state(state_name):
|
||||
states[state_name] = states.size()
|
||||
|
||||
|
44
script/player camera.gd
Normal file
44
script/player camera.gd
Normal file
|
@ -0,0 +1,44 @@
|
|||
extends Camera2D
|
||||
|
||||
const LOOK_X_FACTOR = 0.2
|
||||
const SHIFT_TRANS = Tween.TRANS_SINE
|
||||
const SHIFT_EASE = Tween.EASE_OUT
|
||||
const SHIFT_DURATIOIN = .5
|
||||
|
||||
var facing = 0
|
||||
var prev_facing = facing
|
||||
|
||||
onready var prev_pos = get_camera_position()
|
||||
onready var tween: Tween = $Tween
|
||||
onready var parent = get_parent()
|
||||
|
||||
func _ready():
|
||||
set_limits()
|
||||
|
||||
|
||||
func set_limits():
|
||||
var tilemap: TileMap = get_tree().get_nodes_in_group("Tilemap")[0]
|
||||
var map_limits = tilemap.get_used_rect()
|
||||
var map_cellsize = tilemap.cell_size
|
||||
limit_left = (map_limits.position.x + 1) * map_cellsize.x
|
||||
limit_right = (map_limits.end.x - 1) * map_cellsize.x - 1
|
||||
limit_top = (map_limits.position.y + 1) * map_cellsize.y
|
||||
limit_bottom = (map_limits.end.y - 1) * map_cellsize.y
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if facing != 0:
|
||||
prev_facing = facing
|
||||
check_facing()
|
||||
|
||||
|
||||
func check_facing():
|
||||
if parent.input_direction != 0:
|
||||
facing = parent.input_direction
|
||||
var target = get_viewport_rect().size.x * parent.input_direction * LOOK_X_FACTOR
|
||||
tween.interpolate_property(self, "position:x", position.x, target, SHIFT_DURATIOIN, SHIFT_TRANS, SHIFT_EASE)
|
||||
tween.start()
|
||||
|
||||
|
||||
func _on_grounded_updated(is_grounded):
|
||||
drag_margin_v_enabled = !is_grounded
|
|
@ -1,31 +1,82 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
const UP = Vector2(0, -1)
|
||||
const GRAVITY = 32
|
||||
const SPEED = 200
|
||||
const JUMP_HEIGHT = -550
|
||||
var motion = Vector2()
|
||||
signal grounded_updated(is_grounded)
|
||||
|
||||
var velocity = Vector2()
|
||||
var input_direction: int = 0
|
||||
var speed = 10 * 16
|
||||
var gravity
|
||||
var max_jump_velocity
|
||||
var min_jump_velocity
|
||||
var walljump_velocity
|
||||
var max_jump_height = 2.75 * 16
|
||||
var min_jump_height = 0.6 * 16
|
||||
var walljump_height = 2.25 * 16
|
||||
var jump_duration = 0.35
|
||||
var is_grounded
|
||||
var touching_wall = 0
|
||||
|
||||
onready var Spr: Sprite = $Sprite
|
||||
onready var Occluder: LightOccluder2D = $Sprite/LightOccluder2D
|
||||
onready var Anim: AnimationPlayer = $AnimationPlayer
|
||||
onready var CoyoteTimer: Timer = $CoyoteTimer
|
||||
onready var StateMachine: Node = $PlayerStateMachine
|
||||
|
||||
|
||||
func _ready():
|
||||
gravity = 2 * max_jump_height / pow(jump_duration, 2)
|
||||
max_jump_velocity = -sqrt(2 * gravity * max_jump_height)
|
||||
min_jump_velocity = -sqrt(2 * gravity * min_jump_height)
|
||||
walljump_velocity = -sqrt(2 * gravity * walljump_height)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
motion.y += GRAVITY
|
||||
|
||||
if Input.is_action_pressed("ui_right"):
|
||||
motion.x = SPEED
|
||||
elif Input.is_action_pressed("ui_left"):
|
||||
motion.x = -SPEED
|
||||
else:
|
||||
motion.x = 0
|
||||
|
||||
emit_signal("grounded_updated", is_on_floor())
|
||||
|
||||
|
||||
func handle_move_input():
|
||||
input_direction = int(Input.is_action_pressed("right")) - int(Input.is_action_pressed("left"))
|
||||
velocity.x = lerp(velocity.x, speed * input_direction, get_movement_weight())
|
||||
|
||||
if input_direction > 0:
|
||||
Spr.flip_h = false
|
||||
Occluder.scale.x = 1
|
||||
|
||||
if input_direction < 0:
|
||||
Spr.flip_h = true
|
||||
Occluder.scale.x = -1
|
||||
|
||||
|
||||
func jump():
|
||||
velocity.y = max_jump_velocity
|
||||
CoyoteTimer.stop()
|
||||
|
||||
|
||||
func apply_gravity(delta, modifier = 1):
|
||||
velocity.y += gravity * delta * modifier
|
||||
|
||||
|
||||
func apply_movement():
|
||||
if velocity.x > -1 and velocity.x < 1:
|
||||
velocity.x = 0
|
||||
var was_on_floor = is_on_floor()
|
||||
velocity = move_and_slide(velocity, Vector2.UP)
|
||||
if !is_on_floor() and was_on_floor and velocity.y >= 0:
|
||||
CoyoteTimer.start()
|
||||
var was_grounded = is_grounded
|
||||
is_grounded = is_on_floor()
|
||||
if was_grounded == null or is_grounded != was_grounded:
|
||||
emit_signal("grounded_updated", is_grounded)
|
||||
|
||||
|
||||
func get_movement_weight():
|
||||
if is_on_floor():
|
||||
if Input.is_action_just_pressed("ui_up"):
|
||||
motion.y = JUMP_HEIGHT
|
||||
|
||||
motion = move_and_slide(motion, UP)
|
||||
|
||||
if position.y >= 493:
|
||||
get_tree().change_scene("Death Screen.tscn")
|
||||
pass
|
||||
return 0.2
|
||||
else:
|
||||
return 0.07
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
body.get_tree().change_scene("Logan is awful.tscn")
|
||||
|
|
Loading…
Reference in a new issue