finished belts. Some random errors in corners...
This commit is contained in:
@@ -17,17 +17,19 @@ func _process(delta: float) -> void:
|
|||||||
func setup(pos, dir):
|
func setup(pos, dir):
|
||||||
map_position = pos
|
map_position = pos
|
||||||
facing_direction = dir
|
facing_direction = dir
|
||||||
|
self.rotate(-PI / 2 * facing_direction)
|
||||||
|
|
||||||
func collect(input_value: int):
|
func collect(input_value: int):
|
||||||
$value_text.text = str(input_value)
|
if empty:
|
||||||
$value_text.show()
|
$value_text.text = str(input_value)
|
||||||
empty = false
|
$value_text.show()
|
||||||
value = input_value
|
empty = false
|
||||||
|
value = input_value
|
||||||
|
|
||||||
func move():
|
func move():
|
||||||
#print("Moving item")
|
#print("Moving item")
|
||||||
move_timer += 1
|
move_timer += 1
|
||||||
$value_text.position[1] = -30 + (move_timer * 2)
|
$value_text.position[1] = -14 + (move_timer * 2)
|
||||||
if move_timer > 15:
|
if move_timer > 15:
|
||||||
move_timer = 0
|
move_timer = 0
|
||||||
empty = true
|
empty = true
|
||||||
@@ -35,5 +37,11 @@ func move():
|
|||||||
var next_pos = map_position
|
var next_pos = map_position
|
||||||
if facing_direction == 0:
|
if facing_direction == 0:
|
||||||
next_pos[1] += 1
|
next_pos[1] += 1
|
||||||
|
elif facing_direction == 1:
|
||||||
|
next_pos[0] += 1
|
||||||
|
elif facing_direction == 2:
|
||||||
|
next_pos[1] -= 1
|
||||||
|
elif facing_direction == 3:
|
||||||
|
next_pos[0] -= 1
|
||||||
return [next_pos, value]
|
return [next_pos, value]
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ script = ExtResource("2_rfspg")
|
|||||||
visible = false
|
visible = false
|
||||||
z_index = 1
|
z_index = 1
|
||||||
offset_left = -14.0
|
offset_left = -14.0
|
||||||
offset_top = -30.0
|
offset_top = -14.0
|
||||||
offset_right = 14.0
|
offset_right = 14.0
|
||||||
offset_bottom = -7.0
|
offset_bottom = 9.0
|
||||||
theme_override_colors/font_color = Color(0.23529412, 0, 0.8862745, 1)
|
theme_override_colors/font_color = Color(0.23529412, 0, 0.8862745, 1)
|
||||||
text = "-99"
|
text = "-99"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@ var producer_value: int
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
print("Placed Extractor at: (%s, %s)" % [self.global_position[0], self.global_position[1]])
|
print("Placed Extractor at: (%s, %s)" % [self.global_position[0], self.global_position[1]])
|
||||||
|
|
||||||
func setup(value):
|
func setup(setup_value):
|
||||||
producer_value = value
|
producer_value = setup_value
|
||||||
print("extractor value set as %s" % producer_value)
|
print("extractor value set as %s" % producer_value)
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
|||||||
+16
-11
@@ -14,6 +14,7 @@ const DELETE_SCENE = preload("res://delete.tscn")
|
|||||||
|
|
||||||
enum Mode { NONE, PLACE_EXTRACTOR, PLACE_BELT, PLACE_ADDER, DELETE }
|
enum Mode { NONE, PLACE_EXTRACTOR, PLACE_BELT, PLACE_ADDER, DELETE }
|
||||||
var current_mode = Mode.NONE
|
var current_mode = Mode.NONE
|
||||||
|
var current_direction = 0
|
||||||
var preview_item: Node2D = null # Holds the visual for the mouse
|
var preview_item: Node2D = null # Holds the visual for the mouse
|
||||||
|
|
||||||
# These should likely be changed to be the same format as above
|
# These should likely be changed to be the same format as above
|
||||||
@@ -67,6 +68,14 @@ func _input(event):
|
|||||||
elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
|
elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
|
||||||
clear_preview()
|
clear_preview()
|
||||||
current_mode = Mode.NONE
|
current_mode = Mode.NONE
|
||||||
|
if event is InputEventKey and event.pressed:
|
||||||
|
print('key pressed')
|
||||||
|
if event.keycode == KEY_BRACKETLEFT:
|
||||||
|
current_direction = (current_direction + 1) % 4
|
||||||
|
preview_item.rotate(-PI / 2)
|
||||||
|
elif event.keycode == KEY_BRACKETRIGHT:
|
||||||
|
current_direction = (current_direction - 1) % 4
|
||||||
|
preview_item.rotate(+PI / 2)
|
||||||
|
|
||||||
|
|
||||||
# Returns the grid position of the mouse
|
# Returns the grid position of the mouse
|
||||||
@@ -135,16 +144,8 @@ func process_grid_data_at(coords: Vector2i) -> void:
|
|||||||
|
|
||||||
# Formula: Start at 1, add 1 extra value for every 10 tiles away
|
# Formula: Start at 1, add 1 extra value for every 10 tiles away
|
||||||
var producer_value = 1 + floor(distance / 10.0)
|
var producer_value = 1 + floor(distance / 10.0)
|
||||||
|
|
||||||
# Register the producer in our global data registry
|
|
||||||
# disabled: for x in range(-1, 2):
|
|
||||||
# disabled: for y in range(-1, 2):
|
|
||||||
# disabled: grid_data[coords + Vector2i(x, y)] = {
|
|
||||||
# disabled: "type": "producer",
|
|
||||||
# disabled: "value": producer_value
|
|
||||||
# disabled: }
|
|
||||||
|
|
||||||
|
|
||||||
grid_data[coords] = [{
|
grid_data[coords] = [{
|
||||||
"type": "producer",
|
"type": "producer",
|
||||||
"value": producer_value
|
"value": producer_value
|
||||||
@@ -169,6 +170,7 @@ func set_preview_mode(mode_type: Mode, scene_to_preview: PackedScene):
|
|||||||
|
|
||||||
if scene_to_preview:
|
if scene_to_preview:
|
||||||
preview_item = scene_to_preview.instantiate()
|
preview_item = scene_to_preview.instantiate()
|
||||||
|
preview_item.rotate(-PI / 2 * current_direction)
|
||||||
# Optional: Make the preview slightly transparent
|
# Optional: Make the preview slightly transparent
|
||||||
preview_item.modulate.a = 0.5
|
preview_item.modulate.a = 0.5
|
||||||
add_child(preview_item)
|
add_child(preview_item)
|
||||||
@@ -213,7 +215,7 @@ func place_item(item: PackedScene):
|
|||||||
if item == EXTRACTOR_SCENE:
|
if item == EXTRACTOR_SCENE:
|
||||||
new_item.setup(object_at_coords['value'])
|
new_item.setup(object_at_coords['value'])
|
||||||
elif item == BELT_SCENE:
|
elif item == BELT_SCENE:
|
||||||
new_item.setup(spawn_pos, 0)
|
new_item.setup(spawn_pos, current_direction)
|
||||||
else:
|
else:
|
||||||
print("No custom setup for %s" % item)
|
print("No custom setup for %s" % item)
|
||||||
|
|
||||||
@@ -242,7 +244,10 @@ func register_object_at_coordinate(coords: Vector2i, object_data: Dictionary) ->
|
|||||||
grid_data[coords] = [object_data]
|
grid_data[coords] = [object_data]
|
||||||
|
|
||||||
func delete_object_at_coordinate(coords: Vector2i):
|
func delete_object_at_coordinate(coords: Vector2i):
|
||||||
grid_data[coords].pop_back()
|
if grid_data.has(coords):
|
||||||
|
grid_data[coords].pop_back()
|
||||||
|
if grid_data[coords] == []:
|
||||||
|
grid_data.erase(coords)
|
||||||
|
|
||||||
|
|
||||||
# --- UI Button Signals ---
|
# --- UI Button Signals ---
|
||||||
|
|||||||
+4
-3
@@ -2,13 +2,14 @@ extends Sprite2D
|
|||||||
|
|
||||||
var output_value: int
|
var output_value: int
|
||||||
|
|
||||||
func setup(output_value):
|
func setup(out_value):
|
||||||
$tooltip.hide()
|
$tooltip.hide()
|
||||||
print("Producer spawned physically with a value of: ", output_value)
|
print("Producer spawned physically with a value of: ", out_value)
|
||||||
$text_value.text = str(output_value)
|
$text_value.text = str(out_value)
|
||||||
$tooltip.text = "Placed at: (%s, %s)" % [self.global_position[0], self.global_position[1]]
|
$tooltip.text = "Placed at: (%s, %s)" % [self.global_position[0], self.global_position[1]]
|
||||||
print($tooltip.size )
|
print($tooltip.size )
|
||||||
$tooltip.size = Vector2i(100, 100)
|
$tooltip.size = Vector2i(100, 100)
|
||||||
|
output_value = out_value
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user