aboutsummaryrefslogtreecommitdiff
path: root/code/main.felan
blob: 6d83f56dddb8291a348c49a7b86bcac0845081f1 (plain)
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
@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:Color)->void);
DrawText :: @c_function(raylib,"DrawText",(*u8,i32,i32,i32,u32)->void);

Color :: struct {
  r:u8;
  g:u8;
  b:u8;
  a:u8;
};

main :: ()->void{
  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 :u32= 0xff000000;
  InitWindow(screenWidth,screenHeight,str);
  while !WindowShouldClose() {
    BeginDrawing();
    ClearBackground(white);
    DrawText(str2,@cast(190,i32),@cast(200,i32),@cast(20,i32),black);
    EndDrawing();
  }
  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;
};