aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/lib/io.felan6
-rw-r--r--code/main.felan69
-rw-r--r--code/main2.felan87
3 files changed, 94 insertions, 68 deletions
diff --git a/code/lib/io.felan b/code/lib/io.felan
index 97be3b1..1fe7cf9 100644
--- a/code/lib/io.felan
+++ b/code/lib/io.felan
@@ -70,5 +70,11 @@ _print_unsigned :: (comptime t:type, value:t) -> void {
value != @cast(0,t);
} {}
+ while i < NUMBERS_SIZE - 1 {
+ @putc(numbers[i]);
+ i += 1;
+ }
+ return;
+
puts(&numbers[i]);
};
diff --git a/code/main.felan b/code/main.felan
index cdaeee8..90b1d08 100644
--- a/code/main.felan
+++ b/code/main.felan
@@ -1,73 +1,6 @@
@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("hello");
- 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();
+ print(1234);
};
-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;
-};
diff --git a/code/main2.felan b/code/main2.felan
new file mode 100644
index 0000000..ffa3a5b
--- /dev/null
+++ b/code/main2.felan
@@ -0,0 +1,87 @@
+@import("basic.felan");
+
+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{
+ 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;
+ dx : i32 = 1;
+ dy : i32 = 1;
+ 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 += dx;
+ rect_posy += dy;
+ /*
+ print(rect_posx);
+ print_char(' ');
+ print(rect_posy);
+ print_char('\n');
+ */
+ if rect_posx >= screenWidth {
+ print("hello");
+ print(dx);
+ print("\n");
+ dx = @cast(-1,i32);
+ }else if rect_posx < @cast(0,i32) {
+ dx = @cast(1,i32);
+ }
+ if rect_posy >= screenHeight {
+ print("hi");
+ print(dy);
+ print("\n");
+ dy = @cast(-@cast(1,i32),i32);
+ }else if rect_posy < @cast(0,i32) {
+ dy = @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;
+}