SGDK. Creating image.

Import the picture into SGDK.

First of all, download the basis of our project.

  1. Now, download the picture from MEGA.
  2. then create a text file resources.res

Place them in the resf older, in the directory of your project. All SGDK resources, such as music, images, we will put in the res folder.

Inside resources.res, write the following.

IMAGE img "image.png" BEST

The syntax here is as follows

Type name "path_to_file" compression_type

I.e. to the image image.png we will refer to in the code by the name img, the compression chose the best BEST.

You can learn more about resources in recomp.txtlocated in SGDKbin

Write the code.

Now, in main.c write the following code.

#include <genesis.h>
#include "resources.h"

int main()
{
    VDP_drawImage(BG_A, &img, 0, 0);
    while(1)
    {
        VDP_waitVSync();
    }
    return (0);
}</genesis.h>

Let’s analyze the code.

#include "resources.h"

resources.h is created automatically during the compilation process, we imported it and now, we have access to resources.

VDP_drawImage(BG_A, &img, 0, 0);

VDP_drawImage – draws an image on the screen, the syntax is as follows.

VDP_drawImage (layer, image, tile_x, tile_y);
  • layer – indicates the layer on which the image is installed (BG_A or BG_B)
  • image – the object of the image, the name of which we specified in resources.res
  • tile_x, tile_y – coordinates of the image on the tile grid (1 tile = 8×8 px)

Next, start an endless cycle.

while(1)
{
  VDP_waitVSync();
}

Now compile (run the compile.batfile). And run the rum, you should get the following.

Create your own image.

Sega Genesis is able to store 4 palettes of 16 colors. This means that we will need images, with a palette of 16 colors.

To create an image, we need paint.net. Draw there an image with a resolution of 320×240 (Sega Genesis resolution), and save to png. In the Save Options window, select a color depth of 4 bits,so the image palette will be reduced to 16 colors. And click OK.

Final result.

Пожалуйста отключи блокировщик рекламы, или внеси сайт в белый список!

Please disable your adblocker or whitelist this site!