Finalize core features

This commit is contained in:
Ategon 2024-10-07 17:37:16 -04:00
parent e1dc13186f
commit 355e699601
32 changed files with 444 additions and 27 deletions

View file

@ -1,10 +1,13 @@
[gd_scene load_steps=6 format=3 uid="uid://bs6ojoud4mvb8"]
[gd_scene load_steps=9 format=3 uid="uid://bs6ojoud4mvb8"]
[ext_resource type="Script" path="res://main.gd" id="1_x66oe"]
[ext_resource type="PackedScene" uid="uid://ccdhbljb3e0oh" path="res://src/ui/MainUI.tscn" id="2_anen6"]
[ext_resource type="PackedScene" uid="uid://cr2nvts234wlw" path="res://src/manager/TimeManager.tscn" id="2_rrhko"]
[ext_resource type="Texture2D" uid="uid://c37jv23kd15ay" path="res://parts/zones/images/home.png" id="3_kjcur"]
[ext_resource type="AudioStream" uid="uid://br26r6ck51wa1" path="res://Bossa Monstra.wav" id="5_qgck0"]
[ext_resource type="AudioStream" uid="uid://c06j2q7c0j6br" path="res://sfx/UI Click 2.wav" id="6_xxay8"]
[ext_resource type="AudioStream" uid="uid://cv6th0edghuyr" path="res://sfx/pick up coin.wav" id="7_612ep"]
[ext_resource type="AudioStream" uid="uid://dpqyst1dkgwnr" path="res://sfx/coin spawn.wav" id="8_ddf5u"]
[node name="Main" type="Node2D"]
script = ExtResource("1_x66oe")
@ -27,4 +30,16 @@ stream = ExtResource("5_qgck0")
volume_db = -18.0
autoplay = true
[node name="AudioStreamPlayer2" type="AudioStreamPlayer" parent="."]
stream = ExtResource("6_xxay8")
volume_db = 5.0
[node name="AudioStreamPlayer3" type="AudioStreamPlayer" parent="."]
stream = ExtResource("7_612ep")
volume_db = -11.0
[node name="AudioStreamPlayer4" type="AudioStreamPlayer" parent="."]
stream = ExtResource("8_ddf5u")
volume_db = -15.0
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View file

