Engine
Raylib based game framework
Loading...
Searching...
No Matches
RaylibUtils.h
1#pragma once
2#include "raylib.h"
3#include "rlgl.h"
4
5#include <cmath>
6#include <string>
7#include <vector>
8
9bool ColorCompare(const Color a, const Color b);
10
11// Draw texture with scaling
12void DrawTextureScale(const Texture2D& texture, const Vector2 position, const float scale, const Color color);
13// Draw textures centred on the origin with rotation in degrees
14void DrawTextureRot(const Texture2D& texture, const Vector2 position, const int rotation, const Color color);
15// Same as above but scaling factor as well
16void DrawTextureRotScale(const Texture2D& texture, const Vector2 position, const int rotation, const float scale,
17const Color color);
18// Same as above but you input a rectangle to choose the desired sprite
19void DrawTextureRotScaleSelect(const Texture2D& texture, const Rectangle selection, const Vector2 position,
20const int rotation, const float scale, const Color color);
21
22// Draw text centred on a rec
23void DrawTextRec(const std::string& text, const int fontSize, const Color textColor, const Rectangle rec,
24const Color recColor);
25
26// Turn an angle in degrees to a vector
27Vector2 Angle2Vector(const int degrees);
28// Get angle of vector
29int Vector2Angle(const Vector2 vec);
30// Get a vector of certain length and rotation in degrees
31Vector2 Vector2Rot(const int length, const int rotation);
32
33// Convert from vector rot to bound by 360 degrees
34int DegreeRot(const int rot);
35
36// Angle from one pos to another
37int AngleFromPos(const Vector2 pos1, const Vector2 pos2);
38
39// Scale a rectangle
40Rectangle ScaleRectangle(const Rectangle rectangle, const float scale, const Vector2 position);
41
42// Get 2D camera rectangle
43Rectangle GetCameraRectangle(const Camera2D camera);
44
45// Check for texture visibility
46bool IsTextureVisible(const Texture2D texture, const float scale, const Vector2 position, const Camera2D camera);
47bool IsRectangleVisible(const Rectangle rectangle, const float scale, const Vector2 position, const Camera2D camera);
48
49// String to list of words
50std::vector<std::string> WordList(const std::string& input);
51
52// Draw a texture as a polygon of n points with no intersecting edges all visible to the centre
53void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2* points, Vector2* texcoords, int pointCount,
54Color tint);
55
56// Convert a double to a string with a certain amount of precision
57std::string DoubleToRoundedString(const double num, const int precision);
58
59// Get a centred rectangle
60Rectangle CenteredRectangle(const Rectangle rec, const Vector2 pos);
61
62// Used for shadow maps
63RenderTexture2D LoadShadowmapRenderTexture(int width, int height);
64void UnloadShadowmapRenderTexture(RenderTexture2D target);