Skip to content

exercise_5

bjornstahl edited this page Oct 14, 2021 · 2 revisions

Exercise 5

As shown in the first exercise set, images can have a text based backing store, an image based backing store, or a simple colour. The 'backing store' though is not strictly coupled to one video object, they are reference counted and can be shared.

Sharing image stores is a very simple yet efficient way of reducing memory use and to make drawing more efficient as it reduces the number of state transitions that are needed to render something.

1 - Share that Storage

Load an image asynchronously from a file. Create a null_surface and print the results from using image_matchstore on these two objects. Then use image_sharestorage and repeat the comparison. Then Create a _tick event handler and destroy the loaded image after a certain number of ticks.

For some extra fun, try sharing WORLDID to the null surface.

2 - Check your coordinates

Load an image asynchronously from a file, preferably one with the picture of a dog or something equally awesome and easy to see. Create 3 other null surfaces that share storage with the image when loaded. Position them so that there is a one pixel gap. Split it up so that the each surface shows a different quadrant of the same source.

Hint: image_set_txcos is your friend.

3 - I have been framed

Start with 4 fill_surface colored boxes, keep them invisible. Create and show a null_surface and use image_framesetsize along with set_image_as_frame attached to populate the different slots.

4 Cycle harder

Continue with the frameset from exercise three. Add an input handler that uses the arrow keys to interactively step which the active frame is. Look at image_active_frame.

5 Automatic Cycling

Continue with the frameset from exercise three. Try and use image_framecyclemode to make it animate automatically.

6 Oh Sheet!

Time to combine the lessons learned so far. Scour the internet for a 'sprite sheet' in a friendly image format but as a single image file. Try and convert that image into a correctly animated cycle.