Skip to main content
Engineering LibreTexts

9.13: Starting Off with Some Grass

  • Page ID
  •     # start off with some random grass images on the screen
        for i in range(10):
            grassObjs.append(makeNewGrass(camerax, cameray))
            grassObjs[i]['x'] = random.randint(0, WINWIDTH)
            grassObjs[i]['y'] = random.randint(0, WINHEIGHT)

    The active area should start off with a few grass objects visible on the screen. The makeNewGrass() function will create and return a grass object that is randomly located somewhere in the active area but outside the camera view. This is what we normally want when we call makeNewGrass(), but since we want to make sure the first few grass objects are on the screen, the X and Y coordinates are overwritten.

    • Was this article helpful?