summaryrefslogtreecommitdiff
path: root/src/shapes.c
diff options
context:
space:
mode:
authorjussi2024-11-21 00:11:31 +0200
committerjussi2024-11-21 00:11:31 +0200
commit4c0eb17a9c234bfee73af408faa38e38f2e450d9 (patch)
tree4aea4fe804a63ed13a1d092aada0ba5925dcf05f /src/shapes.c
parent479726a5e468a2f4d0f9337f082889082e535bfb (diff)
downloadreilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.gz
reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.bz2
reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.zip
New raylib 5.5 functions.
Diffstat (limited to 'src/shapes.c')
-rw-r--r--src/shapes.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/src/shapes.c b/src/shapes.c
index 2efa78a..07f40c3 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -4,17 +4,6 @@
#include "lua_core.h"
#include "textures.h"
-static inline void getVector2Array( lua_State* L, int index, Vector2 points[] ) {
- int t = index, i = 0;
- lua_pushnil( L );
-
- while ( lua_next( L, t ) != 0 ) {
- points[i] = uluaGetVector2( L, lua_gettop( L ) );
- i++;
- lua_pop( L, 1 );
- }
-}
-
/*
## Shapes - Basic shapes drawing functions
*/
@@ -30,12 +19,40 @@ int lshapesSetShapesTexture( lua_State* L ) {
Texture* texture = uluaGetTexture( L, 1 );
Rectangle source = uluaGetRectangle( L, 2 );
+ state->shapesTexture = *texture;
+
SetShapesTexture( *texture, source );
return 0;
}
/*
+> texture = RL.GetShapesTexture()
+
+Get texture that is used for shapes drawing. Return as lightuserdata
+
+- Success return Texture
+*/
+int lshapesGetShapesTexture( lua_State* L ) {
+ lua_pushlightuserdata( L, &state->shapesTexture );
+
+ return 1;
+}
+
+/*
+> source = RL.GetShapesTextureRectangle()
+
+Get texture source rectangle that is used for shapes drawing
+
+- Success return Rectangle
+*/
+int lshapesGetShapesTextureRectangle( lua_State* L ) {
+ uluaPushRectangle( L, GetShapesTextureRectangle() );
+
+ return 1;
+}
+
+/*
> RL.DrawPixel( Vector2 pos, Color color )
Draw a pixel
@@ -875,6 +892,24 @@ int lshapesCheckCollisionCircleRec( lua_State* L ) {
}
/*
+> collision = RL.CheckCollisionCircleLine( Vector2 center, float radius, Vector2 p1, Vector2 p2 )
+
+Check if circle collides with a line created betweeen two points [p1] and [p2]
+
+- Success return bool
+*/
+int lshapesCheckCollisionCircleLine( lua_State* L ) {
+ Vector2 center = uluaGetVector2( L, 1 );
+ float radius = luaL_checknumber( L, 2 );
+ Vector2 p1 = uluaGetVector2( L, 3 );
+ Vector2 p2 = uluaGetVector2( L, 4 );
+
+ lua_pushboolean( L, CheckCollisionCircleLine( center, radius, p1, p2 ) );
+
+ return 1;
+}
+
+/*
> collision = RL.CheckCollisionPointRec( Vector2 point, Rectangle rec )
Check if point is inside rectangle