Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Projects/split/assets/16x16black.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ dest_files=["res://.godot/imported/16x16black.png-5e8145782b79248dfaa02d8676f34b
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
Expand Down
6 changes: 6 additions & 0 deletions Projects/split/assets/16x16white.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ dest_files=["res://.godot/imported/16x16white.png-ec46b3f73bbe2f120e7fb9c4edfa6b
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
Expand Down
6 changes: 4 additions & 2 deletions Projects/split/scenes/world.tscn
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[gd_scene load_steps=4 format=3 uid="uid://dik5rqh5f6kul"]
[gd_scene load_steps=5 format=3 uid="uid://dik5rqh5f6kul"]

[ext_resource type="Texture2D" uid="uid://dvyq6o6ydksev" path="res://assets/16x16black.png" id="1_p2yq5"]
[ext_resource type="Script" uid="uid://bonuvp7npa7eu" path="res://scripts/lanscape_camera.gd" id="2_k0juu"]
[ext_resource type="PackedScene" uid="uid://bv5wirk2j375u" path="res://scenes/root.tscn" id="2_k2vro"]
[ext_resource type="Script" uid="uid://cxp36b3eu6cos" path="res://scripts/treeHUD.gd" id="3_yikaj"]

[node name="World" type="Node2D"]

[node name="Background" type="Sprite2D" parent="."]
position = Vector2(0, -37)
scale = Vector2(200, 200)
scale = Vector2(1000, 1000)
texture = ExtResource("1_p2yq5")

[node name="Camera2D" type="Camera2D" parent="."]
zoom = Vector2(0.49, 0.49)
script = ExtResource("2_k0juu")

[node name="Root" parent="." instance=ExtResource("2_k2vro")]
unique_name_in_owner = true
Expand Down
14 changes: 12 additions & 2 deletions Projects/split/scripts/lanscape_camera.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
extends Camera2D


var grow: Grow
var cam_zoom: float = 0.49
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
grow = %Root
grow.new_growth.connect(_new_growth)
pass


Expand All @@ -12,4 +15,11 @@ func _process(delta: float) -> void:

#look at the incoming growth locations and zoom the camera if they are not visible
func _new_growth(growth:Node2D) -> void:
pass
# percent_top indicates how much above the top is viewed
const percent_top : float = 0.1
const base_zoom_y : float = 324
var ideal_zoom : float = min(0.49, (base_zoom_y) / (-(1 + percent_top)*(min(-1, growth.global_position.y))))
if (cam_zoom > ideal_zoom):
cam_zoom = ideal_zoom
zoom = Vector2(cam_zoom, cam_zoom)
return