diff options
Diffstat (limited to 'demos/2d/fog_of_war')
-rw-r--r-- | demos/2d/fog_of_war/engine.cfg | 12 | ||||
-rw-r--r-- | demos/2d/fog_of_war/floor.png | bin | 572 -> 0 bytes | |||
-rw-r--r-- | demos/2d/fog_of_war/fog.gd | 78 | ||||
-rw-r--r-- | demos/2d/fog_of_war/fog.png | bin | 31448 -> 0 bytes | |||
-rw-r--r-- | demos/2d/fog_of_war/fog.tscn | 51 | ||||
-rw-r--r-- | demos/2d/fog_of_war/icon.png | bin | 8681 -> 0 bytes | |||
-rw-r--r-- | demos/2d/fog_of_war/tileset.tres | 32 | ||||
-rw-r--r-- | demos/2d/fog_of_war/tileset_edit.tscn | 30 | ||||
-rw-r--r-- | demos/2d/fog_of_war/troll.gd | 38 | ||||
-rw-r--r-- | demos/2d/fog_of_war/troll.png | bin | 7246 -> 0 bytes | |||
-rw-r--r-- | demos/2d/fog_of_war/troll.tscn | 52 |
11 files changed, 0 insertions, 293 deletions
diff --git a/demos/2d/fog_of_war/engine.cfg b/demos/2d/fog_of_war/engine.cfg deleted file mode 100644 index 98e20c1e41..0000000000 --- a/demos/2d/fog_of_war/engine.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[application] - -name="Fog of War" -main_scene="res://fog.tscn" -icon="res://icon.png" - -[input] - -move_up=[key(Up)] -move_bottom=[key(Down)] -move_left=[key(Left)] -move_right=[key(Right)] diff --git a/demos/2d/fog_of_war/floor.png b/demos/2d/fog_of_war/floor.png Binary files differdeleted file mode 100644 index 07b4f8c98f..0000000000 --- a/demos/2d/fog_of_war/floor.png +++ /dev/null diff --git a/demos/2d/fog_of_war/fog.gd b/demos/2d/fog_of_war/fog.gd deleted file mode 100644 index 3ac8df0e17..0000000000 --- a/demos/2d/fog_of_war/fog.gd +++ /dev/null @@ -1,78 +0,0 @@ - -extends TileMap - -# Member variables - -# Boundaries for the fog rectangle -var x_min = -20 # Left start tile -var x_max = 20 # Right end tile -var y_min = -20 # Top start tile -var y_max = 20 # Bottom end tile - -var position # Player's position - -# Iteration variables -var x -var y - -# Variables to check if the player moved -var x_old -var y_old - -# Array to build up the visible area like a square. -# First value determines the width/height of the tip. -# Here it would be 2*2 + 1 = 5 tiles wide/high. -# Second value determines the total squares size. -# Here it would be 5*2 + 1 = 10 tiles wide/high. -var l = range(2, 5) - - -# Process that runs in realtime -func _fixed_process(delta): - position = get_node("../troll").get_pos() - - # Calculate the corresponding tile - # from the players position - x = int(position.x/get_cell_size().x) - # Switching from positive to negative tile positions - # causes problems because of rounding problems - if position.x < 0: - x -= 1 # Correct negative values - - y = int(position.y/get_cell_size().y) - if (position.y < 0): - y -= 1 - - # Check if the player moved one tile further - if ((x_old != x) or (y_old != y)): - # Create the transparent part (visited area) - var end = l.size() - 1 - var start = 0 - for steps in range(l.size()): - for m in range(x - l[end] - 1, x + l[end] + 2): - for n in range(y - l[start] - 1, y + l[start] + 2): - if (get_cell(m, n) != 0): - set_cell(m, n, 1, 0, 0) - end -= 1 - start += 1 - - # Create the actual and active visible part - var end = l.size() - 1 - var start = 0 - for steps in range(l.size()): - for m in range(x - l[end], x + l[end] + 1): - for n in range(y - l[start], y + l[start] + 1): - set_cell(m, n, -1) - end -= 1 - start += 1 - - x_old = x - y_old = y - - -func _ready(): - # Create a square filled with the 100% opaque fog - for x in range(x_min, x_max): - for y in range(y_min, y_max): - set_cell(x, y, 0, 0, 0) - set_fixed_process(true) diff --git a/demos/2d/fog_of_war/fog.png b/demos/2d/fog_of_war/fog.png Binary files differdeleted file mode 100644 index 56980c298d..0000000000 --- a/demos/2d/fog_of_war/fog.png +++ /dev/null diff --git a/demos/2d/fog_of_war/fog.tscn b/demos/2d/fog_of_war/fog.tscn deleted file mode 100644 index e86a23125c..0000000000 --- a/demos/2d/fog_of_war/fog.tscn +++ /dev/null @@ -1,51 +0,0 @@ -[gd_scene load_steps=4 format=1] - -[ext_resource path="res://tileset.tres" type="TileSet" id=1] -[ext_resource path="res://troll.tscn" type="PackedScene" id=2] -[ext_resource path="res://fog.gd" type="Script" id=3] - -[node name="Node2D" type="Node2D"] - -[node name="TileMap" type="TileMap" parent="."] - -transform/pos = Vector2( 206, 112 ) -mode = 0 -tile_set = ExtResource( 1 ) -cell/size = Vector2( 48, 48 ) -cell/quadrant_size = 16 -cell/custom_transform = Matrix32( 1, 0, 0, 1, 0, 0 ) -cell/half_offset = 2 -cell/tile_origin = 0 -cell/y_sort = false -collision/use_kinematic = false -collision/friction = 1.0 -collision/bounce = 0.0 -collision/layers = 1 -collision/mask = 1 -occluder/light_mask = 1 -tile_data = IntArray( -589834, 2, -589833, 2, -589832, 2, -589831, 2, -589830, 2, -589829, 2, -589828, 2, -589827, 2, -589826, 2, -589825, 2, -655360, 2, -655359, 2, -655358, 2, -655357, 2, -655356, 2, -655355, 2, -655354, 2, -655353, 2, -655352, 2, -655351, 2, -524298, 2, -524297, 2, -524296, 2, -524295, 2, -524294, 2, -524293, 2, -524292, 2, -524291, 2, -524290, 2, -524289, 2, -589824, 2, -589823, 2, -589822, 2, -589821, 2, -589820, 2, -589819, 2, -589818, 2, -589817, 2, -589816, 2, -589815, 2, -458762, 2, -458761, 2, -458760, 2, -458759, 2, -458758, 2, -458757, 2, -458756, 2, -458755, 2, -458754, 2, -458753, 2, -524288, 2, -524287, 2, -524286, 2, -524285, 2, -524284, 2, -524283, 2, -524282, 2, -524281, 2, -524280, 2, -524279, 2, -393226, 2, -393225, 2, -393224, 2, -393223, 2, -393222, 2, -393221, 2, -393220, 2, -393219, 2, -393218, 2, -393217, 2, -458752, 2, -458751, 2, -458750, 2, -458749, 2, -458748, 2, -458747, 2, -458746, 2, -458745, 2, -458744, 2, -458743, 2, -327690, 2, -327689, 2, -327688, 2, -327687, 2, -327686, 2, -327685, 2, -327684, 2, -327683, 2, -327682, 2, -327681, 2, -393216, 2, -393215, 2, -393214, 2, -393213, 2, -393212, 2, -393211, 2, -393210, 2, -393209, 2, -393208, 2, -393207, 2, -262154, 2, -262153, 2, -262152, 2, -262151, 2, -262150, 2, -262149, 2, -262148, 2, -262147, 2, -262146, 2, -262145, 2, -327680, 2, -327679, 2, -327678, 2, -327677, 2, -327676, 2, -327675, 2, -327674, 2, -327673, 2, -327672, 2, -327671, 2, -196618, 2, -196617, 2, -196616, 2, -196615, 2, -196614, 2, -196613, 2, -196612, 2, -196611, 2, -196610, 2, -196609, 2, -262144, 2, -262143, 2, -262142, 2, -262141, 2, -262140, 2, -262139, 2, -262138, 2, -262137, 2, -262136, 2, -262135, 2, -131082, 2, -131081, 2, -131080, 2, -131079, 2, -131078, 2, -131077, 2, -131076, 2, -131075, 2, -131074, 2, -131073, 2, -196608, 2, -196607, 2, -196606, 2, -196605, 2, -196604, 2, -196603, 2, -196602, 2, -196601, 2, -196600, 2, -196599, 2, -65546, 2, -65545, 2, -65544, 2, -65543, 2, -65542, 2, -65541, 2, -65540, 2, -65539, 2, -65538, 2, -65537, 2, -131072, 2, -131071, 2, -131070, 2, -131069, 2, -131068, 2, -131067, 2, -131066, 2, -131065, 2, -131064, 2, -131063, 2, -10, 2, -9, 2, -8, 2, -7, 2, -6, 2, -5, 2, -4, 2, -3, 2, -2, 2, -1, 2, -65536, 2, -65535, 2, -65534, 2, -65533, 2, -65532, 2, -65531, 2, -65530, 2, -65529, 2, -65528, 2, -65527, 2, 65526, 2, 65527, 2, 65528, 2, 65529, 2, 65530, 2, 65531, 2, 65532, 2, 65533, 2, 65534, 2, 65535, 2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 131062, 2, 131063, 2, 131064, 2, 131065, 2, 131066, 2, 131067, 2, 131068, 2, 131069, 2, 131070, 2, 131071, 2, 65536, 2, 65537, 2, 65538, 2, 65539, 2, 65540, 2, 65541, 2, 65542, 2, 65543, 2, 65544, 2, 65545, 2, 196598, 2, 196599, 2, 196600, 2, 196601, 2, 196602, 2, 196603, 2, 196604, 2, 196605, 2, 196606, 2, 196607, 2, 131072, 2, 131073, 2, 131074, 2, 131075, 2, 131076, 2, 131077, 2, 131078, 2, 131079, 2, 131080, 2, 131081, 2, 262134, 2, 262135, 2, 262136, 2, 262137, 2, 262138, 2, 262139, 2, 262140, 2, 262141, 2, 262142, 2, 262143, 2, 196608, 2, 196609, 2, 196610, 2, 196611, 2, 196612, 2, 196613, 2, 196614, 2, 196615, 2, 196616, 2, 196617, 2, 327670, 2, 327671, 2, 327672, 2, 327673, 2, 327674, 2, 327675, 2, 327676, 2, 327677, 2, 327678, 2, 327679, 2, 262144, 2, 262145, 2, 262146, 2, 262147, 2, 262148, 2, 262149, 2, 262150, 2, 262151, 2, 262152, 2, 262153, 2, 393206, 2, 393207, 2, 393208, 2, 393209, 2, 393210, 2, 393211, 2, 393212, 2, 393213, 2, 393214, 2, 393215, 2, 327680, 2, 327681, 2, 327682, 2, 327683, 2, 327684, 2, 327685, 2, 327686, 2, 327687, 2, 327688, 2, 327689, 2, 458742, 2, 458743, 2, 458744, 2, 458745, 2, 458746, 2, 458747, 2, 458748, 2, 458749, 2, 458750, 2, 458751, 2, 393216, 2, 393217, 2, 393218, 2, 393219, 2, 393220, 2, 393221, 2, 393222, 2, 393223, 2, 393224, 2, 393225, 2, 524278, 2, 524279, 2, 524280, 2, 524281, 2, 524282, 2, 524283, 2, 524284, 2, 524285, 2, 524286, 2, 524287, 2, 458752, 2, 458753, 2, 458754, 2, 458755, 2, 458756, 2, 458757, 2, 458758, 2, 458759, 2, 458760, 2, 458761, 2, 589814, 2, 589815, 2, 589816, 2, 589817, 2, 589818, 2, 589819, 2, 589820, 2, 589821, 2, 589822, 2, 589823, 2, 524288, 2, 524289, 2, 524290, 2, 524291, 2, 524292, 2, 524293, 2, 524294, 2, 524295, 2, 524296, 2, 524297, 2, 655350, 2, 655351, 2, 655352, 2, 655353, 2, 655354, 2, 655355, 2, 655356, 2, 655357, 2, 655358, 2, 655359, 2, 589824, 2, 589825, 2, 589826, 2, 589827, 2, 589828, 2, 589829, 2, 589830, 2, 589831, 2, 589832, 2, 589833, 2 ) - -[node name="troll" parent="." instance=ExtResource( 2 )] - -collision/margin = 0.001 - -[node name="Fog" type="TileMap" parent="."] - -mode = 0 -tile_set = ExtResource( 1 ) -cell/size = Vector2( 48, 48 ) -cell/quadrant_size = 16 -cell/custom_transform = Matrix32( 1, 0, 0, 1, 0, 0 ) -cell/half_offset = 2 -cell/tile_origin = 0 -cell/y_sort = false -collision/use_kinematic = false -collision/friction = 1.0 -collision/bounce = 0.0 -collision/layers = 1 -collision/mask = 1 -occluder/light_mask = 1 -tile_data = IntArray( ) -script/script = ExtResource( 3 ) - - diff --git a/demos/2d/fog_of_war/icon.png b/demos/2d/fog_of_war/icon.png Binary files differdeleted file mode 100644 index a483390048..0000000000 --- a/demos/2d/fog_of_war/icon.png +++ /dev/null diff --git a/demos/2d/fog_of_war/tileset.tres b/demos/2d/fog_of_war/tileset.tres deleted file mode 100644 index c75ba8d5f2..0000000000 --- a/demos/2d/fog_of_war/tileset.tres +++ /dev/null @@ -1,32 +0,0 @@ -[gd_resource type="TileSet" load_steps=3 format=1] - -[ext_resource path="res://fog.png" type="Texture" id=1] -[ext_resource path="res://floor.png" type="Texture" id=2] - -[resource] - -0/name = "fog opaque" -0/texture = ExtResource( 1 ) -0/tex_offset = Vector2( -48, -48 ) -0/region = Rect2( 0, 0, 144, 144 ) -0/occluder_offset = Vector2( 0, 0 ) -0/navigation_offset = Vector2( 0, 0 ) -0/shape_offset = Vector2( 0, 0 ) -0/shapes = [ ] -1/name = "fog transparent" -1/texture = ExtResource( 1 ) -1/tex_offset = Vector2( -48, -48 ) -1/region = Rect2( 144, 0, 144, 144 ) -1/occluder_offset = Vector2( 0, 0 ) -1/navigation_offset = Vector2( 0, 0 ) -1/shape_offset = Vector2( 0, 0 ) -1/shapes = [ ] -2/name = "floor" -2/texture = ExtResource( 2 ) -2/tex_offset = Vector2( 0, 0 ) -2/region = Rect2( 0, 0, 0, 0 ) -2/occluder_offset = Vector2( 24, 24 ) -2/navigation_offset = Vector2( 24, 24 ) -2/shape_offset = Vector2( 0, 0 ) -2/shapes = [ ] - diff --git a/demos/2d/fog_of_war/tileset_edit.tscn b/demos/2d/fog_of_war/tileset_edit.tscn deleted file mode 100644 index 1573e9d05e..0000000000 --- a/demos/2d/fog_of_war/tileset_edit.tscn +++ /dev/null @@ -1,30 +0,0 @@ -[gd_scene load_steps=3 format=1] - -[ext_resource path="res://fog.png" type="Texture" id=1] -[ext_resource path="res://floor.png" type="Texture" id=2] - -[node name="Node2D" type="Node2D"] - -[node name="fog opaque" type="Sprite" parent="."] - -texture = ExtResource( 1 ) -centered = false -offset = Vector2( -48, -48 ) -region = true -region_rect = Rect2( 0, 0, 144, 144 ) - -[node name="fog transparent" type="Sprite" parent="."] - -transform/pos = Vector2( 144, 0 ) -texture = ExtResource( 1 ) -centered = false -offset = Vector2( -48, -48 ) -region = true -region_rect = Rect2( 144, 0, 144, 144 ) - -[node name="floor" type="Sprite" parent="."] - -transform/pos = Vector2( 264, 24 ) -texture = ExtResource( 2 ) - - diff --git a/demos/2d/fog_of_war/troll.gd b/demos/2d/fog_of_war/troll.gd deleted file mode 100644 index 6f40072e84..0000000000 --- a/demos/2d/fog_of_war/troll.gd +++ /dev/null @@ -1,38 +0,0 @@ - -extends KinematicBody2D - -# This is a simple collision demo showing how -# the kinematic controller works. -# move() will allow to move the node, and will -# always move it to a non-colliding spot, -# as long as it starts from a non-colliding spot too. - -# Member variables -const MOTION_SPEED = 160 # Pixels/second - - -func _fixed_process(delta): - var motion = Vector2() - - if (Input.is_action_pressed("move_up")): - motion += Vector2(0, -1) - if (Input.is_action_pressed("move_bottom")): - motion += Vector2(0, 1) - if (Input.is_action_pressed("move_left")): - motion += Vector2(-1, 0) - if (Input.is_action_pressed("move_right")): - motion += Vector2(1, 0) - - motion = motion.normalized()*MOTION_SPEED*delta - motion = move(motion) - - # Make character slide nicely through the world - var slide_attempts = 4 - while(is_colliding() and slide_attempts > 0): - motion = get_collision_normal().slide(motion) - motion = move(motion) - slide_attempts -= 1 - - -func _ready(): - set_fixed_process(true) diff --git a/demos/2d/fog_of_war/troll.png b/demos/2d/fog_of_war/troll.png Binary files differdeleted file mode 100644 index 69f195d034..0000000000 --- a/demos/2d/fog_of_war/troll.png +++ /dev/null diff --git a/demos/2d/fog_of_war/troll.tscn b/demos/2d/fog_of_war/troll.tscn deleted file mode 100644 index 2dc8bdbf67..0000000000 --- a/demos/2d/fog_of_war/troll.tscn +++ /dev/null @@ -1,52 +0,0 @@ -[gd_scene load_steps=4 format=1] - -[ext_resource path="res://troll.gd" type="Script" id=1] -[ext_resource path="res://troll.png" type="Texture" id=2] - -[sub_resource type="CircleShape2D" id=1] - -custom_solver_bias = 0.0 -radius = 16.0 - -[node name="troll" type="KinematicBody2D"] - -input/pickable = false -shapes/0/shape = SubResource( 1 ) -shapes/0/transform = Matrix32( 1, 0, 0, 1, 3.24216, 19.453 ) -shapes/0/trigger = false -collision/layers = 1 -collision/mask = 1 -collision/margin = 0.001 -script/script = ExtResource( 1 ) - -[node name="Sprite" type="Sprite" parent="."] - -texture = ExtResource( 2 ) - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] - -transform/pos = Vector2( 3.24216, 19.453 ) -shape = SubResource( 1 ) -trigger = false -_update_shape_index = -1 - -[node name="Camera2D" type="Camera2D" parent="."] - -anchor_mode = 1 -rotating = false -current = true -zoom = Vector2( 1, 1 ) -limit/left = -10000000 -limit/top = -10000000 -limit/right = 10000000 -limit/bottom = 10000000 -drag_margin/h_enabled = true -drag_margin/v_enabled = true -smoothing/enable = false -smoothing/speed = 5.0 -drag_margin/left = 0.2 -drag_margin/top = 0.2 -drag_margin/right = 0.2 -drag_margin/bottom = 0.2 - - |