Mountain flower grove


#1

it keeps saying goals ran out of time and i dont think it made 1,000 fowers

# TEXT TO WRITE
text = "five wixen"

#self.setFlowerColor("red")
# options: "random" (default), "pink", "red", "blue", "purple", "yellow" or "white"

# settings
start = Vector(10, 90)
fontHeight  = 20
fontWidth   = fontHeight * 1/2
fontSpacing = fontWidth  * 1/4
lineSpacing = fontHeight * 1/5

# vector fontset - INCOMPLETE
fontSet = {
    # font format:
    # "letter": [ (nextPosX, nextPosY, draw), ... ]
    # note: 'draw' is optional, if it's not defined, the last value is used (= unchanged)
    "A": [ (0, 0, 0), (1/2, 1, 1), (1, 0, 1), (5/6, 1/3, 0), (1/6, 1/3, 1) ],
    "B": [ (0, 0, 0), (0, 1, 1), (3/4, 1, 1), (1, 5/6, 1), (1, 4/6, 1),  (5/6, 1/2, 1), (0, 1/2, 1), (5/6, 1/2, 0), (1, 2/6, 1), (1, 1/6, 1), (5/6, 0, 1), (0, 0, 1) ],
#   'lazy' format example:
#    "B": [(0, 0, 0), (0, 1, 1), (3/4, 1), (1, 5/6), (1, 4/6), (5/6, 1/2), (0, 1/2), (5/6, 1/2, 0), (1, 2/6, 1), (1, 1/6), (5/6, 0), (0, 0)],
#    "C": [ (, , ) ],
#    "D": [ (, , ) ],
    "E": [ (1, 0, 0), (0, 0, 1), (0, 1, 1), (1, 1, 1), (0, 1/2, 0), (3/4, 1/2, 1) ],
    "F": [ (0, 0, 0), (0, 1, 1), (1, 1, 1), (0, 1/2, 0), (3/4, 1/2, 1) ],
#    "G": [ (, , ) ],
    "H": [ (0, 0, 0), (0, 1, 1), (0, 1/2, 0), (1, 1/2, 1), (1, 1, 0), (1, 0, 1) ],
    "I": [ (0, 0, 0), (0, 1, 1) ],
#    "J": [ (, , ) ],
    "K": [ (0, 0, 0), (0, 1, 1), (0, 1/2, 0), (1, 1, 1), (0, 1/2, 0), (1, 0, 1) ],
    "L": [ (0, 1, 0), (0, 0, 1), (1, 0, 1) ],
    "M": [ (0, 0, 0), (0, 1, 1), (1/2, 1/2, 1), (1, 1, 1), (1, 0, 1)],
    "N": [ (0, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 1) ],
#    "O": [ (, , ) ],
#    "P": [ (, , ) ],
#    "Q": [ (, , ) ],
#    "R": [ (, , ) ],
#    "S": [ (, , ) ],
    "T": [ (0, 1, 0), (1, 1, 1), (1/2, 1, 0), (1/2, 0, 1) ],
#    "U": [ (, , ) ],
    "V": [ (0, 1, 0), (1/2, 0, 1), (1, 1, 0) ],
    "W": [ (0, 1, 0), (1/3, 0, 1), (2/3, 1/2, 1), (1, 0, 1), (4/3, 1, 1) ],
    "X": [ (0, 0, 0), (1, 1, 1), (0, 1, 0), (1, 0, 1) ],
    "Y": [ (0, 1, 0), (1/2, 1/2, 1), (1, 1, 1), (1/2, 1/2, 0), (1/2, 0, 1) ],
    "Z": [ (0, 1, 0), (1, 1, 1), (0, 0, 1), (1, 0, 1) ],
    " ": [ (1, 0, 0) ]
    }

# make text uppercase
text = text.toUpperCase()              # workaround for 'text.upper()'

self.toggleFlowers(False)              # turn off flowers at start


# draw a letter
def writeLetter(char):
    if char not in fontSet:
        self.say("Letter " + char + " is not defined!")
        return
    
    corner = Vector(self.pos.x, baseLine)
    maxWidth = 0
    
    for point in fontSet[char]:
        #self.say(point)
#        # turn flowers on/off
#        self.toggleFlowers(point[2])
        if len(point) > 2:
            if point[2]:    # == 1
                self.toggleFlowers(True)
            else:           # == 0
                self.toggleFlowers(False)
        
        # draw next segment
        self.moveXY(corner.x + point[0] * fontWidth, corner.y + point[1] * fontHeight)
        # proportional font support
        if point[0] > maxWidth:
            maxWidth = point[0]
    
    self.toggleFlowers(False)
    self.moveXY(corner.x + maxWidth * fontWidth + fontSpacing, corner.y)


#### main() ####
self.say("I will write: " + text)

self.moveXY(start.x, start.y)          # move to starting position
baseLine = start.y

for i in range(len(text)):
    self.say(text[i])
    writeLetter(text[i])

#2

I recommend drawing something for your own purposes.
Just a quick glance suggests you’re trying to write letters that aren’t accounted for in the font set.
That’ll only waste time.

If your only purpose is to hit 1000 flowers, try playing with the shapes you already have sorted out.

If you instead want to help complete the font set… Look at all of the letters which are commented out, make them work, or avoid using them in your sentence.


#3

The code you copied from the forums was to write letters, not to pass the level. If you want to pass the level just walk around a lot.


#4

well it crashed for me:neutral_face:


#5

Ant’s letter writing code or the level in general? It took me a few times to beat on my computer just because it crashed the first few times. All those flowers are hard on the memory :slightly_smiling:


#6

You what lots of flowers? Walk like this using 2 nested “for” loops:
Stop copying code to “solve” it, you are not learning from it.
Googling code to “understand” is ok, as long you re-write the code all by yourself to make you understood the solution.

/--\  /--\
|  |  |  |
|  |  |  |
|  |  |
|  \--/

#7

Im going to just walk around what kind of 'loops" do you think I should do


#8

Nvm I beat it next level