From 5a1460df0e4cc14d0d713442d4a19afbf05ef00b Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 20 Dec 2019 21:37:36 +0100 Subject: [PATCH] Now a few mobs get spawned, also fixed targeting. --- game/autoload/EntityDataManager.gd | 2 +- game/player/Player.gd | 14 +++++++------- game/scenes/World.gd | 7 +++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/game/autoload/EntityDataManager.gd b/game/autoload/EntityDataManager.gd index 9cef645..169bddf 100644 --- a/game/autoload/EntityDataManager.gd +++ b/game/autoload/EntityDataManager.gd @@ -302,7 +302,7 @@ func spawn(createinfo : EntityCreateInfo, networked : bool, position : Vector2, spawn_parent.add_child(entity_node) entity_node.owner = spawn_parent - entity_node.translation = position + entity_node.position = position entity_node.initialize(createinfo) diff --git a/game/player/Player.gd b/game/player/Player.gd index 074f717..68902fe 100644 --- a/game/player/Player.gd +++ b/game/player/Player.gd @@ -199,9 +199,9 @@ func _unhandled_input(event: InputEvent) -> void: # if event.button_index == BUTTON_WHEEL_DOWN: # camera_pivot.camera_distance_set_delta(0.2) - if not event.pressed and event.button_index == BUTTON_LEFT and event.device != -1: - if mouse_down_delta.length() < MOUSE_TARGET_MAX_OFFSET: - target(event.position) +# if not event.pressed and event.button_index == BUTTON_LEFT and event.device != -1: +# if mouse_down_delta.length() < MOUSE_TARGET_MAX_OFFSET: +# target(event.position) if event.pressed and event.button_index == BUTTON_RIGHT and event.device != -1: target(event.position) @@ -215,8 +215,8 @@ func _unhandled_input(event: InputEvent) -> void: func target(position : Vector2): var space_state = get_world_2d().direct_space_state - #var results = space_state.intersect_point(map.make_canvas_position_local(position), 32, [], 2) - var results = space_state.intersect_point(position, 32, [], 2) + var results = space_state.intersect_point(world.make_canvas_position_local(position), 32, [], 2) + #var results = space_state.intersect_point(position, 32, [], 2) if results: for result in results: @@ -231,8 +231,8 @@ func target(position : Vector2): func cmouseover(event): var space_state = get_world_2d().direct_space_state - #var results = space_state.intersect_point(map.make_canvas_position_local(position), 32, [], 2) - var results = space_state.intersect_point(position, 32, [], 2) + var results = space_state.intersect_point(world.make_canvas_position_local(position), 32, [], 2) + #var results = space_state.intersect_point(position, 32, [], 2) if results: for result in results: diff --git a/game/scenes/World.gd b/game/scenes/World.gd index 08df45d..826dce5 100644 --- a/game/scenes/World.gd +++ b/game/scenes/World.gd @@ -21,8 +21,15 @@ func load_character(file_name: String) -> void: # _player.set_physics_process(false) Server.sset_seed(_player.sseed) + + generate() +func generate() -> void: + for x in range(-5, 5): + for y in range(-5, 5): + Entities.spawn_mob(1, 50, Vector2(x * 200, y * 200)) + func save() -> void: if _player == null or _player_file_name == "": return