Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
boscohyun committed Jan 8, 2024
1 parent 1ca9349 commit 47651b3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
23 changes: 14 additions & 9 deletions frontend/Saver-22b-godot/village_view/VillageView.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ func _input(event):
var mouse_event = event as InputEventMouseButton
if mouse_event != null and mouse_event.is_released() and mouse_event.button_index == MOUSE_BUTTON_LEFT and mouse_event.is_command_or_control_pressed():
print("Mouse Click/Unclick at: ", event.position)
build_house()
print("root pos: ", root_local_position)
var pos = bg.get_local_mouse_position()
print("mouse pos: ", pos)
var relative_pos = pos - root_local_position
relative_pos /= Coordinate_weight
relative_pos.x = roundi(relative_pos.x)
relative_pos.y = roundi(relative_pos.y)
build_house(relative_pos)

func initialize_by_village(village: Dictionary):
initialize(
Expand Down Expand Up @@ -61,16 +68,14 @@ func instantiate_house(pos: Vector2):
bg.add_child(house)
house.set_size(Vector2(Coordinate_weight, Coordinate_weight))
house.set_global_position(pos * Coordinate_weight + root_position - Vector2(Coordinate_weight / 2, Coordinate_weight / 2))
house.button_down.connect(func(house_pos):
#var village = SceneContext.get_selected_village()
#village.houses.
get_tree().change_scene_to_file("res://scenes/farm.tscn")
)

func build_house():
var pos = bg.get_local_mouse_position()
var relative_pos = pos - root_local_position
relative_pos /= Coordinate_weight
relative_pos.x = roundi(relative_pos.x)
relative_pos.y = roundi(relative_pos.y)
func build_house(relative_pos: Vector2):
print("build house pos: ", relative_pos)
print("root pos: ", root_local_position)
print("mouse pos: ", pos)
print("public key: ", GlobalSigner.signer.GetPublicKey())
var gql_query = Gql_query.new()
var query_string = gql_query.place_house_query_format.format([
Expand Down
7 changes: 7 additions & 0 deletions frontend/Saver-22b-godot/village_view/house_texture_rect.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends TextureRect

signal button_down(position: Vector2)

func _on_button_button_down():
print(position)
button_down.emit(position)
19 changes: 18 additions & 1 deletion frontend/Saver-22b-godot/village_view/house_texture_rect.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://cjvcx7fit5avb"]
[gd_scene load_steps=3 format=3 uid="uid://ccrlf3kfcisji"]

[ext_resource type="Texture2D" uid="uid://dajunmx26gvr5" path="res://sprites/house.png" id="1_4yb37"]
[ext_resource type="Script" path="res://village_view/house_texture_rect.gd" id="2_hemgv"]

[node name="House_TextureRect" type="TextureRect"]
anchors_preset = 8
Expand All @@ -17,3 +18,19 @@ grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("1_4yb37")
script = ExtResource("2_hemgv")

[node name="Button" type="Button" parent="."]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -6.0
offset_bottom = 16.0
grow_horizontal = 2
grow_vertical = 0
theme_override_font_sizes/font_size = 10
text = "Enter"

[connection signal="button_down" from="Button" to="." method="_on_button_button_down"]

0 comments on commit 47651b3

Please sign in to comment.