88 lines
1.8 KiB
C
88 lines
1.8 KiB
C
|
#include "bmpload.h"
|
||
|
#include "const.h"
|
||
|
#include "arena.h"
|
||
|
|
||
|
char arenaLayout[10][10] = {
|
||
|
{ 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 },
|
||
|
{ 1, 2, 2, 2, 0, 0, 2, 2, 2, 1 },
|
||
|
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||
|
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||
|
{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 2 },
|
||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||
|
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||
|
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||
|
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||
|
{ 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 }
|
||
|
};
|
||
|
|
||
|
struct SpriteRender arenaWallTop, arenaWallSide, arenaFloor;
|
||
|
|
||
|
void setupWallSprites(struct BMPImage *spritesheetImage) {
|
||
|
buildSpriteFromSpritesheet(
|
||
|
spritesheetImage,
|
||
|
&arenaWallTop,
|
||
|
0, 0, 20, 20
|
||
|
);
|
||
|
|
||
|
buildSpriteFromSpritesheet(
|
||
|
spritesheetImage,
|
||
|
&arenaWallSide,
|
||
|
20, 0, 20, 20
|
||
|
);
|
||
|
|
||
|
buildSpriteFromSpritesheet(
|
||
|
spritesheetImage,
|
||
|
&arenaFloor,
|
||
|
40, 0, 20, 20
|
||
|
);
|
||
|
}
|
||
|
|
||
|
void renderArenaTile(int x, int y) {
|
||
|
char tile;
|
||
|
struct SpriteRender *target;
|
||
|
|
||
|
tile = arenaLayout[y][x];
|
||
|
|
||
|
switch (tile) {
|
||
|
case 0:
|
||
|
target = &arenaFloor;
|
||
|
break;
|
||
|
case 1:
|
||
|
target = &arenaWallTop;
|
||
|
break;
|
||
|
case 2:
|
||
|
target = &arenaWallSide;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
target->x = x * 20;
|
||
|
target->y = y * 20;
|
||
|
|
||
|
drawSprite(target);
|
||
|
}
|
||
|
|
||
|
void drawOnlyArena(struct SpriteBounds *bounds) {
|
||
|
int leftTileX, rightTileX,
|
||
|
topTileY, bottomTileY;
|
||
|
|
||
|
leftTileX = bounds->left / TILE_SIZE;
|
||
|
rightTileX = bounds->right / TILE_SIZE;
|
||
|
topTileY = bounds->top / TILE_SIZE;
|
||
|
bottomTileY = bounds->bottom / TILE_SIZE;
|
||
|
|
||
|
renderArenaTile(leftTileX, topTileY);
|
||
|
renderArenaTile(rightTileX, topTileY);
|
||
|
renderArenaTile(rightTileX, bottomTileY);
|
||
|
renderArenaTile(leftTileX, bottomTileY);
|
||
|
}
|
||
|
|
||
|
void buildArena() {
|
||
|
int x, y;
|
||
|
|
||
|
for (y = 0; y < 10; ++y) {
|
||
|
for (x = 0; x < 10; ++x) {
|
||
|
renderArenaTile(x, y);
|
||
|
}
|
||
|
}
|
||
|
}
|