Now a few mobs get spawned, also fixed targeting.

This commit is contained in:
Relintai 2019-12-20 21:37:36 +01:00
parent 90a602a81f
commit 5a1460df0e
3 changed files with 15 additions and 8 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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