Grow Columns

Imagine we are old time farmers, we have some planting work to do.

(Make sure the terminating condition is related to the updating variable, otherwise, your program might never end. To stop them, reload the page.)

plant_colX

Let's put up some columns along x line, expect them appear one after another:

# plant_colX
def plant_colX(x,z,h):
  column(x, z, h, 'leaves')
  if x < 10:
    game.set_timer(1, plant_colX, x+2, z, h)
plant_colX(0, -10, 5)

A line of green columns come out one by one, totally 6 columns.

plant_colZ, some columns pop up along z direction:

# plant_colZ
def plant_colZ(x,z,h):
    column(x, z, h, 'box_red')
    if z < 0:     
        game.set_timer(2, plant_colZ, x, z+2, h)

Get taller!

Here is a column that grows taller:

taller_col

# taller_col
def taller_col(x,z,h):
  column(x,z,h, 'box_green')

  if h < 20:
    game.set_timer(0.5, taller_col, x, z, h+2)

taller_col(-5, -10, 3)

plant_gold

Guess what we are planting next? Which way do they go?

# plant_gold
def plant_gold(x,z,h):
    column(x,z,h, 'gold')
    if h <10:     
        game.set_timer(1, plant_gold, x+2, z+2, h+1)

plant_gold(0, -20, 2)

Gold Bars! And they are getting taller!

Run the program and see the animation yourself.

Enjoy the show!

results matching ""

    No results matching ""