Brandling Safari: LAN safari-zone creature catching on the HD-2D engine
- Authoritative 30 Hz server (ENet, SQLite): accounts, characters, wild AI, tall grass / water / wandering spawns, fishing, captures, follower chains, clock + weather, LAN beacon - Client: title / join / character creator / play screens, prediction + reconciliation, interpolated players and parties, HD-2D UI (dialogue with Professor Henry, HUD, collection) - Shared deterministic zone generator, movement, protocol, roster, appearance - Paper-doll character art pipeline (PixelLab base walk + per-item animation edits) - Brandling roster from the company list (logo colors, jev types), Blender safari props - Headless test bot
This commit is contained in:
49
client/CharacterSprite.h
Normal file
49
client/CharacterSprite.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
// Paper-doll compositor for player sprites. Every body and item is a sheet of
|
||||
// identical frame layout (3 direction rows x [standing, walk 0..3], 64 px
|
||||
// cells) made of a recolorable shade layer plus fixed-color pixels, so any
|
||||
// look is composed on the CPU in a few milliseconds without new art.
|
||||
// Mirrors tools/character_compose.py.
|
||||
|
||||
#include "Appearance.h"
|
||||
|
||||
#include "hd2d/Texture.h"
|
||||
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace bs {
|
||||
|
||||
// Shade 1 (darkest) .. 4 (highlight) of a base color; matches ramp() in tools/character_compose.py.
|
||||
std::array<uint32_t, 4> colorRamp(uint32_t rgb);
|
||||
|
||||
class CharacterArt {
|
||||
public:
|
||||
bool load(const std::string& charDir, const CharacterManifest& manifest);
|
||||
// Full sprite sheet for a look (GL orientation, same layout as the source sheets).
|
||||
hd2d::Image compose(const Appearance& look) const;
|
||||
const CharacterManifest& manifest() const { return *manifest_; }
|
||||
|
||||
private:
|
||||
struct Layer {
|
||||
hd2d::Image shade, fixed; // either may be empty
|
||||
};
|
||||
struct Body {
|
||||
hd2d::Image fixed;
|
||||
Layer skin;
|
||||
std::map<std::string, Layer> items; // includes top_tee / bottom_shorts shade layers
|
||||
};
|
||||
std::map<std::string, Body> bodies_;
|
||||
const CharacterManifest* manifest_ = nullptr;
|
||||
};
|
||||
|
||||
// Sheet layout helpers shared by players and NPCs.
|
||||
struct SheetLayout {
|
||||
int cell = 64, framesPerDir = 5, walkFrames = 4;
|
||||
// Direction row for a facing relative to the camera; `flip` mirrors east into west.
|
||||
// relYaw: facing yaw minus camera yaw (0 = walking away from the camera).
|
||||
static int rowFor(float relYaw, bool& flip);
|
||||
};
|
||||
|
||||
} // namespace bs
|
||||
Reference in New Issue
Block a user