1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
@import("basic.felan");
/*
libc :: @c_library("/lib/libc.so.6");
puts :: @c_function(libc,"puts",(*u8)->i32);
sleep :: @c_function(libc,"sleep",(i32)->i32);
*/
raylib :: @c_library("/lib/libraylib.so.5.5.0");
InitWindow :: @c_function(raylib,"InitWindow",(i32,i32,*u8)->void);
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)->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;
g:u8;
b:u8;
a:u8;
};
main :: ()->void{
print(1236);
return;
b := "raylib [core] example - basic window\0";
c := "Congrats! You created your first window!\0";
str := &b[0];
str2 := &c[0];
screenWidth :i32: 800;
screenHeight :i32: 450;
a : u8 : 255;
b : u8 : 0;
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);
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();
};
color :: (a:u8,r:u8,g:u8,b:u8)->Color{
c : Color = undefined;
c.r = r;
c.g = g;
c.b = b;
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;
};
|