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
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.
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.
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.
- 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)