experiments
This commit is contained in:
44
tiles/miner.c
Normal file
44
tiles/miner.c
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Created by bruno on 2.6.2025.
|
||||
//
|
||||
|
||||
#include "miner.h"
|
||||
#include "tile.h"
|
||||
#include "../util/audio.h"
|
||||
|
||||
const ItemType MinerRecipes[TILEREGISTRY_SIZE] = {
|
||||
[BGType_IRON_ORE] = IRON_ORE,
|
||||
[BGType_SILVER_ORE] = SILVER_ORE,
|
||||
[BGType_GOLD_ORE] = GOLD_ORE,
|
||||
[BGType_PLATINUM_ORE] = PLATINUM_ORE
|
||||
};
|
||||
|
||||
|
||||
void updateMiner(Tile *tile) {
|
||||
ItemOnBelt *outItem = &tile->items[MINER_OUTPUT_SLOT];
|
||||
BackgroundType bgt = backgroundMap[tile->rect.y][tile->rect.x].type;
|
||||
ItemType targetOutItemType = MinerRecipes[bgt];
|
||||
Item targetOutItem = ItemRegistry[targetOutItemType];
|
||||
|
||||
if (targetOutItemType != TYPE_AIR && outItem->type == 0) {
|
||||
if (tile->miscVal == 0) {
|
||||
tile->audioCh = getAvailableChannel();
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].volume = 64;
|
||||
audioData.synthVoices[tile->audioCh].phase = 0;
|
||||
audioData.synthVoices[tile->audioCh].sourceRect.x = TILE_SIZE * tile->rect.x;
|
||||
audioData.synthVoices[tile->audioCh].sourceRect.y = TILE_SIZE * tile->rect.y;
|
||||
audioData.synthVoices[tile->audioCh].waveform = WAVE_NOISE;
|
||||
audioData.synthVoices[tile->audioCh].frequency = 400;
|
||||
}
|
||||
}
|
||||
if (outItem->type == 0 && ++tile->miscVal >= targetOutItem.miscVal) {
|
||||
if (tile->audioCh < NUM_SYNTH_VOICES) {
|
||||
audioData.synthVoices[tile->audioCh].volume = 0;
|
||||
}
|
||||
tile->miscVal = 0;
|
||||
outItem->type = targetOutItemType;
|
||||
outItem->offset = -0.5f;
|
||||
}
|
||||
}
|
||||
}
|
18
tiles/miner.h
Normal file
18
tiles/miner.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Created by bruno on 2.6.2025.
|
||||
//
|
||||
|
||||
#ifndef FACTORYGAME_MINER_H
|
||||
#define FACTORYGAME_MINER_H
|
||||
|
||||
#include "../items/item.h"
|
||||
#include "stdint.h"
|
||||
|
||||
extern const ItemType FurnaceRecipes[];
|
||||
|
||||
#define MINER_OUTPUT_SLOT 0
|
||||
|
||||
void updateMiner(Tile * tile);
|
||||
|
||||
|
||||
#endif //FACTORYGAME_MINER_H
|
@@ -7,6 +7,7 @@
|
||||
#include "furnace.h"
|
||||
#include "../util/atlas.h"
|
||||
#include "../util/font.h"
|
||||
#include "miner.h"
|
||||
|
||||
int scrollFrame = 0;
|
||||
unsigned long beltFrames = 0;
|
||||
@@ -145,6 +146,8 @@ void setupTiles() {
|
||||
TileRegistry[TYPE_FURNACE].outputLane[FURNACE_OUTPUT_SLOT] = 1;
|
||||
TileRegistry[TYPE_FURNACE].needsTicks = true;
|
||||
TileRegistry[TYPE_BELT].needsTicks = true;
|
||||
TileRegistry[TYPE_MINER].needsTicks = true;
|
||||
TileRegistry[TYPE_MINER].outputLane[MINER_OUTPUT_SLOT] = 1;
|
||||
}
|
||||
|
||||
uint16_t getBreakTime(int type) {
|
||||
|
@@ -4,10 +4,12 @@
|
||||
|
||||
#include "tilecallbacks.h"
|
||||
#include "furnace.h"
|
||||
#include "miner.h"
|
||||
|
||||
const UpdateTileCallback ItemTileCallbacks[TILEREGISTRY_SIZE] = {
|
||||
[TYPE_AIR] = NULL,
|
||||
[TYPE_BLOCK] = NULL,
|
||||
[TYPE_BELT] = updateBelt,
|
||||
[TYPE_FURNACE] = updateFurnace
|
||||
[TYPE_FURNACE] = updateFurnace,
|
||||
[TYPE_MINER] = updateMiner
|
||||
};
|
Reference in New Issue
Block a user