Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Images and Sprites [1/8]


Images and Sprites

The type imageLoader can be used to load an external image. An URL is the only argument of initializer for type imageLoader

The getter .url from type imageLoader returns the image URL (the one given in the initializer).

The getter .isError from type imageLoader waits for the image to load. If the loading succeeds, it returns false. If it fails, it returns true.

The type image represents images.

The functional getter .getImage from type imageLoader returns the image if the loading has succeeded.

The member function .draw from type image draws the image to the screen. This member is actually a procedure, because it modifies the displayed output, but it is common to refer to procedures as “functions”. The argument is of type point2D, and it specifies the position on the screen where the top left corner of the image is to be placed. This member function does not return a value, which makes it a procedure.

In this program, the argument of member function .draw is given by the initializer of type point2D.

To make the zombie not leave a trail, clear the screen on each iteration of the for loop.

Loading...