Loading an image into an array

How to load specific images into an array like

Map = ( ( 1, 1, 1 ), ( 2, 2, 2 ), ( 3, 3, 3 ) ) 

      

I can put

images to such variables

one = oslLoadImageFile ("one.png", OSL_IN_RAM, OSL_PF_5551);

so can i do something like Map = ((one, one, one))

and if each image were 32x32 it could be side by side and not in front in front

Sorry I'm still learning and trying to revisit some of the basics in my hea

-1


a source to share


2 answers


You seem to be using C ++ OldSchool Library for PSP. According to its documentation, you should create one image file which should contain a set of images, and then you can create a map with it.

//definition of the pointers towards our image
OSL_IMAGE *Zora_tileset;

//definition of the pointers towards our map
OSL_MAP *zora;


 Zora_tileset = oslLoadImageFile("tileset.png", OSL_IN_RAM, OSL_PF_5551);

 //check
 if (!Zora_tileset)
  oslDebug("Check if all the files are copied in the game folder.");

 //configuration of the map
 zora = oslCreateMap(
  Zora_tileset,     //Tileset
  Zora_map,     //Map
  16,16,      //Size of tiles
  64,65,      //Size of Map
  OSL_MF_U16);     //Format of Map

      



It looks like this library has very limited use and it would be a good idea to ask your question on the forum .

+1


a source


It looks like you want to build a tile map for a 2D game. In this case, you would like to have one sprite containing all of your fragments. The map will then contain indices for specific chunks.

When it comes time to draw the tiles, copy the parts of the sprite based on the tile index.

If you had a sprite image with the snippets below:



+---+---+---+---+
| 0 | 1 | 2 | 3 |
+---+---+---+---+
| 4 | 5 | 6 | 7 |
+---+---+---+---+
| 8 | 9 |
+---+---+

      

You can use someting like this to calculate the copy rectangle for each tile index:

const int TILE_SIZE = 32;
const int TILES_PER_ROW = 10;

int xCoordinate = TILE_SIZE * (tileIndex % TILES_PER_ROW);
int yCoordinate = TILE_SIZE * (tileIndex / 10);

Draw(tileSet, xCoordinate, yCoordinate, TILE_SIZE, TILE_SIZE);

      

0


a source







All Articles