COMPLETED FEATURES: Custom Sprite Integration: - Player, Zombie, Merchant sprites (0.2 scale) - 11 custom sprites + 5 asset packs loaded - Auto-transparency processing (white/brown removal) - Gravestone system with atlas extraction 2.5D Minecraft-Style Terrain: - Volumetric blocks with 25px thickness - Strong left/right side shading (30%/50% darker) - Minecraft-style texture patterns (grass, dirt, stone) - Crisp black outlines for definition Y-Layer Stacking System: - GRASS_FULL: All green (elevation > 0.7) - GRASS_TOP: Green top + brown sides (elevation 0.4-0.7) - DIRT: All brown (elevation < 0.4) - Dynamic terrain depth based on height Floating Island World Edge: - Stone cliff walls at map borders - 2-tile transition zone - Elevation flattening for cliff drop-off effect - 100x100 world with defined boundaries Performance & Polish: - Canvas renderer for pixel-perfect sharpness - CSS image-rendering: crisp-edges - willReadFrequently optimization - No Canvas2D warnings Technical: - 3D volumetric trees and rocks - Hybrid rendering (2.5D terrain + 2D characters) - Procedural texture generation - Y-layer aware terrain type selection
62 lines
1.5 KiB
JavaScript
62 lines
1.5 KiB
JavaScript
class ObjectPool {
|
|
constructor(createFn, resetFn) {
|
|
this.createFn = createFn; // Funkcija za kreiranje novega objekta
|
|
this.resetFn = resetFn; // Funkcija za resetiranje objekta pred ponovno uporabo
|
|
this.active = []; // Aktivni objekti
|
|
this.inactive = []; // Neaktivni objekti (v poolu)
|
|
}
|
|
|
|
// Dobi objekt iz poola
|
|
get() {
|
|
let item;
|
|
if (this.inactive.length > 0) {
|
|
item = this.inactive.pop();
|
|
} else {
|
|
item = this.createFn();
|
|
}
|
|
|
|
// Resetiraj objekt (npr. nastavi visible = true)
|
|
if (this.resetFn) {
|
|
this.resetFn(item);
|
|
}
|
|
|
|
this.active.push(item);
|
|
return item;
|
|
}
|
|
|
|
// Vrni objekt v pool
|
|
release(item) {
|
|
const index = this.active.indexOf(item);
|
|
if (index > -1) {
|
|
this.active.splice(index, 1);
|
|
this.inactive.push(item);
|
|
}
|
|
}
|
|
|
|
// Vrni vse aktivne v pool
|
|
releaseAll() {
|
|
while (this.active.length > 0) {
|
|
const item = this.active.pop();
|
|
this.inactive.push(item);
|
|
}
|
|
}
|
|
|
|
// Počisti vse
|
|
clear() {
|
|
this.active = [];
|
|
this.inactive = [];
|
|
}
|
|
|
|
// Info
|
|
getStats() {
|
|
return {
|
|
active: this.active.length,
|
|
inactive: this.inactive.length,
|
|
total: this.active.length + this.inactive.length
|
|
};
|
|
}
|
|
}
|
|
|
|
// Ensure global access
|
|
window.ObjectPool = ObjectPool;
|