aboutsummaryrefslogtreecommitdiff
path: root/code/main.felan
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-28 13:52:10 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-28 13:52:10 +0330
commit0d671d4364fa0db76fca6584a97c51de02b9e220 (patch)
tree9e94b3eadb57c381f5e8d218e32aa8f8e41f2081 /code/main.felan
parent5823be69762ac3d15869d4de65647f0b9ca82449 (diff)
add more stuff to lib
fix use after free
Diffstat (limited to 'code/main.felan')
-rw-r--r--code/main.felan32
1 files changed, 26 insertions, 6 deletions
diff --git a/code/main.felan b/code/main.felan
index 6d83f56..9f49f01 100644
--- a/code/main.felan
+++ b/code/main.felan
@@ -12,8 +12,10 @@ WindowShouldClose :: @c_function(raylib,"WindowShouldClose",()->bool);
BeginDrawing :: @c_function(raylib,"BeginDrawing",()->void);
EndDrawing :: @c_function(raylib,"EndDrawing",()->void);
CloseWindow :: @c_function(raylib,"CloseWindow",()->void);
-ClearBackground :: @c_function(raylib,"ClearBackground",(color:Color)->void);
-DrawText :: @c_function(raylib,"DrawText",(*u8,i32,i32,i32,u32)->void);
+ClearBackground :: @c_function(raylib,"ClearBackground",(Color)->void);
+DrawText :: @c_function(raylib,"DrawText",(*u8,i32,i32,i32,Color)->void);
+// void DrawRectangle(int posX, int posY, int width, int height, Color color);
+DrawRectangle :: @c_function(raylib,"DrawRectangle",(posX:i32,posY:i32,width:i32,height:i32,color:Color)->void);
Color :: struct {
r:u8;
@@ -23,6 +25,8 @@ Color :: struct {
};
main :: ()->void{
+ print(1236);
+ return;
b := "raylib [core] example - basic window\0";
c := "Congrats! You created your first window!\0";
str := &b[0];
@@ -31,14 +35,21 @@ main :: ()->void{
screenHeight :i32: 450;
a : u8 : 255;
b : u8 : 0;
- white :: color(a,a,a,a);
- black :u32= 0xff000000;
+ WHITE :: color(a,a,a,a);
+ BLACK :: color(@cast(0xff0000ff,u32));
InitWindow(screenWidth,screenHeight,str);
+ rect_posx :i32= 0;
+ rect_posy :i32= 0;
while !WindowShouldClose() {
BeginDrawing();
- ClearBackground(white);
- DrawText(str2,@cast(190,i32),@cast(200,i32),@cast(20,i32),black);
+ ClearBackground(WHITE);
+ DrawRectangle(rect_posx,rect_posy,@cast(200,i32),@cast(40,i32),color(@cast(0x00ffff,u32)));
+ DrawText(str2,@cast(190,i32),@cast(200,i32),@cast(20,i32),BLACK);
EndDrawing();
+ /*
+ rect_posx += @cast(1,i32);
+ rect_posy += @cast(1,i32);
+ */
}
CloseWindow();
};
@@ -51,3 +62,12 @@ color :: (a:u8,r:u8,g:u8,b:u8)->Color{
c.a = a;
return c;
};
+
+color :: (value:u32)->Color{
+ c : Color = undefined;
+ c.r = @cast((value&@cast(0xff000000,u32))>>@cast(6*4,u32),u8);
+ c.g = @cast((value&@cast(0x00ff0000,u32))>>@cast(4*4,u32),u8);
+ c.b = @cast((value&@cast(0x0000ff00,u32))>>@cast(2*4,u32),u8);
+ c.a = @cast((value&@cast(0x000000ff,u32))>>@cast(0*4,u32),u8);
+ return c;
+};