Skip to content

Commit

Permalink
Updates with enums
Browse files Browse the repository at this point in the history
  • Loading branch information
smaludzi committed Sep 8, 2020
1 parent cfc7bda commit a416b1b
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 175 deletions.
6 changes: 2 additions & 4 deletions examples/core_3d_camera_first_person.nev
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/

/***
* A small hack in raylib library is needed
*
Expand All @@ -36,7 +35,6 @@
* }
*
*/

use raylib
use raylib_camera
use raylib_models
Expand Down Expand Up @@ -64,7 +62,7 @@ func main() -> int
camera.target = raylib.Vector3(0.0, 1.8, 0.0);
camera.up = raylib.Vector3(0.0, 1.0, 0.0);
camera.fovy = 60.0;
camera.type = raylib_camera.CAMERA_PERSPECTIVE;
camera.type = raylib_camera.CameraType::CAMERA_PERSPECTIVE;

/* Generates some random columns */
for (i = 0; i < MAX_COLUMNS; i = i + 1)
Expand All @@ -75,7 +73,7 @@ func main() -> int
};

/* Set a first person camera mode */
raylib_camera.SetCameraMode(camera, raylib_camera.CAMERA_FIRST_PERSON);
raylib_camera.SetCameraMode(camera, raylib_camera.CameraMode::CAMERA_FIRST_PERSON);

/* Set our game to run at 60 frames-per-second */
raylib.SetTargetFPS(200);
Expand Down
7 changes: 3 additions & 4 deletions examples/core_input_mouse.nev
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/

use raylib
use raylib_mouse
use raylib_shapes
Expand All @@ -46,15 +45,15 @@ func main() -> int
{
ballPosition = raylib_mouse.GetMousePosition();

if (raylib_mouse.IsMouseButtonPressed(raylib_mouse.MOUSE_LEFT_BUTTON))
if (raylib_mouse.IsMouseButtonPressed(raylib_mouse.MouseButton::MOUSE_LEFT_BUTTON))
{
ballColor = raylib.MAROON
}
else if (raylib_mouse.IsMouseButtonPressed(raylib_mouse.MOUSE_MIDDLE_BUTTON))
else if (raylib_mouse.IsMouseButtonPressed(raylib_mouse.MouseButton::MOUSE_MIDDLE_BUTTON))
{
ballColor = raylib.LIME
}
else if (raylib_mouse.IsMouseButtonPressed(raylib_mouse.MOUSE_RIGHT_BUTTON))
else if (raylib_mouse.IsMouseButtonPressed(raylib_mouse.MouseButton::MOUSE_RIGHT_BUTTON))
{
ballColor = raylib.DARKBLUE
}
Expand Down
17 changes: 11 additions & 6 deletions examples/core_input_mouse_ffi.nev
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/

record Vector2
{
x : float;
Expand All @@ -37,9 +38,12 @@ record Color
a : char;
}

let MOUSE_LEFT_BUTTON = 0;
let MOUSE_RIGHT_BUTTON = 1;
let MOUSE_MIDDLE_BUTTON = 2;
enum MouseButton
{
MOUSE_LEFT_BUTTON = 0,
MOUSE_RIGHT_BUTTON = 1,
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));
Expand Down Expand Up @@ -76,15 +80,15 @@ func main() -> int
{
ballPosition = GetMousePosition();

if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton::MOUSE_LEFT_BUTTON))
{
ballColor = MAROON
}
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON))
else if (IsMouseButtonPressed(MouseButton::MOUSE_MIDDLE_BUTTON))
{
ballColor = LIME
}
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON))
else if (IsMouseButtonPressed(MouseButton::MOUSE_RIGHT_BUTTON))
{
ballColor = DARKBLUE
}
Expand All @@ -106,3 +110,4 @@ func main() -> int

0
}

