Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_iso_engine.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
45#ifndef NILOREA_ISOMETRIC_ENGINE
46#define NILOREA_ISOMETRIC_ENGINE
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
57#include "n_common.h"
58#include "n_log.h"
59
60/*---------------------------------------------------------------------------
61 * Ability flags (shared by both legacy MAP and new ISO_MAP)
62 *-------------------------------------------------------------------------*/
63
65#define WALK 1
67#define SWIM 2
69#define BLCK 3
70
71/*---------------------------------------------------------------------------
72 * Terrain transition bitmask definitions (Article 934)
73 *
74 * Edge bits represent which cardinal sides have a higher-priority terrain.
75 * Corner bits represent which diagonal neighbors have a higher-priority
76 * terrain (only when the adjacent edges do NOT have that terrain).
77 *-------------------------------------------------------------------------*/
78
80#define ISO_EDGE_W (1 << 0)
82#define ISO_EDGE_N (1 << 1)
84#define ISO_EDGE_E (1 << 2)
86#define ISO_EDGE_S (1 << 3)
88#define ISO_NUM_EDGE_MASKS 16
89
91#define ISO_CORNER_NW (1 << 0)
93#define ISO_CORNER_NE (1 << 1)
95#define ISO_CORNER_SE (1 << 2)
97#define ISO_CORNER_SW (1 << 3)
99#define ISO_NUM_CORNER_MASKS 16
101#define ISO_NUM_MASKS (ISO_NUM_EDGE_MASKS + ISO_NUM_CORNER_MASKS)
102
103/*---------------------------------------------------------------------------
104 * Projection presets
105 *-------------------------------------------------------------------------*/
106
108#define ISO_PROJ_CLASSIC 0
110#define ISO_PROJ_ISOMETRIC 1
112#define ISO_PROJ_MILITARY 2
114#define ISO_PROJ_STAGGERED 3
116#define ISO_NUM_PROJECTIONS 4
117
118/* Legacy aliases */
120#define ISO_PROJ_STEEP ISO_PROJ_ISOMETRIC
122#define ISO_PROJ_WIDE ISO_PROJ_STAGGERED
123
124/*---------------------------------------------------------------------------
125 * New height-aware isometric data structures (no Allegro dependency)
126 *-------------------------------------------------------------------------*/
127
129#define ISO_MAX_SEGMENTS_PER_TILE 2
130
138
145
148typedef struct ISO_DRAW_ENTRY {
149 int mx, my;
151 int bottom;
152 int top;
155
159typedef struct ISO_PROJECTION {
160 float half_w;
161 float half_h;
162 float angle_deg;
163 float tile_lift;
167
168/*---------------------------------------------------------------------------
169 * 2D Isometric Camera
170 *
171 * Manages camera position, zoom, and coordinate conversion between
172 * screen pixels and world coordinates. Works with iso_map_draw()
173 * and iso_screen_to_map_height() using the library coordinate system.
174 *-------------------------------------------------------------------------*/
175
177typedef struct N_ISO_CAMERA {
178 float x;
179 float y;
180 float zoom;
181 float zoom_min;
182 float zoom_max;
184
188typedef struct ISO_MAP {
189 int width;
190 int height;
194 int* terrain;
196 int* ability;
197 int* overlay;
202
205 /* --- rendering flags (used by iso_map_draw) --- */
212 /* --- height-based ambient tinting --- */
217 /* --- neighbor edge heights for chunked rendering --- */
226
232
238} ISO_MAP;
239
240/*---------------------------------------------------------------------------
241 * New height-aware isometric API (Articles 747/748/934/1269/2026)
242 * These functions do NOT require Allegro.
243 *-------------------------------------------------------------------------*/
244
246ISO_MAP* iso_map_new(int width, int height, int num_terrains, int max_height);
248void iso_map_free(ISO_MAP** map);
249
251void iso_map_set_projection(ISO_MAP* map, int preset, float tile_width);
253void iso_map_set_projection_custom(ISO_MAP* map, float half_w, float half_h, float tile_lift);
255void iso_map_set_projection_target(ISO_MAP* map, int preset);
257void iso_map_lerp_projection(ISO_MAP* map, float dt);
259const char* iso_projection_name(int preset);
260
262int iso_map_get_terrain(const ISO_MAP* map, int mx, int my);
264void iso_map_set_terrain(ISO_MAP* map, int mx, int my, int terrain);
266int iso_map_get_height(const ISO_MAP* map, int mx, int my);
268void iso_map_set_height(ISO_MAP* map, int mx, int my, int h);
270int iso_map_get_ability(const ISO_MAP* map, int mx, int my);
272void iso_map_set_ability(ISO_MAP* map, int mx, int my, int ab);
273
275void iso_map_to_screen(const ISO_MAP* map, int mx, int my, int h, float* screen_x, float* screen_y);
277void iso_screen_to_map(const ISO_MAP* map, float screen_x, float screen_y, int* mx, int* my);
279void iso_map_to_screen_f(const ISO_MAP* map, float fmx, float fmy, float h, float* screen_x, float* screen_y);
284void iso_corner_to_screen(const ISO_MAP* map, int cx, int cy, float fh, float cam_x, float cam_y, float zoom, float* sx, float* sy);
288void iso_screen_to_map_height(const ISO_MAP* map, float screen_x, float screen_y, int tile_w, int tile_h, int* mx, int* my);
292void iso_screen_to_map_height_f(const ISO_MAP* map, float screen_x, float screen_y, int tile_w, int tile_h, int* mx, int* my, float* out_fx, float* out_fy);
293
295int iso_is_in_diamond(int px, int py, int tile_w, int tile_h);
297float iso_diamond_dist(int px, int py, int tile_w, int tile_h);
298
300float iso_map_interpolate_height(const ISO_MAP* map, float fx, float fy);
301
303void iso_map_calc_transitions(const ISO_MAP* map, int mx, int my, int* edge_bits, int* corner_bits);
305int iso_map_should_transition(const ISO_MAP* map, int mx1, int my1, int mx2, int my2);
306
308void iso_map_corner_heights(const ISO_MAP* map, int mx, int my, float* h_n, float* h_e, float* h_s, float* h_w);
309
311int iso_map_save(const ISO_MAP* map, const char* filename);
313ISO_MAP* iso_map_load(const char* filename);
314
316void iso_map_randomize(ISO_MAP* map);
317
318#ifdef N_ASTAR_H
323ASTAR_GRID* iso_map_to_astar_grid(const ISO_MAP* map, int max_height_diff, int start_x, int start_y);
324#endif
325
327void iso_map_smooth_corner_heights(const ISO_MAP* map, int mx, int my, float* h_n, float* h_e, float* h_s, float* h_w);
328
337int iso_map_set_segments(ISO_MAP* map, int mx, int my, const ISO_TILE_SEGMENT* segs, int count);
338
340const ISO_TILE_SEGMENTS* iso_map_get_segments(const ISO_MAP* map, int mx, int my);
341
349int iso_map_build_draw_order(const ISO_MAP* map, ISO_DRAW_ENTRY* out, int max_entries);
350
352int iso_map_should_transition_smooth(const ISO_MAP* map, int mx1, int my1, int mx2, int my2);
353
356void iso_map_calc_transitions_full(const ISO_MAP* map, int mx, int my, int* edge_bits, int* corner_bits);
357
358/*---------------------------------------------------------------------------
359 * Height border edge visibility
360 *
361 * Determines which diamond edges of an elevated tile should be outlined.
362 * An edge is drawn when the adjacent tile has a height difference > 1
363 * or does not exist (map boundary).
364 *-------------------------------------------------------------------------*/
365
378
389ISO_VISIBLE_EDGES iso_map_get_visible_edges(const ISO_MAP* map, int mx, int my);
390
401ISO_VISIBLE_EDGES iso_map_get_visible_edges_segment(const ISO_MAP* map, int mx, int my, int seg_idx);
402
403/*---------------------------------------------------------------------------
404 * N_ISO_CAMERA API
405 *
406 * 2D camera management for isometric viewports. Coordinates match the
407 * library convention used by iso_map_to_screen() and iso_map_draw().
408 *-------------------------------------------------------------------------*/
409
414N_ISO_CAMERA* n_iso_camera_new(float zoom_min, float zoom_max);
415
418
420void n_iso_camera_scroll(N_ISO_CAMERA* cam, float dx, float dy);
421
427void n_iso_camera_zoom(N_ISO_CAMERA* cam, float dz, float mouse_x, float mouse_y);
428
435void n_iso_camera_center_on(N_ISO_CAMERA* cam, float world_x, float world_y, int screen_w, int screen_h);
436
445void n_iso_camera_follow(N_ISO_CAMERA* cam, float target_x, float target_y, int screen_w, int screen_h, float smoothing, float dt);
446
453void n_iso_camera_screen_to_world(const N_ISO_CAMERA* cam, float sx, float sy, float* wx, float* wy);
454
461void n_iso_camera_world_to_screen(const N_ISO_CAMERA* cam, float wx, float wy, float* sx, float* sy);
462
463/*---------------------------------------------------------------------------
464 * Isometric drawable object for depth-sorted rendering
465 *
466 * Objects are interleaved with tiles during iso_map_draw() based on
467 * their map position, achieving correct painter's algorithm ordering.
468 * When an object is behind a taller tile, it can optionally be redrawn
469 * as a transparent overlay so the player can still see it.
470 *-------------------------------------------------------------------------*/
471
478typedef void (*N_ISO_OBJECT_DRAW_FN)(float screen_x, float screen_y, float zoom, float alpha, void* user_data);
479
493
494/*---------------------------------------------------------------------------
495 * ISO_MAP rendering API (requires Allegro 5)
496 *
497 * Provides full isometric rendering with height, terrain transitions,
498 * cliff walls, hover highlight, and grid overlay. Requires pre-generated
499 * tile bitmaps and transition mask overlays from the application.
500 *-------------------------------------------------------------------------*/
501#ifdef HAVE_ALLEGRO
502
503#include <allegro5/allegro.h>
504#include <allegro5/allegro_primitives.h>
505#include <allegro5/allegro_font.h>
506
526void iso_map_draw(const ISO_MAP* map,
527 ALLEGRO_BITMAP** tile_bitmaps,
528 ALLEGRO_BITMAP*** transition_tiles,
529 int num_masks,
530 ALLEGRO_BITMAP** overlay_bitmaps,
531 int num_overlay_tiles,
532 float cam_px,
533 float cam_py,
534 float zoom,
535 int screen_w,
536 int screen_h,
537 int player_mode,
538 N_ISO_OBJECT* objects,
539 int num_objects);
540
547void iso_mask_tile_to_diamond(ALLEGRO_BITMAP* bmp, int tile_w, int tile_h);
548
555void iso_generate_transition_masks(ALLEGRO_BITMAP** masks, int tile_w, int tile_h);
556
567void iso_generate_transition_tiles(ALLEGRO_BITMAP*** tiles,
568 ALLEGRO_BITMAP** masks,
569 ALLEGRO_BITMAP** tile_bitmaps,
570 int num_terrains,
571 int tile_w,
572 int tile_h);
573
574/*---------------------------------------------------------------------------
575 * Legacy API (requires Allegro 5)
576 *-------------------------------------------------------------------------*/
577
579#define N_TILE 2
581#define N_ABILITY 3
583#define N_MUSIC 4
585#define N_OBJECT 5
586
588typedef struct CELL {
589 int
597
598} CELL;
599
601typedef struct MAP {
604
606 char* name;
607
609 ALLEGRO_BITMAP *mousemap,
612
613 int
630 ALLEGRO_COLOR bgcolor;
632 ALLEGRO_COLOR wirecolor;
641
642} MAP;
643
645int create_empty_map(MAP** map, const char* name, int XSIZE, int YSIZE, int TILEW, int TILEH, int nbmaxobjects, int nbmaxgroup, int nbmaxanims, int nbtiles, int nbanims);
647int set_value(MAP* map, int type, int x, int y, int value);
649int get_value(MAP* map, int type, int x, int y);
651int ScreenToMap(int mx, int my, int* Tilex, int* Tiley, ALLEGRO_BITMAP* mousemap);
653int camera_to_scr(MAP** map, int x, int y);
655int camera_to_map(MAP** map, int tx, int ty, int x, int y);
657int draw_map(MAP* map, ALLEGRO_BITMAP* bmp, int destx, int desty, int mode);
659int load_map(MAP** map, char* filename);
661int save_map(MAP* map, char* filename);
663int free_map(MAP** map);
664
665#endif /* HAVE_ALLEGRO */
666
671#ifdef __cplusplus
672}
673#endif
674
675#endif /* #ifndef NILOREA_ISOMETRIC_ENGINE */
static int player_mode
Definition ex_gui.c:54
static ALLEGRO_BITMAP * transition_tiles[8][(16+16)]
static int screen_w
static ALLEGRO_BITMAP * tile_bitmaps[8]
static int screen_h
static int mode
Grid structure holding walkability, costs, and dimensions.
Definition n_astar.h:147
int bottom
segment bottom height (primary sort key)
char * quests_group_names
as for previous:char *object_group_names
float fz
height in map units (elevation)
int X
X move in pixel for drawing.
char * sounds_group_names
as for previous:char *object_group_names
int TILEW
size X of tiles of the map (in pixel)
ISO_TILE_SEGMENT segs[2]
int * neighbor_heights_west
Heights from west neighbor chunk's east edge [height], NULL = boundary.
float fy
fractional map Y position
int lower_tile
terrain index for wall/side faces (-1 = use tile's terrain layer)
int * ability
walkability per cell [height * width] (WALK/SWIM/BLCK)
int height
map height in tiles (Y axis)
float occluded_alpha
overlay alpha when behind tiles [0..1], 0=hidden, 0.35=ghost, 1=always visible
int ability
ability of the tile (walking, swimming, blocking, killing ?)
ALLEGRO_BITMAP * colortile
default full colored background tile
int upper_tile
terrain index for top face (-1 = use tile's terrain layer)
int neighbor_top_se
top height of SE neighbor (0 if absent/boundary)
float tile_lift
vertical pixel offset per height unit
float zoom_min
minimum allowed zoom
int * neighbor_heights_east
Heights from east neighbor chunk's west edge [height], NULL = boundary.
int draw_sw
1 if SW edge (S→W, bottom-left) should be drawn
ALLEGRO_COLOR bgcolor
color of the bg
int neighbor_top_sw
top height of SW neighbor (0 if absent/boundary)
float angle_deg
current projection angle in degrees
int smooth_height
0 = CUT mode (cliff walls), 1 = SMOOTH mode (per-corner slopes)
int tilenumber
ident of the tile in the MAP->tile library
float half_w
half-width of a tile in pixels (horizontal extent)
int count
0..ISO_MAX_SEGMENTS_PER_TILE
char * name
Name of the map ( used for linking between two map )
int ptanchorY
Y starting cell for drawing.
int bottom
lower height bound (inclusive), must be < top
int hover_mx
hovered tile X (-1 = none)
int max_height
maximum allowed height value
int ptanchorX
X starting cell for drawing.
int top
segment top height
float sprite_h
entity height in world units for occlusion (derived from sprite hot_y)
int seg_idx
segment index within tile (0..count-1)
int draw_nw
1 if NW edge (N→W, top-left) should be drawn
int underside
1 if underside face should be drawn
int neighbor_top_ne
top height of NE neighbor (0 if absent/boundary)
float occlude_clip_y
OUTPUT: screen Y of top occluder north vertex (for cross-chunk clip fallback)
int TILEH
size Y of tiles of the map (in pixel)
char * object_group_names
name of the main group of the (kind of) library of objects, filled by zero else, size iz limited to 5...
int num_terrains
number of terrain types used
float * dynamic_light_map
Per-tile dynamic light accumulation buffer.
int top
upper height bound, must be > bottom
CELL * grid
Grid of each cell of the map.
float half_h
half-height of a tile in pixels (vertical extent)
int * overlay
overlay tile index per cell [height * width], 0 = none.
float lerp_speed
interpolation speed factor (default 3.0)
int neighbor_top_nw
top height of NW neighbor (0 if absent/boundary)
float fx
fractional map X position
void * user_data
user data passed to draw callback
int * neighbor_heights_south
Heights from south neighbor chunk's north edge [width], NULL = boundary.
int * terrain
terrain type per cell [height * width], indices 0..num_terrains-1
N_ISO_OBJECT_DRAW_FN draw
draw callback
int YSIZE
size Y of the grid (nbYcell)
int XSIZE
size X of the grid (nbXcell)
float zoom_max
maximum allowed zoom
int * neighbor_heights_north
Heights from north neighbor chunk's south edge [width], NULL = boundary.
float height_tint_intensity
0.0 = no tint, 0.3 = subtle, 1.0 = full range.
float zoom
zoom factor (1.0 = no zoom)
float ambient_b
int is_occluded
OUTPUT: set to 1 if behind tiles during last iso_map_draw() call.
char * anim_group_names
as for previous:char *object_group_names
int music
ident of the music on the tile
int draw_se
1 if SE edge (E→S, bottom-right) should be drawn
int my
tile coordinates
int objectnumber
ident of the object in the MAP->object library
int * heightmap
height value per cell [height * width], 0..max_height
float y
camera Y offset (world units, pre-zoom)
float ambient_r
Global ambient color (day/night + dark place tinting).
int width
map width in tiles (X axis)
float ambient_g
int show_grid
1 = draw grid overlay
float target_angle
target angle for smooth interpolation (degrees)
int draw_ne
1 if NE edge (N→E, top-right) should be drawn
int Y
Y move in pixel for drawing.
ISO_TILE_SEGMENTS * segments
Per-cell height segments.
float sprite_half_w
entity half-width in screen pixels for horizontal occlusion test
ALLEGRO_BITMAP * mousemap
Map for mouse collision between mouse pointer and map.
int draw_underside
1 if floating segment underside border should be drawn
int smooth_slope_max
max height diff rendered as slope (default 1)
int hover_my
hovered tile Y (-1 = none)
float x
camera X offset (world units, pre-zoom)
ISO_PROJECTION proj
current projection parameters
ALLEGRO_COLOR wirecolor
color of wire
void iso_map_set_height(ISO_MAP *map, int mx, int my, int h)
set height for a cell (bounds-checked, clamped)
int save_map(MAP *map, char *filename)
Save the map.
void iso_map_set_projection_custom(ISO_MAP *map, float half_w, float half_h, float tile_lift)
set custom projection parameters directly
void iso_map_smooth_corner_heights(const ISO_MAP *map, int mx, int my, float *h_n, float *h_e, float *h_s, float *h_w)
compute smooth corner heights with slope clamping (for rendering)
int get_value(MAP *map, int type, int x, int y)
Get the tilenumber of a cell.
ISO_MAP * iso_map_new(int width, int height, int num_terrains, int max_height)
create a new height-aware ISO_MAP with given dimensions
float iso_diamond_dist(int px, int py, int tile_w, int tile_h)
distance from pixel to diamond edge (0 at edge, 1 at center)
int iso_map_set_segments(ISO_MAP *map, int mx, int my, const ISO_TILE_SEGMENT *segs, int count)
set per-tile segments on an ISO_MAP.
int draw_map(MAP *map, ALLEGRO_BITMAP *bmp, int destx, int desty, int mode)
Draw the map using its coordinate on the specified bitmap.
void n_iso_camera_zoom(N_ISO_CAMERA *cam, float dz, float mouse_x, float mouse_y)
Zoom the camera toward a screen-space point (e.g.
void n_iso_camera_center_on(N_ISO_CAMERA *cam, float world_x, float world_y, int screen_w, int screen_h)
Center the camera so that a world point is at screen center.
int iso_map_save(const ISO_MAP *map, const char *filename)
save ISO_MAP to binary file (chunk-based format)
int iso_map_should_transition_smooth(const ISO_MAP *map, int mx1, int my1, int mx2, int my2)
check if terrain transition should render between two cells (height-aware)
void iso_corner_to_screen(const ISO_MAP *map, int cx, int cy, float fh, float cam_x, float cam_y, float zoom, float *sx, float *sy)
Project a tile corner to screen coordinates (canonical formula).
int load_map(MAP **map, char *filename)
Load the map.
int camera_to_map(MAP **map, int tx, int ty, int x, int y)
Center Map on given map coordinate, with x & y offset.
void iso_map_lerp_projection(ISO_MAP *map, float dt)
smoothly interpolate current projection angle toward target (call every frame)
#define ISO_MAX_SEGMENTS_PER_TILE
Max height segments per tile (ground + one elevated structure).
void iso_mask_tile_to_diamond(ALLEGRO_BITMAP *bmp, int tile_w, int tile_h)
Mask a tile bitmap to the isometric diamond shape.
ISO_VISIBLE_EDGES iso_map_get_visible_edges(const ISO_MAP *map, int mx, int my)
Compute which diamond edges of tile (mx, my) need a height border.
ISO_MAP * iso_map_load(const char *filename)
load ISO_MAP from binary file
void n_iso_camera_free(N_ISO_CAMERA **cam)
Free a camera and set the pointer to NULL.
int iso_map_build_draw_order(const ISO_MAP *map, ISO_DRAW_ENTRY *out, int max_entries)
Build the draw order for segment-sorted rendering.
int iso_map_should_transition(const ISO_MAP *map, int mx1, int my1, int mx2, int my2)
check if terrain blending should occur between two adjacent cells
const char * iso_projection_name(int preset)
get the display name for a projection preset
void n_iso_camera_follow(N_ISO_CAMERA *cam, float target_x, float target_y, int screen_w, int screen_h, float smoothing, float dt)
Smoothly follow a world-space target (camera lerp).
void iso_map_set_ability(ISO_MAP *map, int mx, int my, int ab)
set ability for a cell (bounds-checked)
ISO_VISIBLE_EDGES iso_map_get_visible_edges_segment(const ISO_MAP *map, int mx, int my, int seg_idx)
Compute per-segment edge visibility for height border rendering.
int iso_map_get_terrain(const ISO_MAP *map, int mx, int my)
get terrain type for a cell (bounds-checked)
int camera_to_scr(MAP **map, int x, int y)
Center Map on given screen coordinate.
void iso_map_calc_transitions_full(const ISO_MAP *map, int mx, int my, int *edge_bits, int *corner_bits)
compute per-terrain transition bitmasks with height filtering (Article 934).
int iso_map_get_ability(const ISO_MAP *map, int mx, int my)
get ability for a cell (bounds-checked)
void iso_map_draw(const ISO_MAP *map, ALLEGRO_BITMAP **tile_bitmaps, ALLEGRO_BITMAP ***transition_tiles, int num_masks, ALLEGRO_BITMAP **overlay_bitmaps, int num_overlay_tiles, float cam_px, float cam_py, float zoom, int screen_w, int screen_h, int player_mode, N_ISO_OBJECT *objects, int num_objects)
Draw the full ISO_MAP with height, transitions, overlays, cliff walls, hover, and grid.
int set_value(MAP *map, int type, int x, int y, int value)
Set the tilenumber of a cell.
void iso_map_to_screen(const ISO_MAP *map, int mx, int my, int h, float *screen_x, float *screen_y)
convert map tile coordinates to screen pixel coordinates
void iso_map_calc_transitions(const ISO_MAP *map, int mx, int my, int *edge_bits, int *corner_bits)
compute terrain transition bitmasks for a cell (Article 934)
void iso_map_set_projection(ISO_MAP *map, int preset, float tile_width)
set projection preset and snap to it immediately
void n_iso_camera_screen_to_world(const N_ISO_CAMERA *cam, float sx, float sy, float *wx, float *wy)
Convert screen pixel coordinates to world coordinates.
int ScreenToMap(int mx, int my, int *Tilex, int *Tiley, ALLEGRO_BITMAP *mousemap)
Convert screen coordinate to map coordinate.
void iso_map_to_screen_f(const ISO_MAP *map, float fmx, float fmy, float h, float *screen_x, float *screen_y)
convert map tile coordinates to screen pixel coordinates (float version)
void iso_map_free(ISO_MAP **map)
free an ISO_MAP and set the pointer to NULL
int iso_is_in_diamond(int px, int py, int tile_w, int tile_h)
test if pixel (px,py) is inside the isometric diamond of size tile_w x tile_h
void iso_generate_transition_tiles(ALLEGRO_BITMAP ***tiles, ALLEGRO_BITMAP **masks, ALLEGRO_BITMAP **tile_bitmaps, int num_terrains, int tile_w, int tile_h)
Pre-composite transition tiles (terrain texture * alpha mask).
void iso_map_set_projection_target(ISO_MAP *map, int preset)
set target projection preset for smooth interpolation via iso_map_lerp_projection
void iso_map_set_terrain(ISO_MAP *map, int mx, int my, int terrain)
set terrain type for a cell (bounds-checked)
void iso_screen_to_map(const ISO_MAP *map, float screen_x, float screen_y, int *mx, int *my)
convert screen pixel coordinates to map tile coordinates (flat, no height)
void iso_map_randomize(ISO_MAP *map)
randomize terrain and height for testing/demo purposes
void iso_generate_transition_masks(ALLEGRO_BITMAP **masks, int tile_w, int tile_h)
Generate the 32 procedural transition alpha masks (16 edge + 16 corner).
void(* N_ISO_OBJECT_DRAW_FN)(float screen_x, float screen_y, float zoom, float alpha, void *user_data)
Object draw callback.
const ISO_TILE_SEGMENTS * iso_map_get_segments(const ISO_MAP *map, int mx, int my)
get per-tile segments.
int iso_map_get_height(const ISO_MAP *map, int mx, int my)
get height for a cell (bounds-checked, clamped)
float iso_map_interpolate_height(const ISO_MAP *map, float fx, float fy)
bilinear height interpolation at fractional map coordinates
void n_iso_camera_world_to_screen(const N_ISO_CAMERA *cam, float wx, float wy, float *sx, float *sy)
Convert world coordinates to screen pixel coordinates.
void iso_screen_to_map_height_f(const ISO_MAP *map, float screen_x, float screen_y, int tile_w, int tile_h, int *mx, int *my, float *out_fx, float *out_fy)
height-aware screen-to-map conversion returning fractional tile coordinates.
void iso_screen_to_map_height(const ISO_MAP *map, float screen_x, float screen_y, int tile_w, int tile_h, int *mx, int *my)
height-aware screen-to-map conversion with diamond hit testing.
void iso_map_corner_heights(const ISO_MAP *map, int mx, int my, float *h_n, float *h_e, float *h_s, float *h_w)
compute average corner heights for smooth rendering (Article 2026)
void n_iso_camera_scroll(N_ISO_CAMERA *cam, float dx, float dy)
Scroll the camera by (dx, dy) world units.
int free_map(MAP **map)
Free the map.
N_ISO_CAMERA * n_iso_camera_new(float zoom_min, float zoom_max)
Create a new camera with the given zoom limits.
int create_empty_map(MAP **map, const char *name, int XSIZE, int YSIZE, int TILEW, int TILEH, int nbmaxobjects, int nbmaxgroup, int nbmaxanims, int nbtiles, int nbanims)
Create an empty map.
Cell of a MAP.
Draw order entry for segment-sorted rendering.
Height-aware isometric map with terrain and height layers.
Axonometric projection parameters.
Single vertical segment of a tile: solid matter from bottom to top.
Per-tile height segments.
Per-tile edge visibility flags for height border rendering.
MAP with objects, tiles, skins (legacy structure)
2D isometric camera for viewport management.
Drawable object for depth-sorted isometric rendering.
Common headers and low-level functions & define.
Generic log system.