Alles werkt. ship it
This commit is contained in:
+57
@@ -1,8 +1,65 @@
|
||||
extends Node
|
||||
|
||||
var naampje = "je moeder"
|
||||
var dna = []
|
||||
# const DNA_SIZE = 173;
|
||||
const TRAITS = {
|
||||
"Arm": [1, 4, 5],
|
||||
"Leg": [2, 1, 2],
|
||||
"Head": [1, 2, 2, 2, 1],
|
||||
"Skin": [3, 3, 3, 3],
|
||||
"Penis": [2]
|
||||
}
|
||||
const TIERS_STRING = "12 3 1 23 12 3 4 51 2 3 4 1 "
|
||||
const TRAIT_STRING = "Arm Leg Head Skin Penis"
|
||||
|
||||
func initialize():
|
||||
# Make one boolean per thing we need
|
||||
for i in range(TRAITS.size()):
|
||||
for j in range(TRAITS.values()[i].size()):
|
||||
for x in range(TRAITS.values()[i][j]):
|
||||
if randf() > 0.1:
|
||||
dna.append(false)
|
||||
else:
|
||||
dna.append(true)
|
||||
|
||||
func sum(a):
|
||||
var sum = 0
|
||||
for i in range(a.size()):
|
||||
sum += a[i]
|
||||
return sum
|
||||
|
||||
func describe():
|
||||
var TRAIT_DESC = "Has a %s trait of tier %d."
|
||||
var LATENT_DESC = " latent tier %d trait."
|
||||
|
||||
var d = 0
|
||||
var found_trait = false
|
||||
for i in range(TRAITS.size()):
|
||||
found_trait = false
|
||||
for j in range(TRAITS.values()[i].size()):
|
||||
for x in range(TRAITS.values()[i][j]):
|
||||
if !found_trait && dna[d]:
|
||||
print(TRAIT_DESC % [TRAITS.keys()[i], j+1])
|
||||
found_trait = true
|
||||
elif found_trait && dna[d]:
|
||||
print(LATENT_DESC % [j+1])
|
||||
d += 1
|
||||
var strand = ""
|
||||
for i in range(dna.size()):
|
||||
if dna[i]:
|
||||
strand += "1"
|
||||
else:
|
||||
strand += "0"
|
||||
print(strand)
|
||||
print(TIERS_STRING)
|
||||
print(TRAIT_STRING)
|
||||
|
||||
func _ready():
|
||||
print(naampje)
|
||||
initialize()
|
||||
print(dna.size())
|
||||
|
||||
#Register the selection event
|
||||
get_node("Area").connect('input_event', get_parent(), 'select_a_bitch', [get_index()])
|
||||
pass
|
||||
+31
-8
@@ -2,19 +2,20 @@ extends Node
|
||||
export (PackedScene) var Creature
|
||||
|
||||
var selected = []
|
||||
var rng = RandomNumberGenerator.new()
|
||||
|
||||
func _ready():
|
||||
rng.randomize()
|
||||
pass
|
||||
|
||||
func spawn_a_bitch():
|
||||
# Maak een bitch
|
||||
var c = Creature.instance()
|
||||
add_child(c)
|
||||
|
||||
# Geef de bitch een random positie en rotatie
|
||||
c.rotate_y(rand_range(-5, 5))
|
||||
c.transform = Transform(c.transform.basis, Vector3(rand_range(-7, 7), 0, rand_range(-5, 5)))
|
||||
# print_tree ( )
|
||||
return c
|
||||
|
||||
func kill_a_bitch():
|
||||
var c = get_child(get_child_count()-1)
|
||||
@@ -22,13 +23,35 @@ func kill_a_bitch():
|
||||
c.queue_free()
|
||||
#remove_child(c)
|
||||
|
||||
func combine_a_bitch():
|
||||
if selected.size() == 2:
|
||||
var new_dna = []
|
||||
for i in range(selected[0].dna.size()):
|
||||
if rng.randf() > 0.5:
|
||||
new_dna.append(selected[0].dna[i])
|
||||
else:
|
||||
new_dna.append(selected[1].dna[i])
|
||||
var new_child = spawn_a_bitch()
|
||||
new_child.dna = new_dna
|
||||
deselect_all()
|
||||
select(new_child)
|
||||
new_child.describe()
|
||||
|
||||
func deselect_all():
|
||||
for i in range(selected.size()):
|
||||
selected[i].get_node("SelectionIndicator").visible = false;
|
||||
selected = []
|
||||
|
||||
func select(creature):
|
||||
if selected.has(creature):
|
||||
creature.get_node("SelectionIndicator").visible = false;
|
||||
selected.erase(creature)
|
||||
else:
|
||||
selected.append(creature)
|
||||
creature.get_node("SelectionIndicator").visible = true;
|
||||
|
||||
func select_a_bitch(camera, event, click_position, click_normal, index, creature_id):
|
||||
if event.is_action_pressed("select_creature"):
|
||||
var kindeke = get_child(creature_id)
|
||||
if selected.has(creature_id):
|
||||
kindeke.get_node("SelectionIndicator").visible = false;
|
||||
selected.erase(creature_id)
|
||||
else:
|
||||
selected.append(creature_id)
|
||||
kindeke.get_node("SelectionIndicator").visible = true;
|
||||
select(kindeke)
|
||||
print(creature_id)
|
||||
@@ -67,6 +67,12 @@ margin_bottom = 69.0975
|
||||
shortcut_in_tooltip = false
|
||||
text = "Kill a bitch"
|
||||
|
||||
[node name="Button" type="Button" parent="GUI/Control"]
|
||||
margin_left = 500.0
|
||||
margin_top = 50.0
|
||||
margin_right = 73.0
|
||||
text = "Combine!"
|
||||
|
||||
[node name="Log" type="Label" parent="GUI"]
|
||||
anchor_bottom = 1.0
|
||||
margin_bottom = -586.0
|
||||
@@ -83,3 +89,4 @@ Creature = ExtResource( 2 )
|
||||
environment = SubResource( 3 )
|
||||
[connection signal="pressed" from="GUI/Control/Spawn" to="CreatureLab" method="spawn_a_bitch"]
|
||||
[connection signal="pressed" from="GUI/Control/Kill" to="CreatureLab" method="kill_a_bitch"]
|
||||
[connection signal="pressed" from="GUI/Control/Button" to="CreatureLab" method="combine_a_bitch"]
|
||||
|
||||
Reference in New Issue
Block a user