mirror of
https://github.com/mightypanders/GMTKJam2021.git
synced 2025-01-30 21:59:55 +01:00
add DOP List and script
This commit is contained in:
parent
174dfe512c
commit
b9a7ce118a
@ -1,36 +1,6 @@
|
||||
extends Node2D
|
||||
|
||||
export var entity_name = "DROPOFF"
|
||||
export var destinationColor = Color.yellow
|
||||
var rng = RandomNumberGenerator.new()
|
||||
|
||||
onready var sprite = $Sprite
|
||||
|
||||
|
||||
var colorList = [
|
||||
Color.yellow,
|
||||
Color.violet,
|
||||
Color.red,
|
||||
Color.turquoise,
|
||||
]
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
modulate_color()
|
||||
|
||||
func modulate_color():
|
||||
rng.randomize()
|
||||
var n = rng.randi_range(0,colorList.size()-1)
|
||||
print(n)
|
||||
destinationColor = colorList[n]
|
||||
print(destinationColor)
|
||||
sprite.modulate = destinationColor
|
||||
|
||||
|
||||
func _on_Timer_timeout():
|
||||
modulate_color()
|
||||
sprite.modulate = destinationColor
|
23
DropOffPoints.gd
Normal file
23
DropOffPoints.gd
Normal file
@ -0,0 +1,23 @@
|
||||
extends Node
|
||||
|
||||
var colorList = [
|
||||
Color.yellow,
|
||||
Color.violet,
|
||||
Color.red,
|
||||
Color.turquoise,
|
||||
]
|
||||
|
||||
onready var rng = RandomNumberGenerator.new()
|
||||
onready var dropOffChildern = get_children()
|
||||
|
||||
func _ready():
|
||||
rng.randomize()
|
||||
|
||||
func random_color() -> Color:
|
||||
var n = rng.randi_range(0,colorList.size()-1)
|
||||
return colorList[n]
|
||||
|
||||
func set_colors():
|
||||
for dop in dropOffChildern:
|
||||
dop.destinationColor = random_color()
|
||||
dop.modulate_color()
|
Loading…
Reference in New Issue
Block a user