# Obeleži sve kategorije koje odgovaraju problemu

### Još detalja - opišite nam problem

Uspešno ste prijavili problem!
Status problema i sve dodatne informacije možete pratiti klikom na link.
Nažalost nismo trenutno u mogućnosti da obradimo vaš zahtev.
Molimo vas da pokušate kasnije.

#### Programming in Python, handbook

Drawing basic shapes can be fun and sometimes challenging. Still, it would be even more fun to be able to combine our drawing with ready-made pictures or photos. In PyGame environment this is very simple. Let’s look at the following example:

We have two new PyGame functions in this program:

• Function pg.image.load loads the image from the disk. We pass the name of the file containing the image to this function (path to the file may be included), and as a result it returns the image in a format suitable for program. We should save that result in some variable (in the example it is the variable tree_image);

• Function blit displays an image in a given window. Arguments of this function are a variable containing the image (result of function pg.image.load) and position $$(x, y)$$ in the window where we want the image to appear. At the position we set, the upper left corner of the image will appear. In the example, we set the position $$(0, 0)$$, so the upper left corner of the image appears in the upper left corner of the window.

Try typing different coordinate values instead of $$(0, 0)$$ to get a better understanding of how the blit function works. We can observe that displaying ready-made images is similar to displaying movable drawings using an anchor.

You can also try displaying one image in multiple places on the screen, as we did with basic shapes. Just call the blit function multiple times, with different values for the display location.

When displaying an image in multiple places, the images may overlap. Therefore, care must be taken of the order of displaying. In our case, we should first show the tree we imagine as further, and then the tree we imagine as closer. Otherwise the final scene may seem wrong, as the following picture shows.

The objects we perceive as further are usually in the upper part of the image, which means that they have a smaller $$y$$ coordinate, though this may not always be true. In this and similar examples it will be enough to stick to this simple rule: it is better to first display objects with smaller $$y$$ coordinate.

In the following program, correct the order of tree positions in the list, and then add a statement to draw a tree at position (x, y) in the loop.

Finish the program by drawing the tree with the apples (as in the example).

After you finish the program, you can also try modifying the program to display an apple tree 100 pixels to the right and 50 pixels lower.