Skip to content

Commit

Permalink
Raylib turned into small library
Browse files Browse the repository at this point in the history
  • Loading branch information
smaludzi committed Aug 6, 2020
1 parent 36cdae8 commit f417477
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 11 deletions.
24 changes: 13 additions & 11 deletions never.lang
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,25 @@
</context>

<context id="keywords" style-ref="keyword">
<keyword>let</keyword>
<keyword>var</keyword>
<keyword>func</keyword>
<keyword>catch</keyword>
<keyword>throw</keyword>
<keyword>while</keyword>
<keyword>do</keyword>
<keyword>for</keyword>
<keyword>if</keyword>
<keyword>else</keyword>
<keyword>record</keyword>
<keyword>nil</keyword>
<keyword>new</keyword>
<keyword>enum</keyword>
<keyword>in</keyword>
<keyword>extern</keyword>
<keyword>for</keyword>
<keyword>func</keyword>
<keyword>if</keyword>
<keyword>in</keyword>
<keyword>let</keyword>
<keyword>match</keyword>
<keyword>module</keyword>
<keyword>new</keyword>
<keyword>nil</keyword>
<keyword>record</keyword>
<keyword>throw</keyword>
<keyword>use</keyword>
<keyword>var</keyword>
<keyword>while</keyword>
</context>

<context id="operators" style-ref="operator">
Expand Down
40 changes: 40 additions & 0 deletions sample/lib/raylib.nev
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

module raylib
{
record Vector2
{
x : float;
y : float;
}

record Color
{
r : char;
g : char;
b : char;
a : char;
}

let MOUSE_LEFT_BUTTON = 0;
let MOUSE_RIGHT_BUTTON = 1;
let MOUSE_MIDDLE_BUTTON = 2;

let DARKBLUE = Color(chr(0), chr(82), chr(172), chr(255));
let DARKGRAY = Color(chr(80), chr(80), chr(80), chr(255));
let LIME = Color(chr(0), chr(158), chr(47), chr(255));
let MAROON = Color(chr(190), chr(33), chr(55), chr(255));
let RAYWHITE = Color(chr(245), chr(245), chr(245), chr(245));

extern "../../raylib/src/libraylib.so" func InitWindow(width : int, height : int, title : string) -> void
extern "../../raylib/src/libraylib.so" func SetTargetFPS(fps : int) -> void
extern "../../raylib/src/libraylib.so" func WindowShouldClose() -> bool
extern "../../raylib/src/libraylib.so" func CloseWindow() -> void
extern "../../raylib/src/libraylib.so" func GetMousePosition() -> Vector2
extern "../../raylib/src/libraylib.so" func IsMouseButtonPressed(button : int) -> bool
extern "../../raylib/src/libraylib.so" func BeginDrawing() -> void
extern "../../raylib/src/libraylib.so" func EndDrawing() -> void
extern "../../raylib/src/libraylib.so" func ClearBackground(color : Color) -> void
extern "../../raylib/src/libraylib.so" func DrawCircleV(center : Vector2, radius : float, color : Color) -> void
extern "../../raylib/src/libraylib.so" func DrawText(text : string, posX : int, posY : int, fontSize : int, color : Color) -> void
}

51 changes: 51 additions & 0 deletions sample/sample_raylib_module.nev
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

use raylib

let screenWidth = 800;
let screenHeight = 450;

func main() -> int
{
/*
let ballPosition = raylib.Vector2( -100.0, -100.0 );
let ballColor = raylib.Color;

ballColor = raylib.DARKBLUE;

raylib.InitWindow(screenWidth, screenHeight, "Never meets raylib");
raylib.SetTargetFPS(60);

while (!raylib.WindowShouldClose())
{
ballPosition = raylib.GetMousePosition();

if (raylib.IsMouseButtonPressed(raylib.MOUSE_LEFT_BUTTON))
{
ballColor = raylib.MAROON
}
else if (raylib.IsMouseButtonPressed(raylib.MOUSE_MIDDLE_BUTTON))
{
ballColor = raylib.LIME
}
else if (raylib.IsMouseButtonPressed(raylib.MOUSE_RIGHT_BUTTON))
{
ballColor = raylib.DARKBLUE
}
else
{
ballColor
};

raylib.BeginDrawing();

raylib.ClearBackground(raylib.RAYWHITE);
raylib.DrawCircleV(ballPosition, 40.0, ballColor);
raylib.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, raylib.DARKGRAY);

raylib.EndDrawing()
};

raylib.CloseWindow();
*/
0
}

0 comments on commit f417477

Please sign in to comment.