Jo Engine  2024.04.28
Jo Sega Saturn Engine
Macros | Functions
map.h File Reference

Jo Engine MAP file (sprite map) More...

Go to the source code of this file.

Macros

#define JO_MAP_NO_COLLISION
 Value returned by jo_map_hitbox_detection_custom_boundaries();. More...
 

Functions

int jo_map_per_pixel_vertical_collision (const unsigned int layer, int x, int y, unsigned char *attribute)
 Method to get vertical distance between our point (x, y) and the surface of the map (example: hill) More...
 
int jo_map_hitbox_detection_custom_boundaries (const unsigned int layer, const int x, const int y, const int w, const int h)
 Fast method to get if a square intersects with the map (HitBox processing) based on screen coord. More...
 
bool jo_map_load_from_file (const unsigned int layer, const short depth, const char *const sub_dir, const char *const filename)
 Load a sprite map on a specific layer using MAP file format. More...
 
bool jo_map_create (const unsigned int layer, const unsigned short max_tile_count, const short depth)
 Create a new sprite map. More...
 
void jo_map_add_tile (const unsigned int layer, const short x, const short y, const unsigned char sprite_id, const unsigned char attribute)
 Add a tile on the specific layer. More...
 
void jo_map_add_animated_tile (const unsigned int layer, const short x, const short y, const unsigned char anim_id, const unsigned char attribute)
 Add an animated tile on the specific layer. More...
 
void jo_map_free (const unsigned int layer)
 Destroy the specific layer. More...
 
void jo_map_draw (const unsigned int layer, const short screen_x, const short screen_y)
 Display the specific layer. More...
 
void jo_map_draw_background (const unsigned int layer, const short x, const short y)
 Draw the specific layer on the background (NBG1) More...
 
void jo_map_move_tiles_by_attribute (const unsigned int layer, const unsigned char attribute_filter, const short incr_x, const short incr_y)
 Move specific tiles by their attributes. More...
 
void jo_map_3d_draw (const unsigned int layer, const int x, const int y, const int z)
 

Detailed Description

Jo Engine MAP file (sprite map)

Author
Johannes Fetz
Bug:
No known bugs.

Macro Definition Documentation

◆ JO_MAP_NO_COLLISION

#define JO_MAP_NO_COLLISION

Value returned by jo_map_hitbox_detection_custom_boundaries();.

Warning
Don't change this value

Function Documentation

◆ jo_map_3d_draw()

void jo_map_3d_draw ( const unsigned int  layer,
const int  x,
const int  y,
const int  z 
)

◆ jo_map_add_animated_tile()

void jo_map_add_animated_tile ( const unsigned int  layer,
const short  x,
const short  y,
const unsigned char  anim_id,
const unsigned char  attribute 
)

Add an animated tile on the specific layer.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
xhorizontal position on the map
yvertical position on the map
anim_idAnimation ID
attributeUser attribute (it's for you)

◆ jo_map_add_tile()

void jo_map_add_tile ( const unsigned int  layer,
const short  x,
const short  y,
const unsigned char  sprite_id,
const unsigned char  attribute 
)

Add a tile on the specific layer.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
xhorizontal position on the map
yvertical position on the map
sprite_idSprite ID
attributeUser attribute (it's for you)

◆ jo_map_create()

bool jo_map_create ( const unsigned int  layer,
const unsigned short  max_tile_count,
const short  depth 
)

Create a new sprite map.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
max_tile_countMaximum tile count in the entire map
depthZ index (ex 500)
Returns
true if successful otherwise false (use jo_get_last_error())

◆ jo_map_draw()

void jo_map_draw ( const unsigned int  layer,
const short  screen_x,
const short  screen_y 
)

Display the specific layer.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
screen_xrelative horizontal position between the screen and the map
screen_yrelative vertical position between the screen and the map

◆ jo_map_draw_background()

void jo_map_draw_background ( const unsigned int  layer,
const short  x,
const short  y 
)

Draw the specific layer on the background (NBG1)

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
xrelative horizontal position between the background image and the map
yrelative vertical position between the background image and the map
Warning
Only works with full color images (not 8 bits)

◆ jo_map_free()

void jo_map_free ( const unsigned int  layer)

Destroy the specific layer.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)

◆ jo_map_hitbox_detection_custom_boundaries()

int jo_map_hitbox_detection_custom_boundaries ( const unsigned int  layer,
const int  x,
const int  y,
const int  w,
const int  h 
)

Fast method to get if a square intersects with the map (HitBox processing) based on screen coord.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
xHorizontal position of square (based on the screen !, so 0 is the left the screen)
yVertical position of square (based on the screen !, so 0 is the top the screen)
wWidth of the square
hHeight of the square
Returns
The attribute of the tile if square collides otherwise JO_MAP_NO_COLLISION

◆ jo_map_load_from_file()

bool jo_map_load_from_file ( const unsigned int  layer,
const short  depth,
const char *const  sub_dir,
const char *const  filename 
)

Load a sprite map on a specific layer using MAP file format.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
depthZ-index
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
filenameFilename (upper case and shorter as possible like "A.MAP")
Remarks
Sample file with 4 blocks. Each tile has his own texture:
IMAGE_FILENAME X Y ATTRIBUTE(optional)
1.TGA 0 0
2.TGA 160 0
3.TGA 0 120
4.TGA 160 120
use JoMapEditor to create map file
Returns
true if successful otherwise false (use jo_get_last_error())

◆ jo_map_move_tiles_by_attribute()

void jo_map_move_tiles_by_attribute ( const unsigned int  layer,
const unsigned char  attribute_filter,
const short  incr_x,
const short  incr_y 
)

Move specific tiles by their attributes.

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
attribute_filterTile attribute value (filtering)
incr_xHorizontal position incrementation
incr_yVertical position incrementation

◆ jo_map_per_pixel_vertical_collision()

int jo_map_per_pixel_vertical_collision ( const unsigned int  layer,
int  x,
int  y,
unsigned char *  attribute 
)

Method to get vertical distance between our point (x, y) and the surface of the map (example: hill)

Parameters
layerlayer level (between 0 and JO_MAP_MAX_LAYER)
xHorizontal position of the point (based on the screen !, so 0 is the left the screen)
yVertical position of the point (based on the screen !, so 0 is the top the screen)
attributeTile attribute
Remarks
(x,y)
# | #
### | ##
##### v ##
####### ####
##############
Returns
distance from the surface of the map otherwise JO_MAP_NO_COLLISION
Warning
if distance > 0 then you don't touch the ground but your are on the sprite
if distance <= 0 then you are under the surface of the sprite
Don't use this method if you don't have transparent pixel or if the surface is concave