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.

60 lines
1.9 KiB

#ifndef ISOMETRICMAP_H_
#define ISOMETRICMAP_H_
#include "raylib.h"
#include "tile.h"
#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;
} IsometricMap;
// returns pointer to IsometricMap Instance
IsometricMap * IsometricMapInit();
// 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 halfTextureSize, int quarterTextureSize);
// 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(Camera2D *camera, int x, int y, Vector2 *tmp);
void IsometricMapUnprojectIgnoreCam(int x, int y, Vector2 *tmp);
// changes to Texture ID of tile at x y on maplayer layer
void IsometricMapChangeTextureIdOfTile(IsometricMap *map, int x, int y, int id);
// returns Tile * -> tile at coordinates x y z=layer
Tile * IsometricMapGetTileFromWorldCoordinates(IsometricMap *isometricMap, float x, float y);
// Draws Isometric Map and Sprites in between :)
void IsometricMapDraw(Game *game);
void IsometricMapDrawRectangle(Vector2 from, Vector2 to, Color color);
#endif