Explorar o código

Use random to generate bricks

DricomDragon %!s(int64=3) %!d(string=hai) anos
pai
achega
0e7fe49df6
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      godot/scripts/Grid.gd

+ 6 - 0
godot/scripts/Grid.gd

@@ -32,6 +32,11 @@ func generate_row():
 
 
 func generate_cell(x, y):
+	if randi() % 2 : # 50% of generation
+		build_brick(x, y)
+
+
+func build_brick(x, y):
 	set_cell(x, y, Tile.BRICK)
 	living_cells[Vector2(x, y)] = current_row
 
@@ -56,6 +61,7 @@ func move():
 
 
 func _ready():
+	randomize()
 	generate_and_move()