You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.2 KiB

#ifndef ISOMETRICMAP_H_
#define ISOMETRICMAP_H_
#include "raylib.h"
#include "tile.c"
#include "../game.h"
typedef struct IsometricMap{
// Array with all the needed textures for this layer
Texture2D tileTextures[10];
// twodimensional array of all the tiles in this layer
Tile ***tiles;
// amount of tiles in x-direction
int width;
// amount of tiles in y-direction
int height;
// pixel width of a single tile texture
int textureWidth;
// pixel height of a single tile texture
int textureHeight;
// pixel width of the entire map
int worldPixelWidth;
// pixel height of the entire map
int worldPixelHeight;
// layer of the map
int layer;
} IsometricMap;
// returns pointer to IsometricMap Instance
IsometricMap * IsometricMapInit(int layer);
// For Rendering: calculates coordinate offset for a single tile at arrayPosition x y
// Only works for tiles with texture width == height (and for 22.5 degree?)
Vector2 * IsometricMapCalcOffsetForTileAt(int x, int y, int textureSize);
// saves many divisions
Vector2 * IsometricMapCalcOffsetForTileAtEfficient(int x, int y, int halfTextureSize, int quarterTextureSize);
// Gives the most upper Tile above *tile
Tile * IsometricMapGetMostUpperTile(IsometricMap **isometricMap, Tile *tile);
// returns Tile at x y on layer isometricMap
Tile * IsometricMapGetTileFromArrayPosition(IsometricMap *isometricMap, int x, int y);
// Project: Screen Coordinates -> World Coordinates writes result in tmp Vector
// Currently only calcing coords on layer 0
void IsometricMapProject(IsometricMap *isometricMap, Camera2D *camera, float x, float y, Vector2 *tmp);
// Unproject: World Coordinates -> Screen Coordinates writes result in tmp Vector
void IsometricMapUnproject(IsometricMap **isometricMap, Camera2D *camera, int x, int y, float z, Vector2 *tmp);
// changes to Texture ID of tile at x y on maplayer layer
void IsometricMapChangeTextureIdOfTile(IsometricMap **map, int x, int y, int layer, int id);
// returns Tile * -> tile at coordinates x y z=layer
Tile * IsometricMapGetTileFromWorldCoordinates(IsometricMap **isometricMap, float x, float y, float layer);
// Draws Isometric Map and Sprites in between :)
void IsometricMapDraw(Game *game);
#endif