Adding cursors
This commit is contained in:
@@ -29,3 +29,14 @@ func update_card():
|
||||
waterSupply.text = str(next_seed_param.water_prod)
|
||||
fertilitySupply.text = str(next_seed_param.fertility_prod)
|
||||
populationSupply.text = str(next_seed_param.presence_prod)
|
||||
|
||||
func update_mouse_position(mouse_position):
|
||||
if (
|
||||
mouse_position.x > 0
|
||||
and mouse_position.y > 0
|
||||
and mouse_position.x < GameTerrain.TERRAIN_SIZE.x * GameTerrain.MAP_RATIO
|
||||
and mouse_position.y < GameTerrain.TERRAIN_SIZE.y * GameTerrain.MAP_RATIO
|
||||
):
|
||||
waterNeeds.set_cursor(GameTerrain.get_color(mouse_position).r)
|
||||
fertilityNeeds.set_cursor(GameTerrain.get_color(mouse_position).g)
|
||||
populationNeeds.set_cursor(GameTerrain.get_color(mouse_position).b)
|
||||
|
||||
@@ -3,6 +3,8 @@ extends CenterContainer
|
||||
|
||||
@export var gradient : GradientTexture1D
|
||||
|
||||
const CURSOR_WIDTH = 0.08
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$Gradient.texture = gradient
|
||||
@@ -26,3 +28,20 @@ func set_area(need : Array):
|
||||
texture.gradient = zone_grad
|
||||
|
||||
$Zone.texture = texture
|
||||
|
||||
func set_cursor(color_value):
|
||||
var zone_grad := Gradient.new()
|
||||
|
||||
zone_grad.interpolation_mode = Gradient.GRADIENT_INTERPOLATE_CONSTANT
|
||||
|
||||
zone_grad.set_color(0, Color(1,1,1,0))
|
||||
zone_grad.set_color(1, Color(1,1,1,0))
|
||||
|
||||
zone_grad.add_point(max(color_value - CURSOR_WIDTH/2, 0.0), Color(1,1,1,1))
|
||||
zone_grad.add_point(min(color_value + CURSOR_WIDTH/2, 1.0), Color(1,1,1,0))
|
||||
|
||||
var texture := GradientTexture1D.new()
|
||||
|
||||
texture.gradient = zone_grad
|
||||
|
||||
$Cursor.texture = texture
|
||||
|
||||
Reference in New Issue
Block a user