Skip to content

Commit

Permalink
randomizes positon of resource drops on death.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexnortung committed Jul 13, 2021
1 parent 94be5d8 commit fa6eed9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/game/Game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var players = {}
var projectiles = {}
# Entities are other Nodes with ids
var entities = {}
var rng = RandomNumberGenerator.new()
const projectileTypes = {
base_projectile = preload("res://common/game/projectiles/BaseProjectile.tscn"), # 0
}
Expand Down
3 changes: 2 additions & 1 deletion server/game/ServerGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ func spawn_resource_drops_from_player(player : Node2D, lost_resources: Array):
# Do not spawn resource drops if there are 0 or less
continue
# TODO: add randomized direction
var newPosition = player.position
var randomVector = Vector2(rng.randf_range(-1, 1), rng.randf_range(-1, 1)) * 50
var newPosition = player.position + randomVector
server_spawn_resource_drop(newPosition, resourceType, amount, player.position)

func server_spawn_resource_drop(position: Vector2, type: int, amount: int, oldPosition : Vector2, id : String = UUID.v4()):
Expand Down

0 comments on commit fa6eed9

Please sign in to comment.