-1

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

4

2 回答 2

1

似乎是您使用 C++ OldSchool Library for PSP。根据其文档,您应该创建一个包含一组图像的图像文件,然后您就可以使用它创建地图。

//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

看起来这个库的用途非常有限,在它的论坛上提问是个好主意。

于 2009-09-11T14:25:26.863 回答
0

听起来您想为 2D 游戏构建平铺地图。在这种情况下,您可能希望拥有一个包含所有图块的精灵。然后地图将包含特定图块的索引。

在绘制图块时,您将根据图块索引复制部分精灵。

如果您有一个精灵图像,其索引如下:

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

您可以使用类似这样的方法来计算要为每个图块索引复制的矩形:

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);
于 2009-06-26T01:16:43.990 回答