start turret
This commit is contained in:
18
tiles/tile.c
18
tiles/tile.c
@@ -9,6 +9,7 @@
|
||||
#include "../util/atlas.h"
|
||||
#include "../util/font.h"
|
||||
#include "miner.h"
|
||||
#include "turret.h"
|
||||
|
||||
int scrollFrame = 0;
|
||||
unsigned long beltFrames = 0;
|
||||
@@ -80,7 +81,7 @@ void registerTile(char fname[20], SDL_Renderer *renderer) {
|
||||
|
||||
// Load animation frames
|
||||
int frame = 0;
|
||||
int indexTile = 0;
|
||||
ItemType indexTile = 0;
|
||||
char texturePath[80];
|
||||
|
||||
if (sscanf(fname, "%d_%20[^_]_%d.png", &indexTile, name, &frame) == 3) {
|
||||
@@ -111,12 +112,13 @@ void registerTile(char fname[20], SDL_Renderer *renderer) {
|
||||
createRotatedTexture(renderer, texture, 270)
|
||||
};
|
||||
|
||||
printf("Bound %s to %d orient %s\n", fname, indexTile, OrientStrings[o]);
|
||||
// printf("Bound %s to %d orient %s\n", fname, indexTile, OrientStrings[o]);
|
||||
TileRegistry[indexTile].animation.textures[o][frame] = textures[o];
|
||||
SDL_SetTextureBlendMode(textures[o], SDL_BLENDMODE_BLEND);
|
||||
TileRegistry[indexTile].animation.atlasRects[o][frame] = allocate_32x32(textures[o], renderer);
|
||||
}
|
||||
|
||||
printf("Bound %s to %d\n", fname, indexTile);
|
||||
TileRegistry[indexTile].type = indexTile;
|
||||
TileRegistry[indexTile].maxHealth = 200;
|
||||
TileRegistry[indexTile].animation.frameCount = frame + 1;
|
||||
@@ -155,7 +157,7 @@ void registerBackgroundTile(char fname[20], SDL_Renderer *renderer) {
|
||||
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE);
|
||||
|
||||
printf("Bound %s to %d\n", fname, indexBgTile);
|
||||
//printf("Bound %s to %d\n", fname, indexBgTile);
|
||||
|
||||
BackgroundTileRegistry[indexBgTile].animation.textures[frame] = texture;
|
||||
BackgroundTileRegistry[indexBgTile].animation.atlasRects[frame] = allocate_32x32(texture, renderer);
|
||||
@@ -261,7 +263,7 @@ void setupTiles() {
|
||||
for (uint16_t i = 0; i < ItemSlotCount; i++) {
|
||||
TileRegistry[TYPE_BELT].outputLane[i] = true;
|
||||
}
|
||||
for (uint16_t l = 0; l < ItemSlotCount; l++) {
|
||||
for (uint16_t l = 0; l < 2; l++) {
|
||||
for (ItemType i = 0; i < itemRegistryIndex; i++) {
|
||||
TileRegistry[TYPE_BELT].allowedInItems[l][i] = true;
|
||||
}
|
||||
@@ -272,7 +274,7 @@ void setupTiles() {
|
||||
TileRegistry[TYPE_FURNACE].allowedInItems[FURNACE_INPUT_SLOT][i] = true;
|
||||
}
|
||||
}
|
||||
TileRegistry[TYPE_FURNACE].outputLane[FURNACE_OUTPUT_SLOT] = 1;
|
||||
; TileRegistry[TYPE_FURNACE].outputLane[FURNACE_OUTPUT_SLOT] = 1;
|
||||
TileRegistry[TYPE_FURNACE].startFrame = 1;
|
||||
TileRegistry[TYPE_FURNACE].needsTicks = true;
|
||||
TileRegistry[TYPE_FURNACE].animation.divisor = 8;
|
||||
@@ -283,6 +285,9 @@ void setupTiles() {
|
||||
TileRegistry[TYPE_MINER].startFrame = 1;
|
||||
TileRegistry[TYPE_AIR].walkable = true;
|
||||
|
||||
TileRegistry[TYPE_TURRET].needsTicks = true;
|
||||
TileRegistry[TYPE_TURRET].allowedInItems[TURRET_AMMO_INPUT_SLOT][IRON_INGOT] = true;
|
||||
|
||||
BackgroundTileRegistry[BGType_WATER_DEEP].animation.divisor = 16;
|
||||
BackgroundTileRegistry[BGType_WATER_SHALLOW].animation.divisor = 12;
|
||||
BackgroundTileRegistry[BGType_GRASS_FLOWER0].animation.divisor = 16;
|
||||
@@ -450,6 +455,9 @@ void renderAllTiles(SDL_Renderer *renderer, SDL_Rect playerRect) {
|
||||
}
|
||||
|
||||
bool isWalkable(MiniRect tileCoords) {
|
||||
if (tileCoords.x < 0 || tileCoords.x >= MAP_WIDTH || tileCoords.y < 0 || tileCoords.y >= MAP_HEIGHT) {
|
||||
return false;
|
||||
}
|
||||
BackgroundTileType bgt = BackgroundTileRegistry[backgroundMap[tileCoords.y][tileCoords.x].type];
|
||||
TileTypeReg fgt = TileRegistry[tileMap[tileCoords.y][tileCoords.x].type];
|
||||
|
||||
|
Reference in New Issue
Block a user