views:

251

answers:

2

How would I load certain images into an array set like

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

I can put

images into variables like so

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

so whould I be able to do something like Map = ( ( one, one, one ) )

and if each image was 32x32 would it be able to be side by side rather then a pixal ahead

Sorry im still learning and trying to go over some basics in my hea

A: 

It sounds like you're wanting to build a tile map for a 2D game. In that case, you would want to have a single sprite containing all of your tiles. The map would then contain indices for specific tiles.

When it comes time to drawing the tiles, you'd copy portions of the sprite based on the tile index.

If you had a sprite image with tiles indexed as follows:

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

You could use someting like this to calculate the rectagle to copy 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);
Brandon Gano
+1  A: 

Seems to be that you use C++ OldSchool Library for PSP. According to its documentation you should create one image file which should contain set of images and then you'll be able to create 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 a very limited usage and it will be a good idea to ask your question on its forum.

Kirill V. Lyadvinsky