@ -7,7 +7,7 @@
[ext_resource type="AudioStream" uid="uid://bqn8ygvwt58sg" path="res://sfx/pick up.wav" id="5_mmqlh"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4cq27"]
size = Vector2(8, 8)
size = Vector2(4, 4)
[node name="Cursor" type="CanvasLayer"]
process_mode = 3

View file

@ -41,6 +41,8 @@ func _on_grab_creature(data):
grabbed_creature = CREATURE.instantiate()
grabbed_creature.key = data.creature
grabbed_creature.held = true
grabbed_creature.tiles = data.tiles
grabbed_creature.tiled = data.tiled
mouse_control.add_child(grabbed_creature)
grabbed_creature.position = Vector2(0, 0)
holding = true
@ -58,20 +60,34 @@ func let_go():
new_creature.key = grabbed_creature.key
new_creature.position = original_position
original_window.add_child(new_creature)
audio_stream_player_2.play()
if get_window().get_window_id() == 0:
Persister.persist_data("grabbing", false)
if Persister.get_value("hovered"):
audio_stream_player_2.play()
else:
audio_stream_player.play()
if signal_object and signal_object.mouse_in_window:
var new_creature = CREATURE.instantiate()
new_creature.key = grabbed_creature.key
new_creature.global_position = grabbed_creature.global_position
get_window().add_child(new_creature)
if get_window().name == "CreatureWindow":
var new_creature = CREATURE.instantiate()
new_creature.key = grabbed_creature.key
new_creature.global_position = grabbed_creature.global_position
get_window().add_child(new_creature)
audio_stream_player_2.play()
if grabbed_creature.tiled:
original_window.remove_tiles(grabbed_creature.tiles)
else:
if not get_window().attempt_place(grabbed_creature.key, mouse_control.position, grabbed_creature.tiles):
var new_creature = CREATURE.instantiate()
new_creature.key = grabbed_creature.key
new_creature.position = original_position
new_creature.tiles = grabbed_creature.tiles
new_creature.tiled = grabbed_creature.tiled
original_window.add_child(new_creature)
audio_stream_player.play()
else:
audio_stream_player_2.play()
if grabbed_creature.tiled:
original_window.remove_tiles(grabbed_creature.tiles)
grabbed_creature.queue_free()
grabbed_creature = null

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

3
favicon.svg Normal file
View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="16" height="16" viewBox="0 0 16 16"><image width="16" height="16" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACrSURBVDhPY9zzbN1/BgoAigEuUkFQFn4A1ANlMTAwQWmiNYMAslqwAdg0I9sCAuh8mB64C8gFeA0A2QrDuABWA0AaQsp2wTE+gNWA5fdmgOk1XW5gGh/A6wWQ7cEZ9+AGYgM4DQBpBGEYwOUVrAbMtYEoXjtDCYXGBnC6AN0QXABvGCADZO8gA3hewJYak4+gxgLMVSAASxtwF6AnFnTNIAATQ1ZLYXZmYAAAN3hJfOuteYcAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJggg=="></image><style>@media (prefers-color-scheme: light) { :root { filter: none; } }
@media (prefers-color-scheme: dark) { :root { filter: none; } }
</style></svg>

After

Width:  |  Height:  |  Size: 781 B

37
favicon.svg.import Normal file
View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://rxpgln3d4n8g"
path="res://.godot/imported/favicon.svg-a165518550174d7996e87d364e3b1023.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://favicon.svg"
dest_files=["res://.godot/imported/favicon.svg-a165518550174d7996e87d364e3b1023.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

18
main.gd
View file

@ -13,12 +13,18 @@ var build_object
@onready var upgrade_pool = Data.data.upgrades.keys()
@onready var zone_pool = Data.data.zones.keys()
@onready var audio_stream_player_2: AudioStreamPlayer = $AudioStreamPlayer2
@onready var audio_stream_player_3: AudioStreamPlayer = $AudioStreamPlayer3
@onready var audio_stream_player_4: AudioStreamPlayer = $AudioStreamPlayer4
func _ready() -> void:
Persister.persist_data("creature_resource_spawn_rate", 20)
Triggerer.listen("spawn_window", _on_spawn_window)
Triggerer.listen("upgrade_menu", _on_build_menu)
Triggerer.listen("quit", _on_quit)
Triggerer.listen("creature_sound", _on_creature_sound)
Triggerer.listen("coin_sound", _on_coin_sound)
Triggerer.listen("coin_collect_sound", _on_coin_collect_sound)
DisplayServer.window_set_title("Home")
get_viewport().transparent_bg = true
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_MOUSE_PASSTHROUGH, true)
@ -29,6 +35,18 @@ func _ready() -> void:
add_child(new_buttons)
func _on_creature_sound(_data):
audio_stream_player_2.play()
func _on_coin_collect_sound(_data):
audio_stream_player_3.play()
func _on_coin_sound(_data):
audio_stream_player_4.play()
func _process(delta: float) -> void:
if Input.is_action_just_pressed("test"):
Triggerer.trigger("spawn_window", {"key": ["farm", "desert", "lake", "forest"].pick_random()})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 B

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -3,4 +3,4 @@ description: 10% higher chance for a creature to drop coins ev
property: creature_resource_spawn_rate
type: percent
amount: 10
cost: 10
cost: 5

View file

@ -2,4 +2,4 @@ name: Creature Bait
description: 2 More creatures will wander onto your property every day
property: creature_amount
amount: 2
cost: 15
cost: 7

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -13,7 +13,7 @@ config_version=5
config/name="ld-56"
run/main_scene="res://Main.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility")
config/icon="res://icon.svg"
config/icon="res://favicon.svg"
[autoload]

BIN
sfx/coin spawn.wav Normal file

Binary file not shown.