27 changes: 26 additions & 1 deletion examples/models_waving_cubes.nev
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/**********************************************************************************************
* LICENSE: zlib/libpng
*
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software:
*
* Copyright (c) 2013-2020 Ramon Santamaria (@raysan5)
* Copyright (c) 2020 Slawomir Maludzinski (binding to Never language)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
/*******************************************************************************************
*
* raylib [models] example - Waving cubes
Expand Down Expand Up @@ -45,7 +70,7 @@ func main() -> int
camera.target = raylib.Vector3(0.0f, 0.0f, 0.0f);
camera.up = raylib.Vector3(0.0f, 1.0f, 0.0f);
camera.fovy = 70.0f;
camera.type = raylib_camera.CAMERA_PERSPECTIVE;
camera.type = raylib_camera.CameraType::CAMERA_PERSPECTIVE;

raylib.SetTargetFPS(60);

Expand Down
20 changes: 13 additions & 7 deletions lib/raylib_camera.nev
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ module raylib_camera
{
use raylib

let CAMERA_PERSPECTIVE = 0;
let CAMERA_ORTHOGRAPHIC = 1;
enum CameraType
{
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC = 1
}

let CAMERA_CUSTOM = 0;
let CAMERA_FREE = 1;
let CAMERA_ORBITAL = 2;
let CAMERA_FIRST_PERSON = 3;
let CAMERA_THIRD_PERSON = 4;
enum CameraMode
{
CAMERA_CUSTOM = 0,
CAMERA_FREE = 1,
CAMERA_ORBITAL = 2,
CAMERA_FIRST_PERSON = 3,
CAMERA_THIRD_PERSON = 4
}

/* Camera System Functions (Module: camera) */
extern "libraylib.so" func SetCameraMode(camera : raylib.Camera3D, mode : int) -> void
Expand Down
93 changes: 51 additions & 42 deletions lib/raylib_gamepad.nev
Original file line number Diff line number Diff line change
Expand Up @@ -25,58 +25,67 @@
**********************************************************************************************/
module raylib_gamepad
{
let GAMEPAD_PLAYER1 = 0;
let GAMEPAD_PLAYER2 = 1;
let GAMEPAD_PLAYER3 = 2;
let GAMEPAD_PLAYER4 = 3;
enum GamepadNumber
{
GAMEPAD_PLAYER1 = 0,
GAMEPAD_PLAYER2 = 1,
GAMEPAD_PLAYER3 = 2,
GAMEPAD_PLAYER4 = 3
}

/* This is here just for error checking */
let GAMEPAD_BUTTON_UNKNOWN = 0;
enum GamepadButton
{
/* This is here just for error checking */
GAMEPAD_BUTTON_UNKNOWN = 0,

/* This is normally a DPAD */
let GAMEPAD_BUTTON_LEFT_FACE_UP = 1;
let GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2;
let GAMEPAD_BUTTON_LEFT_FACE_DOWN = 3;
let GAMEPAD_BUTTON_LEFT_FACE_LEFT = 4;
/* This is normally a DPAD */
GAMEPAD_BUTTON_LEFT_FACE_UP = 1,
GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2,
GAMEPAD_BUTTON_LEFT_FACE_DOWN = 3,
GAMEPAD_BUTTON_LEFT_FACE_LEFT = 4,

/* This normally corresponds with PlayStation and Xbox controllers */
/* XBOX: [Y;X;A;B] */
/* PS3: [Triangle;Square;Cross;Circle] */
/* No support for 6 button controllers though.. */
let GAMEPAD_BUTTON_RIGHT_FACE_UP = 5;
let GAMEPAD_BUTTON_RIGHT_FACE_RIGHT = 6;
let GAMEPAD_BUTTON_RIGHT_FACE_DOWN = 7;
let GAMEPAD_BUTTON_RIGHT_FACE_LEFT = 8;
/* This normally corresponds with PlayStation and Xbox controllers */
/* XBOX: [Y;X;A;B] */
/* PS3: [Triangle;Square;Cross;Circle] */
/* No support for 6 button controllers though.. */
GAMEPAD_BUTTON_RIGHT_FACE_UP = 5,
GAMEPAD_BUTTON_RIGHT_FACE_RIGHT = 6,
GAMEPAD_BUTTON_RIGHT_FACE_DOWN = 7,
GAMEPAD_BUTTON_RIGHT_FACE_LEFT = 8,

/* Triggers */
let GAMEPAD_BUTTON_LEFT_TRIGGER_1 = 9;
let GAMEPAD_BUTTON_LEFT_TRIGGER_2 = 10;
let GAMEPAD_BUTTON_RIGHT_TRIGGER_1 = 11;
let GAMEPAD_BUTTON_RIGHT_TRIGGER_2 = 12;
/* Triggers */
GAMEPAD_BUTTON_LEFT_TRIGGER_1 = 9,
GAMEPAD_BUTTON_LEFT_TRIGGER_2 = 10,
GAMEPAD_BUTTON_RIGHT_TRIGGER_1 = 11,
GAMEPAD_BUTTON_RIGHT_TRIGGER_2 = 12,

/* These are buttons in the center of the gamepad */
let GAMEPAD_BUTTON_MIDDLE_LEFT = 13; /* PS3 Select */
let GAMEPAD_BUTTON_MIDDLE = 14; /* PS Button/XBOX Button */
let GAMEPAD_BUTTON_MIDDLE_RIGHT = 15; /* PS3 Start */
/* These are buttons in the center of the gamepad */
GAMEPAD_BUTTON_MIDDLE_LEFT = 13, /* PS3 Select */
GAMEPAD_BUTTON_MIDDLE = 14, /* PS Button/XBOX Button */
GAMEPAD_BUTTON_MIDDLE_RIGHT = 15, /* PS3 Start */

/* These are the joystick press in buttons */
let GAMEPAD_BUTTON_LEFT_THUMB = 16;
let GAMEPAD_BUTTON_RIGHT_THUMB = 17;
/* These are the joystick press in buttons */
GAMEPAD_BUTTON_LEFT_THUMB = 16,
GAMEPAD_BUTTON_RIGHT_THUMB = 17
}

/* This is here just for error checking */
let GAMEPAD_AXIS_UNKNOWN = 0;
enum GamepadAxis
{
/* This is here just for error checking */
GAMEPAD_AXIS_UNKNOWN = 0,

/* Left stick */
let GAMEPAD_AXIS_LEFT_X = 1;
let GAMEPAD_AXIS_LEFT_Y = 2;
/* Left stick */
GAMEPAD_AXIS_LEFT_X = 1,
GAMEPAD_AXIS_LEFT_Y = 2,

/* Right stick */
let GAMEPAD_AXIS_RIGHT_X = 3;
let GAMEPAD_AXIS_RIGHT_Y = 4;
/* Right stick */
GAMEPAD_AXIS_RIGHT_X = 3,
GAMEPAD_AXIS_RIGHT_Y = 4,

/* Pressure levels for the back triggers */
let GAMEPAD_AXIS_LEFT_TRIGGER = 5; /* [1..-1] (pressure-level) */
let GAMEPAD_AXIS_RIGHT_TRIGGER = 6; /* [1..-1] (pressure-level) */
/* Pressure levels for the back triggers */
GAMEPAD_AXIS_LEFT_TRIGGER = 5, /* [1..-1] (pressure-level) */
GAMEPAD_AXIS_RIGHT_TRIGGER = 6 /* [1..-1] (pressure-level) */
}

/* Input-related functions: gamepads */
extern "libraylib.so" func IsGamepadAvailable(gamepad : int) -> bool /* Detect if a gamepad is available */
Expand Down
Loading

0 comments on commit a416b1b

Please sign in to comment.