diff --git a/2d_laser/Soldier.gd b/2d_laser/Soldier.gd new file mode 100644 index 0000000..705ad6f --- /dev/null +++ b/2d_laser/Soldier.gd @@ -0,0 +1,51 @@ +extends KinematicBody2D + +var speed = 250 +var velocity = Vector2() +var can_shoot = true +export var beam_duration = 1.5 +export var cooldown = 0.5 +var hit = null + +func _ready(): + $Line2D.remove_point(1) + +func get_input(): + velocity = Vector2() + if Input.is_action_pressed("forward"): + velocity += transform.x * speed + if Input.is_action_pressed("backward"): + velocity += -transform.x * speed + if Input.is_action_pressed("strafe_right"): + velocity += transform.y * speed/2 + if Input.is_action_pressed("strafe_left"): + velocity += -transform.y * speed/2 + if Input.is_action_just_pressed("click") and can_shoot: + shoot() + +func shoot(): + can_shoot = false + hit = cast_beam() + yield(get_tree().create_timer(beam_duration), "timeout") + $Line2D.remove_point(1) + hit = null + yield(get_tree().create_timer(cooldown), "timeout") + can_shoot = true + +func cast_beam(): + var space_state = get_world_2d().direct_space_state + var result = space_state.intersect_ray($Muzzle.global_position, $Muzzle.global_position + transform.x * 1000, [self]) + if result: + if !hit: + $Line2D.add_point(transform.xform_inv(result.position)) + else: + $Line2D.set_point_position(1, transform.xform_inv(result.position)) + return result + +func _physics_process(delta): + look_at(get_global_mouse_position()) + get_input() + if position.distance_to(get_global_mouse_position()) > 25: + velocity = move_and_slide(velocity) + if hit: + hit = cast_beam() diff --git a/2d_laser/Soldier.tscn b/2d_laser/Soldier.tscn new file mode 100644 index 0000000..be9b602 --- /dev/null +++ b/2d_laser/Soldier.tscn @@ -0,0 +1,36 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://Soldier.gd" type="Script" id=1] +[ext_resource path="res://assets/spritesheet_characters.png" type="Texture" id=2] +[ext_resource path="res://beam_pulse1.shader" type="Shader" id=3] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 17.3386, 26.1331 ) + +[sub_resource type="ShaderMaterial" id=2] +shader = ExtResource( 3 ) + +[node name="Soldier" type="KinematicBody2D"] +script = ExtResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 2 ) +region_enabled = true +region_rect = Rect2( 113, 0, 51, 43 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.5708 +shape = SubResource( 1 ) + +[node name="Muzzle" type="Position2D" parent="."] +position = Vector2( 25, 9 ) + +[node name="Camera2D" type="Camera2D" parent="."] +current = true + +[node name="Line2D" type="Line2D" parent="."] +material = SubResource( 2 ) +points = PoolVector2Array( 25, 9, 231.473, 9.27283 ) +default_color = Color( 2, 0.17, 0, 1 ) +texture_mode = 101 +end_cap_mode = 2 diff --git a/2d_laser/TileMap.gd b/2d_laser/TileMap.gd new file mode 100644 index 0000000..44a9609 --- /dev/null +++ b/2d_laser/TileMap.gd @@ -0,0 +1,13 @@ +extends TileMap + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +# 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 diff --git a/2d_laser/TileMap.tscn b/2d_laser/TileMap.tscn new file mode 100644 index 0000000..4c6d68a --- /dev/null +++ b/2d_laser/TileMap.tscn @@ -0,0 +1,538 @@ +[gd_scene load_steps=52 format=2] + +[ext_resource path="res://assets/spritesheet_tiles.png" type="Texture" id=1] + +[sub_resource type="ConvexPolygonShape2D" id=1] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=2] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=3] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=4] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=5] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=6] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=7] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=8] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=9] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=10] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=11] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=12] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=13] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=14] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=15] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=16] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=17] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=18] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=19] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=20] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=21] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=22] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=23] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=24] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=25] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=26] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=27] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=28] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=29] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=30] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=31] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=32] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=33] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=34] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=35] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=36] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=37] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=38] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=39] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=40] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=41] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=42] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=43] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=44] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=45] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=46] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=47] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=48] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="ConvexPolygonShape2D" id=49] +points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 ) + +[sub_resource type="TileSet" id=50] +0/name = "spritesheet_tiles.png 0" +0/texture = ExtResource( 1 ) +0/tex_offset = Vector2( 0, 0 ) +0/modulate = Color( 1, 1, 1, 1 ) +0/region = Rect2( 0, 0, 64, 64 ) +0/tile_mode = 0 +0/occluder_offset = Vector2( 0, 0 ) +0/navigation_offset = Vector2( 0, 0 ) +0/shapes = [ ] +0/z_index = 0 +1/name = "spritesheet_tiles.png 1" +1/texture = ExtResource( 1 ) +1/tex_offset = Vector2( 0, 0 ) +1/modulate = Color( 1, 1, 1, 1 ) +1/region = Rect2( 0, 296, 656, 434 ) +1/tile_mode = 1 +1/autotile/bitmask_mode = 1 +1/autotile/bitmask_flags = [ Vector2( 0, 0 ), 176, Vector2( 0, 1 ), 50, Vector2( 0, 2 ), 255, Vector2( 0, 3 ), 507, Vector2( 0, 4 ), 442, Vector2( 0, 5 ), 190, Vector2( 1, 0 ), 152, Vector2( 1, 1 ), 26, Vector2( 1, 2 ), 447, Vector2( 1, 3 ), 510, Vector2( 1, 4 ), 250, Vector2( 1, 5 ), 187, Vector2( 2, 0 ), 56, Vector2( 2, 1 ), 146, Vector2( 2, 2 ), 191, Vector2( 2, 3 ), 251, Vector2( 2, 4 ), 434, Vector2( 2, 5 ), 182, Vector2( 3, 0 ), 184, Vector2( 3, 1 ), 178, Vector2( 3, 2 ), 506, Vector2( 3, 3 ), 446, Vector2( 3, 4 ), 218, Vector2( 3, 5 ), 155, Vector2( 4, 0 ), 58, Vector2( 4, 1 ), 154, Vector2( 4, 2 ), 438, Vector2( 4, 3 ), 504, Vector2( 4, 4 ), 440, Vector2( 4, 5 ), 62, Vector2( 5, 0 ), 24, Vector2( 5, 1 ), 144, Vector2( 5, 2 ), 219, Vector2( 5, 3 ), 63, Vector2( 5, 4 ), 248, Vector2( 5, 5 ), 59, Vector2( 6, 0 ), 18, Vector2( 6, 1 ), 48, Vector2( 6, 2 ), 511, Vector2( 6, 3 ), 16, Vector2( 6, 4 ), 443, Vector2( 6, 5 ), 254, Vector2( 7, 0 ), 432, Vector2( 7, 1 ), 54, Vector2( 7, 2 ), 186, Vector2( 8, 0 ), 216, Vector2( 8, 1 ), 27 ] +1/autotile/icon_coordinate = Vector2( 6, 3 ) +1/autotile/tile_size = Vector2( 64, 64 ) +1/autotile/spacing = 10 +1/autotile/occluder_map = [ ] +1/autotile/navpoly_map = [ ] +1/autotile/priority_map = [ ] +1/autotile/z_index_map = [ ] +1/occluder_offset = Vector2( 0, 0 ) +1/navigation_offset = Vector2( 0, 0 ) +1/shapes = [ { +"autotile_coord": Vector2( 6, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 1 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 6, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 2 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 5, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 3 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 4, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"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( 5 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 2, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 6 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 7 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 8 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 9 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 10 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 2, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 11 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 3, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 12 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 4, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 13 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 5, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 14 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 6, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 15 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 7, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 16 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 7, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 17 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 8, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 18 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 8, 1 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 19 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 20 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 3 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 21 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 4 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 22 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 0, 5 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 23 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 24 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 3 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 25 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 4 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 26 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 5 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 27 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 2, 5 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 28 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 2, 4 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 29 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 2, 3 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 30 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 2, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 31 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 3, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 32 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 3, 3 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 33 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 3, 4 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 34 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 3, 5 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 35 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 4, 5 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 36 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 4, 4 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 37 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 4, 3 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 38 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 4, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 39 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 5, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 40 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 5, 3 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 41 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 5, 4 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 42 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 5, 5 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 43 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 6, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 44 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 6, 3 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 45 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 6, 4 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 46 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 6, 5 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 47 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 7, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 48 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 8, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 49 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +} ] +1/z_index = 0 +2/name = "spritesheet_tiles.png 2" +2/texture = ExtResource( 1 ) +2/tex_offset = Vector2( 0, 0 ) +2/modulate = Color( 1, 1, 1, 1 ) +2/region = Rect2( 666, 296, 656, 434 ) +2/tile_mode = 1 +2/autotile/bitmask_mode = 1 +2/autotile/bitmask_flags = [ Vector2( 0, 0 ), 176, Vector2( 0, 1 ), 50, Vector2( 0, 2 ), 255, Vector2( 0, 3 ), 507, Vector2( 0, 4 ), 442, Vector2( 0, 5 ), 190, Vector2( 1, 0 ), 152, Vector2( 1, 1 ), 26, Vector2( 1, 2 ), 447, Vector2( 1, 3 ), 510, Vector2( 1, 4 ), 250, Vector2( 1, 5 ), 187, Vector2( 2, 0 ), 56, Vector2( 2, 1 ), 146, Vector2( 2, 2 ), 191, Vector2( 2, 3 ), 251, Vector2( 2, 4 ), 434, Vector2( 2, 5 ), 182, Vector2( 3, 0 ), 184, Vector2( 3, 1 ), 178, Vector2( 3, 2 ), 506, Vector2( 3, 3 ), 446, Vector2( 3, 4 ), 218, Vector2( 3, 5 ), 155, Vector2( 4, 0 ), 58, Vector2( 4, 1 ), 154, Vector2( 4, 2 ), 438, Vector2( 4, 3 ), 504, Vector2( 4, 4 ), 440, Vector2( 4, 5 ), 62, Vector2( 5, 0 ), 24, Vector2( 5, 1 ), 144, Vector2( 5, 2 ), 219, Vector2( 5, 3 ), 63, Vector2( 5, 4 ), 248, Vector2( 5, 5 ), 59, Vector2( 6, 0 ), 18, Vector2( 6, 1 ), 48, Vector2( 6, 2 ), 511, Vector2( 6, 3 ), 16, Vector2( 6, 4 ), 443, Vector2( 6, 5 ), 254, Vector2( 7, 0 ), 432, Vector2( 7, 1 ), 54, Vector2( 7, 2 ), 186, Vector2( 8, 0 ), 216, Vector2( 8, 1 ), 27 ] +2/autotile/icon_coordinate = Vector2( 6, 3 ) +2/autotile/tile_size = Vector2( 64, 64 ) +2/autotile/spacing = 10 +2/autotile/occluder_map = [ ] +2/autotile/navpoly_map = [ ] +2/autotile/priority_map = [ ] +2/autotile/z_index_map = [ ] +2/occluder_offset = Vector2( 0, 0 ) +2/navigation_offset = Vector2( 0, 0 ) +2/shapes = [ ] +2/z_index = 0 +3/name = "spritesheet_tiles.png 3" +3/texture = ExtResource( 1 ) +3/tex_offset = Vector2( 0, 0 ) +3/modulate = Color( 1, 1, 1, 1 ) +3/region = Rect2( 0, 740, 656, 434 ) +3/tile_mode = 1 +3/autotile/bitmask_mode = 1 +3/autotile/bitmask_flags = [ Vector2( 0, 0 ), 176, Vector2( 0, 1 ), 50, Vector2( 0, 2 ), 255, Vector2( 0, 3 ), 507, Vector2( 0, 4 ), 442, Vector2( 0, 5 ), 190, Vector2( 1, 0 ), 152, Vector2( 1, 1 ), 26, Vector2( 1, 2 ), 447, Vector2( 1, 3 ), 510, Vector2( 1, 4 ), 250, Vector2( 1, 5 ), 187, Vector2( 2, 0 ), 56, Vector2( 2, 1 ), 146, Vector2( 2, 2 ), 191, Vector2( 2, 3 ), 251, Vector2( 2, 4 ), 434, Vector2( 2, 5 ), 182, Vector2( 3, 0 ), 184, Vector2( 3, 1 ), 178, Vector2( 3, 2 ), 506, Vector2( 3, 3 ), 446, Vector2( 3, 4 ), 218, Vector2( 3, 5 ), 155, Vector2( 4, 0 ), 58, Vector2( 4, 1 ), 154, Vector2( 4, 2 ), 438, Vector2( 4, 3 ), 504, Vector2( 4, 4 ), 440, Vector2( 4, 5 ), 62, Vector2( 5, 0 ), 24, Vector2( 5, 1 ), 144, Vector2( 5, 2 ), 219, Vector2( 5, 3 ), 63, Vector2( 5, 4 ), 248, Vector2( 5, 5 ), 59, Vector2( 6, 0 ), 18, Vector2( 6, 1 ), 48, Vector2( 6, 2 ), 511, Vector2( 6, 3 ), 16, Vector2( 6, 4 ), 443, Vector2( 6, 5 ), 254, Vector2( 7, 0 ), 432, Vector2( 7, 1 ), 54, Vector2( 7, 2 ), 186, Vector2( 8, 0 ), 216, Vector2( 8, 1 ), 27 ] +3/autotile/icon_coordinate = Vector2( 6, 3 ) +3/autotile/tile_size = Vector2( 64, 64 ) +3/autotile/spacing = 10 +3/autotile/occluder_map = [ ] +3/autotile/navpoly_map = [ ] +3/autotile/priority_map = [ ] +3/autotile/z_index_map = [ ] +3/occluder_offset = Vector2( 0, 0 ) +3/navigation_offset = Vector2( 0, 0 ) +3/shapes = [ ] +3/z_index = 0 +4/name = "spritesheet_tiles.png 4" +4/texture = ExtResource( 1 ) +4/tex_offset = Vector2( 0, 0 ) +4/modulate = Color( 1, 1, 1, 1 ) +4/region = Rect2( 296, 0, 64, 64 ) +4/tile_mode = 0 +4/occluder_offset = Vector2( 0, 0 ) +4/navigation_offset = Vector2( 0, 0 ) +4/shapes = [ ] +4/z_index = 0 +5/name = "spritesheet_tiles.png 5" +5/texture = ExtResource( 1 ) +5/tex_offset = Vector2( 0, 0 ) +5/modulate = Color( 1, 1, 1, 1 ) +5/region = Rect2( 370, 0, 64, 64 ) +5/tile_mode = 0 +5/occluder_offset = Vector2( 0, 0 ) +5/navigation_offset = Vector2( 0, 0 ) +5/shapes = [ ] +5/z_index = 0 + +[node name="TileMap" type="TileMap"] +tile_set = SubResource( 50 ) +format = 1 +tile_data = PoolIntArray( 0, 1, 0, 1, 1, 2, 2, 1, 2, 3, 1, 2, 4, 1, 2, 5, 1, 2, 6, 1, 2, 7, 1, 2, 8, 1, 3, 9, 1, 2, 10, 1, 2, 11, 1, 2, 12, 1, 2, 13, 1, 2, 14, 1, 2, 15, 1, 3, 16, 1, 2, 17, 1, 2, 18, 1, 2, 19, 1, 2, 20, 1, 2, 21, 1, 1, 65536, 1, 65538, 65537, 4, 0, 65538, 4, 0, 65539, 4, 0, 65540, 4, 0, 65541, 4, 0, 65542, 4, 0, 65543, 4, 0, 65544, 1, 65538, 65545, 4, 0, 65546, 4, 0, 65547, 4, 0, 65548, 4, 0, 65549, 4, 0, 65550, 4, 0, 65551, 1, 65538, 65552, 4, 0, 65553, 4, 0, 65554, 4, 0, 65555, 4, 0, 65556, 4, 0, 65557, 1, 65538, 131072, 1, 65538, 131073, 4, 0, 131074, 4, 0, 131075, 4, 0, 131076, 4, 0, 131077, 4, 0, 131078, 4, 0, 131079, 4, 0, 131080, 1, 6, 131081, 4, 0, 131082, 4, 0, 131083, 4, 0, 131084, 4, 0, 131085, 4, 0, 131086, 4, 0, 131087, 1, 65538, 131088, 4, 0, 131089, 4, 0, 131090, 4, 0, 131091, 4, 0, 131092, 4, 0, 131093, 1, 65538, 196608, 1, 65538, 196609, 4, 0, 196610, 4, 0, 196611, 4, 0, 196612, 4, 0, 196613, 4, 0, 196614, 4, 0, 196615, 4, 0, 196616, 4, 0, 196617, 4, 0, 196618, 4, 0, 196619, 4, 0, 196620, 4, 0, 196621, 4, 0, 196622, 4, 0, 196623, 1, 65538, 196624, 4, 0, 196625, 4, 0, 196626, 4, 0, 196627, 4, 0, 196628, 4, 0, 196629, 1, 65538, 262144, 1, 65538, 262145, 4, 0, 262146, 1, 65542, 262147, 1, 3, 262148, 1, 2, 262149, 1, 2, 262150, 1, 5, 262151, 4, 0, 262152, 4, 0, 262153, 4, 0, 262154, 1, 65541, 262155, 4, 0, 262156, 4, 0, 262157, 4, 0, 262158, 4, 0, 262159, 1, 65536, 262160, 1, 2, 262161, 1, 5, 262162, 4, 0, 262163, 4, 0, 262164, 4, 0, 262165, 1, 65538, 327680, 1, 65538, 327681, 4, 0, 327682, 4, 0, 327683, 1, 65538, 327684, 4, 0, 327685, 4, 0, 327686, 4, 0, 327687, 4, 0, 327688, 4, 0, 327689, 4, 0, 327690, 1, 65538, 327691, 4, 0, 327692, 4, 0, 327693, 4, 0, 327694, 4, 0, 327695, 4, 0, 327696, 4, 0, 327697, 4, 0, 327698, 4, 0, 327699, 4, 0, 327700, 4, 0, 327701, 1, 65538, 393216, 1, 65538, 393217, 4, 0, 393218, 4, 0, 393219, 1, 65538, 393220, 4, 0, 393221, 4, 0, 393222, 4, 0, 393223, 4, 0, 393224, 4, 0, 393225, 4, 0, 393226, 1, 65538, 393227, 4, 0, 393228, 4, 0, 393229, 4, 0, 393230, 4, 0, 393231, 1, 0, 393232, 1, 2, 393233, 1, 5, 393234, 4, 0, 393235, 4, 0, 393236, 4, 0, 393237, 1, 65538, 458752, 1, 65538, 458753, 4, 0, 458754, 4, 0, 458755, 1, 65538, 458756, 4, 0, 458757, 4, 0, 458758, 1, 65541, 458759, 4, 0, 458760, 1, 65542, 458761, 1, 2, 458762, 1, 4, 458763, 1, 2, 458764, 1, 5, 458765, 4, 0, 458766, 4, 0, 458767, 1, 65538, 458768, 4, 0, 458769, 4, 0, 458770, 4, 0, 458771, 4, 0, 458772, 4, 0, 458773, 1, 65538, 524288, 1, 65538, 524289, 4, 0, 524290, 4, 0, 524291, 1, 6, 524292, 4, 0, 524293, 4, 0, 524294, 1, 65538, 524295, 4, 0, 524296, 4, 0, 524297, 4, 0, 524298, 4, 0, 524299, 4, 0, 524300, 4, 0, 524301, 4, 0, 524302, 4, 0, 524303, 1, 65538, 524304, 4, 0, 524305, 4, 0, 524306, 4, 0, 524307, 4, 0, 524308, 4, 0, 524309, 1, 65538, 589824, 1, 65538, 589825, 4, 0, 589826, 4, 0, 589827, 4, 0, 589828, 4, 0, 589829, 4, 0, 589830, 1, 65538, 589831, 4, 0, 589832, 4, 0, 589833, 4, 0, 589834, 4, 0, 589835, 4, 0, 589836, 4, 0, 589837, 4, 0, 589838, 4, 0, 589839, 1, 65538, 589840, 4, 0, 589841, 4, 0, 589842, 4, 0, 589843, 4, 0, 589844, 4, 0, 589845, 1, 65538, 655360, 1, 65538, 655361, 4, 0, 655362, 4, 0, 655363, 4, 0, 655364, 4, 0, 655365, 4, 0, 655366, 1, 65538, 655367, 4, 0, 655368, 4, 0, 655369, 4, 0, 655370, 4, 0, 655371, 4, 0, 655372, 4, 0, 655373, 4, 0, 655374, 4, 0, 655375, 1, 65538, 655376, 4, 0, 655377, 4, 0, 655378, 4, 0, 655379, 4, 0, 655380, 4, 0, 655381, 1, 65538, 720896, 1, 65536, 720897, 1, 2, 720898, 1, 2, 720899, 1, 2, 720900, 1, 2, 720901, 1, 2, 720902, 1, 4, 720903, 1, 2, 720904, 1, 2, 720905, 1, 2, 720906, 1, 2, 720907, 1, 2, 720908, 1, 2, 720909, 1, 2, 720910, 1, 2, 720911, 1, 4, 720912, 1, 2, 720913, 1, 2, 720914, 1, 2, 720915, 1, 2, 720916, 1, 2, 720917, 1, 65537 ) diff --git a/2d_laser/World.gd b/2d_laser/World.gd new file mode 100644 index 0000000..6538f91 --- /dev/null +++ b/2d_laser/World.gd @@ -0,0 +1,10 @@ +extends Node2D + +func _ready(): + var map_size = $TileMap.get_used_rect() + var cell_size = $TileMap.cell_size + $Soldier/Camera2D.limit_left = map_size.position.x * cell_size.x + $Soldier/Camera2D.limit_top = map_size.position.y * cell_size.y + $Soldier/Camera2D.limit_right = map_size.end.x * cell_size.x + $Soldier/Camera2D.limit_bottom = map_size.end.y * cell_size.y + \ No newline at end of file diff --git a/2d_laser/World.tscn b/2d_laser/World.tscn new file mode 100644 index 0000000..2ff5025 --- /dev/null +++ b/2d_laser/World.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://World.gd" type="Script" id=1] +[ext_resource path="res://TileMap.tscn" type="PackedScene" id=2] +[ext_resource path="res://Soldier.tscn" type="PackedScene" id=3] + +[sub_resource type="Environment" id=1] +background_mode = 4 +glow_enabled = true +glow_blend_mode = 1 +glow_hdr_luminance_cap = 5.0 + +[node name="World" type="Node2D"] +script = ExtResource( 1 ) + +[node name="TileMap" parent="." instance=ExtResource( 2 )] +show_behind_parent = true + +[node name="Soldier" parent="." instance=ExtResource( 3 )] +position = Vector2( 149.939, 145.85 ) + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource( 1 ) diff --git a/2d_laser/assets/spritesheet_characters.png b/2d_laser/assets/spritesheet_characters.png new file mode 100755 index 0000000..60e05fd Binary files /dev/null and b/2d_laser/assets/spritesheet_characters.png differ diff --git a/2d_laser/assets/spritesheet_characters.png.import b/2d_laser/assets/spritesheet_characters.png.import new file mode 100644 index 0000000..77dc6a3 --- /dev/null +++ b/2d_laser/assets/spritesheet_characters.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/spritesheet_characters.png-3c0c465fcc2845a959d42c5252927ed4.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/spritesheet_characters.png" +dest_files=[ "res://.import/spritesheet_characters.png-3c0c465fcc2845a959d42c5252927ed4.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/2d_laser/assets/spritesheet_tiles.png b/2d_laser/assets/spritesheet_tiles.png new file mode 100755 index 0000000..066beb6 Binary files /dev/null and b/2d_laser/assets/spritesheet_tiles.png differ diff --git a/2d_laser/assets/spritesheet_tiles.png.import b/2d_laser/assets/spritesheet_tiles.png.import new file mode 100644 index 0000000..0bdd52b --- /dev/null +++ b/2d_laser/assets/spritesheet_tiles.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/spritesheet_tiles.png-db7496d4c934dabb135421f2e10462a9.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/spritesheet_tiles.png" +dest_files=[ "res://.import/spritesheet_tiles.png-db7496d4c934dabb135421f2e10462a9.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/2d_laser/beam_pulse1.shader b/2d_laser/beam_pulse1.shader new file mode 100644 index 0000000..3f9f85f --- /dev/null +++ b/2d_laser/beam_pulse1.shader @@ -0,0 +1,12 @@ +shader_type canvas_item; +//render_mode blend_premul_alpha; + +void fragment() { + //float glow = 16.6 * sin(TIME*10.0); + float glow = 0.01 / SCREEN_PIXEL_SIZE.x * sin(TIME * 10.0); + glow = clamp(glow, 2.0, 10.0); + float curve = 1.0 - abs(UV.y - 0.5) * 15.0; + float i = clamp(curve, 0.0, 1.0); + i += clamp((glow + curve) / glow, 0.1, 0.9); + COLOR = i * vec4(3.0, 0.3, 0.1, 1.0); +} \ No newline at end of file diff --git a/2d_laser/default_env.tres b/2d_laser/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/2d_laser/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/2d_laser/icon.png b/2d_laser/icon.png new file mode 100644 index 0000000..c8705db Binary files /dev/null and b/2d_laser/icon.png differ diff --git a/2d_laser/icon.png.import b/2d_laser/icon.png.import new file mode 100644 index 0000000..96cbf46 --- /dev/null +++ b/2d_laser/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/2d_laser/project.godot b/2d_laser/project.godot new file mode 100644 index 0000000..0af1930 --- /dev/null +++ b/2d_laser/project.godot @@ -0,0 +1,52 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="2d_laser" +run/main_scene="res://World.tscn" +config/icon="res://icon.png" + +[input] + +forward={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) + ] +} +backward={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null) + ] +} +strafe_right={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null) + ] +} +strafe_left={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) + ] +} +click={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) + ] +} + +[rendering] + +environment/default_environment="res://default_env.tres"