$$ \newcommand{\floor}[1]{\left\lfloor{#1}\right\rfloor} \newcommand{\ceil}[1]{\left\lceil{#1}\right\rceil} \renewcommand{\mod}{\,\mathrm{mod}\,} \renewcommand{\div}{\,\mathrm{div}\,} \newcommand{\metar}{\,\mathrm{m}} \newcommand{\cm}{\,\mathrm{cm}} \newcommand{\dm}{\,\mathrm{dm}} \newcommand{\litar}{\,\mathrm{l}} \newcommand{\km}{\,\mathrm{km}} \newcommand{\s}{\,\mathrm{s}} \newcommand{\h}{\,\mathrm{h}} \newcommand{\minut}{\,\mathrm{min}} \newcommand{\kmh}{\,\mathrm{\frac{km}{h}}} \newcommand{\ms}{\,\mathrm{\frac{m}{s}}} \newcommand{\mss}{\,\mathrm{\frac{m}{s^2}}} \newcommand{\mmin}{\,\mathrm{\frac{m}{min}}} \newcommand{\smin}{\,\mathrm{\frac{s}{min}}} $$

Prijavi problem


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.

Displaying ready-made images - tasks

We learned how to display a ready-made image so that its upper left corner is at a given position on the screen. In some situations, the position of the upper left corner of the image will not be known to us, but will need to be calculated. In such cases, it may be necessary to know the width and height of the image. In Python’s PyGame library for the image im, the width and height of this image are given as im.get_width() and im.get_height() respectively.

Baskets

Complete the following program to get the picture as in the example. The positions of the trees are given, and a basket should be drawn next to each tree so that the lower right corners of the basket and tree images overlap.

To complete this task, you need to calculate for each drawn basket the position of its top left corner, which can be done starting from the coordinates of the top left corner of the tree, using the widths and heights of both images.

../_images/tree.png ../_images/apple_small.png ../_images/basket.png

Picking apples

Complete the following program to get the picture as in the example. The solution to this task is obtained by appending the previous program - copy it and add apples to the trees and to the baskets.

Boxes

Write programs that use the image of one box shown below,

../_images/box.png

and form images as in examples (use the “Play task” button in each task).

The coordinates of the image, that is, its upper left corner for the leftmost box are (60, 400) and for the highest box are (420, 115).

From the given data and images it is possible to determine the series x and y of the image coordinates of each box in each example. The order of displaying of the box pictures should also be taken into account here.

To better understand how the same series of numbers (for example, 10, 15, 20, 25, 30) can be obtained in two different orders, and what else to look for, answer the supporting question.

    Match a series of numbers with the statements that generate them. Try again.
  • 10, 15, 20, 25, 30
  • for x in range(10, 35, 5)
  • 30, 25, 20, 15, 10
  • for x in range(30, 5, -5)
  • empty series
  • for x in range(30, 10, 5)
  • 5, 15, 25
  • for x in range(5, 35, 10)