24
sfx/coin spawn.wav.import Normal file
View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dpqyst1dkgwnr"
path="res://.godot/imported/coin spawn.wav-f206cd96b45c72a52c96538391684b3c.sample"
[deps]
source_file="res://sfx/coin spawn.wav"
dest_files=["res://.godot/imported/coin spawn.wav-f206cd96b45c72a52c96538391684b3c.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

BIN
sfx/pick up coin.wav Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cv6th0edghuyr"
path="res://.godot/imported/pick up coin.wav-c21724f7cdbce893b4cf124a00df4ec9.sample"
[deps]
source_file="res://sfx/pick up coin.wav"
dest_files=["res://.godot/imported/pick up coin.wav-c21724f7cdbce893b4cf124a00df4ec9.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View file

@ -20,6 +20,7 @@ size = Vector2(52, 73)
[node name="BuildWindow" type="Window"]
canvas_item_default_texture_filter = 0
title = "Shop"
position = Vector2i(0, 36)
size = Vector2i(900, 500)
unresizable = true
@ -72,7 +73,6 @@ offset_right = 83.15
offset_bottom = 145.945
grow_horizontal = 2
bbcode_enabled = true
text = "[center]Test Description"
[node name="Upgrade" type="TextureRect" parent="Control"]
custom_minimum_size = Vector2(32, 40)

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://dyd3gq1oc117t"]
[gd_scene load_steps=6 format=3 uid="uid://dyd3gq1oc117t"]
[ext_resource type="PackedScene" uid="uid://dykc1mgg5uopw" path="res://components/Cursor/MouseHandler.tscn" id="1_53keb"]
[ext_resource type="Script" path="res://src/coin.gd" id="1_l62nl"]
[ext_resource type="Texture2D" uid="uid://cndrtahwhbkli" path="res://src/ui/coin.png" id="2_5qokh"]
[ext_resource type="AudioStream" uid="uid://cv6th0edghuyr" path="res://sfx/pick up coin.wav" id="4_rysea"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6mwyk"]
size = Vector2(8, 8)
@ -18,4 +19,8 @@ shape = SubResource("RectangleShape2D_6mwyk")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_5qokh")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("4_rysea")
volume_db = -11.0
[connection signal="hovered" from="MouseHandler" to="." method="_on_mouse_handler_hovered"]

View file

@ -1,8 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://yao5smo8c43u"]
[gd_scene load_steps=7 format=3 uid="uid://yao5smo8c43u"]
[ext_resource type="Script" path="res://src/creature.gd" id="1_34bi4"]
[ext_resource type="Texture2D" uid="uid://dnvnm78idadmn" path="res://parts/creatures/images/1x1-1.png" id="2_upgji"]
[ext_resource type="PackedScene" uid="uid://dykc1mgg5uopw" path="res://components/Cursor/MouseHandler.tscn" id="3_vlaga"]
[ext_resource type="AudioStream" uid="uid://dpqyst1dkgwnr" path="res://sfx/coin spawn.wav" id="4_g8x0y"]
[ext_resource type="AudioStream" uid="uid://c06j2q7c0j6br" path="res://sfx/UI Click 2.wav" id="5_wsv0d"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4rqgs"]
size = Vector2(12, 12)
@ -18,4 +20,13 @@ texture = ExtResource("2_upgji")
[node name="CollisionShape2D" type="CollisionShape2D" parent="MouseHandler"]
shape = SubResource("RectangleShape2D_4rqgs")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("4_g8x0y")
volume_db = -15.0
[node name="AudioStreamPlayer2" type="AudioStreamPlayer" parent="."]
stream = ExtResource("5_wsv0d")
volume_db = 5.0
[connection signal="clicked" from="MouseHandler" to="." method="_on_mouse_handler_clicked"]
[connection signal="hovered" from="MouseHandler" to="." method="_on_mouse_handler_hovered"]

View file

@ -6,6 +6,7 @@
[node name="CreatureWindow" type="Window"]
canvas_item_default_texture_filter = 0
title = "Wild"
position = Vector2i(0, 36)
size = Vector2i(300, 300)
unresizable = true
@ -20,3 +21,39 @@ texture = ExtResource("3_bxvic")
script = ExtResource("1_eufhm")
[node name="MouseSignals" parent="." instance=ExtResource("2_3cu4o")]
[node name="Timer" type="Timer" parent="."]
one_shot = true
autostart = true
[node name="Timer2" type="Timer" parent="."]
wait_time = 6.0
one_shot = true
autostart = true
[node name="Timer3" type="Timer" parent="."]
wait_time = 12.0
one_shot = true
autostart = true
[node name="Timer4" type="Timer" parent="."]
wait_time = 20.0
one_shot = true
autostart = true
[node name="Timer5" type="Timer" parent="."]
wait_time = 30.0
one_shot = true
autostart = true
[node name="Timer6" type="Timer" parent="."]
wait_time = 50.0
one_shot = true
autostart = true
[connection signal="timeout" from="Timer" to="Node2D" method="_on_timer_timeout"]
[connection signal="timeout" from="Timer2" to="Node2D" method="_on_timer_timeout"]
[connection signal="timeout" from="Timer3" to="Node2D" method="_on_timer_timeout"]
[connection signal="timeout" from="Timer4" to="Node2D" method="_on_timer_timeout"]
[connection signal="timeout" from="Timer5" to="Node2D" method="_on_timer_timeout"]
[connection signal="timeout" from="Timer6" to="Node2D" method="_on_timer_timeout"]

View file

@ -81,7 +81,7 @@ func _update_card(index):
main.zone_pool.shuffle()
choice = main.zone_pool.pop_back()
card_data = Data.data.zones[choice]
cost = 20
cost = 10 + (5 * Persister.get_value("zones_bought", PersisterEnums.Scope.UNKNOWN, 0))
cards[index].object.texture = Data.data.images["%s-card" % [choice]]
else:
if main.upgrade_pool.size() == 0:
@ -89,12 +89,15 @@ func _update_card(index):
main.upgrade_pool.shuffle()
choice = main.upgrade_pool.pop_back()
card_data = Data.data.upgrades[choice]
cost = card_data.cost
cost = card_data.cost + (round(card_data.cost / 2) * Persister.get_value(choice, PersisterEnums.Scope.UNKNOWN, 0))
cards[index].title.text = "[center]%s" % [card_data.name]
cards[index].cost.text = "[center]%d G" % [cost]
card_data.key = choice
chosen_cards[index] = card_data
if (index == 1 and chosen_cards[0].key == choice) or (index == 0 and chosen_cards[1] and chosen_cards[1].key == choice):
_update_card(index)
func _on_mouse_handler_clicked() -> void:
@ -130,8 +133,8 @@ func _buy_upgrade(index):
return
var card_data = chosen_cards[index]
if Persister.get_value("gold", PersisterEnums.Scope.UNKNOWN, 0) >= (card_data.cost if card_data.has("cost") else 20):
Persister.change_value("gold", -(card_data.cost if card_data.has("cost") else 20))
if Persister.get_value("gold", PersisterEnums.Scope.UNKNOWN, 0) >= (card_data.cost if card_data.has("cost") else 10 + (5 * Persister.get_value("zones_bought", PersisterEnums.Scope.UNKNOWN, 0))):
Persister.change_value("gold", -(card_data.cost if card_data.has("cost") else 10 + (5 * Persister.get_value("zones_bought", PersisterEnums.Scope.UNKNOWN, 0))))
buying[index] = true
@ -151,9 +154,11 @@ func _buy_upgrade(index):
if index == 2:
Triggerer.trigger("spawn_window", {"key": card_data.key})
audio_stream_player_2.play()
Persister.change_value("zones_bought", 1)
else:
Persister.change_value(card_data.property, card_data.amount)
audio_stream_player.play()
Persister.change_value(card_data.key, 1)
else:
audio_stream_player_3.play()

View file

@ -1,6 +1,38 @@
extends Node2D
var hovered = false
@onready var audio_stream_player: AudioStreamPlayer = $AudioStreamPlayer
@onready var sprite_2d: Sprite2D = $Sprite2D
var tween
func _ready() -> void:
sprite_2d.scale = Vector2.ZERO
tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_BACK)
tween.tween_property(sprite_2d, "scale", Vector2.ONE, 0.25)
func _on_mouse_handler_hovered() -> void:
if hovered:
return
hovered = true
#audio_stream_player.play()
Triggerer.trigger("coin_collect_sound")
Persister.change_value("gold", 1)
queue_free()
if tween:
tween.kill()
tween = create_tween()
tween.tween_property(sprite_2d, "scale:x", 0, 0.125)
tween.tween_property(sprite_2d, "scale:x", 1, 0.125)
tween.tween_property(sprite_2d, "scale:x", 0, 0.125)
tween.tween_property(sprite_2d, "scale:x", 1, 0.125)
tween.tween_callback(queue_free)
var start_pos = position.y
var tween2 = create_tween()
tween2.tween_property(self, "position:y", start_pos - 5, 0.5)

View file

@ -6,24 +6,73 @@ var key
@onready var image = Data.data.images[key]
@onready var sprite_2d: Sprite2D = $Sprite2D
@onready var audio_stream_player: AudioStreamPlayer = $AudioStreamPlayer
@onready var audio_stream_player_2: AudioStreamPlayer = $AudioStreamPlayer2
const COIN = preload("res://src/Coin.tscn")
var held = false
var target
var start_pos
var lifetime_timer = randi_range(10, 15)
var end_pos
var tween
var tiled = false
var tiles = []
func _ready() -> void:
sprite_2d.texture = image
Triggerer.listen("hour", _on_hour)
func _process(delta: float) -> void:
if target:
position = position.lerp(target, delta * 2)
if get_window().name == "CreatureWindow":
if Persister.get_value("paused"):
return
lifetime_timer -= delta
if lifetime_timer <= 0 and not end_pos:
end_pos = true
match randi_range(0, 3):
0:
target = Vector2(-25, randi_range(-25, 100))
1:
target = Vector2(100, randi_range(-25, 100))
2:
target = Vector2(randi_range(-25, 100), -25)
3:
target = Vector2(randi_range(-25, 100), 100)
if lifetime_timer <= -2:
queue_free()
func _on_hour(_data):
if not held and randf() < (Persister.get_value("creature_resource_spawn_rate") / 100.0):
var new_coin = COIN.instantiate()
new_coin.global_position = global_position
get_window().add_child(new_coin)
#audio_stream_player.play()
Triggerer.trigger("coin_sound")
func _on_mouse_handler_clicked() -> void:
Triggerer.trigger("grab_creature", {"creature": key, "old_window": get_window(), "old_position": position})
Triggerer.trigger("grab_creature", {"creature": key, "old_window": get_window(), "old_position": position, "tiled": tiled, "tiles": tiles})
Persister.persist_data("grabbing", true)
queue_free()
func _on_mouse_handler_hovered() -> void:
if held:
return
if tween:
tween.kill()
tween = create_tween()
tween.tween_property(sprite_2d, "position:y", -1, 0.075)
tween.tween_property(sprite_2d, "position:y", 0, 0.075)
#audio_stream_player_2.play()
Triggerer.trigger("creature_sound")

View file

@ -24,11 +24,22 @@ func _on_minutes(_data):
minutes_left -= 1
if spawn_times.has(minutes_left):
var new_creature = CREATURE.instantiate()
new_creature.position = Vector2(50, 50)
new_creature.key = Data.data.creatures.keys().pick_random()
add_child(new_creature)
_spawn_creature()
func _spawn_creature():
var new_creature = CREATURE.instantiate()
match randi_range(0, 3):
0:
new_creature.position = Vector2(-25, randi_range(-25, 100))
1:
new_creature.position = Vector2(100, randi_range(-25, 100))
2:
new_creature.position = Vector2(randi_range(-25, 100), -25)
3:
new_creature.position = Vector2(randi_range(-25, 100), 100)
new_creature.target = Vector2(randi_range(25, 50), randi_range(25, 50))
new_creature.key = Data.data.creatures.keys().pick_random()
add_child(new_creature)
func _on_day(_data):
minutes_left = 6 * 24
@ -41,3 +52,7 @@ func _generate_spawn_times():
for i in range(0, 4):
spawn_times.push_back(randi_range(2, 6 * 24 - 2))
func _on_timer_timeout() -> void:
_spawn_creature()

View file

@ -9,6 +9,9 @@ var key
const CREATURE = preload("res://src/Creature.tscn")
var tiles = []
var newt = []
func _ready() -> void:
var window_size = get_tree().root.get_window().size
@ -19,6 +22,129 @@ func _ready() -> void:
sprite_2d.position = Vector2(int(data.size[0]) * 12 / 2, int(data.size[1]) * 12 / 2)
func attempt_place(key, position, tiles2):
var creature_data = Data.data.creatures[key]
var tile_size = Vector2(12, 12)
var round_bound = round(position.x / tile_size.x)
var lower_bound = round_bound - 1
var upper_bound = round_bound
var lower_bound2 = round_bound
var upper_bound2 = round_bound + 1
var bound_2 = round((position.x + 6) / tile_size.x)
var round_bound_y = round(position.y / tile_size.y)
var lower_bound_y = round_bound_y - 1
var upper_bound_y = round_bound_y
var lower_bound_y2 = round_bound_y
var upper_bound_y2 = round_bound_y + 1
var bound_2_y = round((position.y + 6) / tile_size.y)
prints(position / tile_size.x)
if lower_bound_y == upper_bound_y:
upper_bound_y += 1
if lower_bound_y2 == upper_bound_y2:
upper_bound_y2 += 1
var tile_x = round(position.x / tile_size.x)
var tile_y = round(position.y / tile_size.y)
var valid_x = false
var bounds_x
var bounds_y
if creature_data.width == 1:
valid_x = _check_tile(bound_2, 0)
else:
var check1 = _check_tile(lower_bound, 0) and _check_tile(upper_bound, 0)
var check2 = _check_tile(lower_bound2, 0) and _check_tile(upper_bound2, 0)
valid_x = check1 or check2
if check1:
bounds_x = Vector2(lower_bound, upper_bound)
if check2:
bounds_x = Vector2(lower_bound2, upper_bound2)
var valid_y = false
if creature_data.height == 1:
valid_y = _check_tile(bound_2_y, 1)
else:
var check1 = _check_tile(lower_bound_y, 1) and _check_tile(upper_bound_y, 1)
var check2 = _check_tile(lower_bound_y2, 1) and _check_tile(upper_bound_y2, 1)
valid_y = check1 or check2
if check1:
bounds_y = Vector2(lower_bound_y, upper_bound_y)
if check2:
bounds_y = Vector2(lower_bound_y2, upper_bound_y2)
if valid_x and valid_y:
if _check_if_contains(creature_data, bound_2, bound_2_y, bounds_x, bounds_y, tiles2):
return false
var new_creature = CREATURE.instantiate()
new_creature.key = key
new_creature.position = Vector2((bound_2 - 0.5) if creature_data.width == 1 else bounds_x[1] - 1, (bound_2_y - 0.5) if creature_data.height == 1 else bounds_y[1] - 1) * 12
get_window().add_child(new_creature)
new_creature.tiled = true
new_creature.tiles = newt
return true
func remove_tiles(array):
for element in array:
tiles.erase(element)
func _check_if_contains(data, bound1, bound1y, bounds2, bounds2y, tiles2):
newt = []
var checks = []
if data.width == 1:
if data.height == 1:
checks.push_back(Vector2i(bound1, bound1y))
else:
checks.push_back(Vector2i(bound1, bounds2y[0]))
checks.push_back(Vector2i(bound1, bounds2y[1]))
else:
if data.height == 1:
checks.push_back(Vector2i(bounds2[0], bound1y))
checks.push_back(Vector2i(bounds2[1], bound1y))
else:
checks.push_back(Vector2i(bounds2[0], bounds2y[0]))
checks.push_back(Vector2i(bounds2[1], bounds2y[0]))
checks.push_back(Vector2i(bounds2[0], bounds2y[1]))
checks.push_back(Vector2i(bounds2[1], bounds2y[1]))
for check in checks:
if tiles.has(check):
if tiles2:
if not tiles2.has(check):
return true
else:
return true
for check in checks:
newt.push_back(check)
tiles.push_back(check)
return false
func _check_tile(coords, dir):
var placeable_min = 2
var placeable_max = int(data.size[dir]) - 1
if coords >= placeable_min and coords <= placeable_max:
return true
return false
#
#New Zones
#

BIN
wall.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 576 B

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
wild.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 1.6 KiB