From 59cf0f6a4249401528e933f1d70c33db0f1e382f Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 30 Dec 2015 13:42:59 +0100 Subject: Update and rename physics.h to physac.h --- src/physac.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/physics.h | 99 ----------------------------------------------------------- 2 files changed, 99 insertions(+), 99 deletions(-) create mode 100644 src/physac.h delete mode 100644 src/physics.h (limited to 'src') diff --git a/src/physac.h b/src/physac.h new file mode 100644 index 00000000..aec57d6f --- /dev/null +++ b/src/physac.h @@ -0,0 +1,99 @@ +/********************************************************************************************** +* +* raylib physics engine module - Basic functions to apply physics to 2D objects +* +* Copyright (c) 2015 Victor Fisac and Ramon Santamaria +* +* 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. +* +**********************************************************************************************/ + +#ifndef PHYSAC_H +#define PHYSAC_H + +//---------------------------------------------------------------------------------- +// Defines and Macros +//---------------------------------------------------------------------------------- +// ... + +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- +typedef enum { RectangleCollider, CircleCollider } ColliderType; + +// Physics struct +typedef struct Physics { + bool enabled; + bool debug; // Should be used by programmer for testing purposes + Vector2 gravity; +} Physics; + +// Transform struct +typedef struct Transform { + Vector2 position; + float rotation; + Vector2 scale; +} Transform; + +// Rigidbody struct +typedef struct Rigidbody { + bool enabled; + float mass; + Vector2 acceleration; + Vector2 velocity; + bool isGrounded; + bool isContact; // Avoid freeze player when touching floor + bool applyGravity; + float friction; // 0.0f to 1.0f + float bounciness; // 0.0f to 1.0f +} Rigidbody; + +// Collider struct +typedef struct Collider { + bool enabled; + ColliderType type; + Rectangle bounds; // Just used for RectangleCollider type + int radius; // Just used for CircleCollider type +} Collider; + +#ifdef __cplusplus +extern "C" { // Prevents name mangling of functions +#endif + +//---------------------------------------------------------------------------------- +// Module Functions Declaration +//---------------------------------------------------------------------------------- +void InitPhysics(); // Initialize all internal physics values +void SetPhysics(Physics settings); // Set physics settings values using Physics data type to overwrite internal physics settings + +void AddRigidbody(int index, Rigidbody rigidbody); // Initialize a new rigidbody with parameters to internal index slot +void AddCollider(int index, Collider collider); // Initialize a new Collider with parameters to internal index slot + +void ApplyPhysics(int index, Vector2 *position); // Apply physics to internal rigidbody, physics calculations are applied to position pointer parameter +void SetRigidbodyEnabled(int index, bool state); // Set enabled state to a defined rigidbody +void SetRigidbodyVelocity(int index, Vector2 velocity); // Set velocity of rigidbody (without considering of mass value) +void AddRigidbodyForce(int index, Vector2 force); // Set rigidbody force (considering mass value) + +void SetColliderEnabled(int index, bool state); // Set enabled state to a defined collider + +Rigidbody GetRigidbody(int index); // Returns the internal rigidbody data defined by index parameter +Collider GetCollider(int index); // Returns the internal collider data defined by index parameter + +#ifdef __cplusplus +} +#endif + +#endif // PHYSAC_H diff --git a/src/physics.h b/src/physics.h deleted file mode 100644 index 211f31a2..00000000 --- a/src/physics.h +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************************************** -* -* raylib physics engine module - Basic functions to apply physics to 2D objects -* -* Copyright (c) 2015 Victor Fisac and Ramon Santamaria -* -* 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. -* -**********************************************************************************************/ - -#ifndef PHYSICS_H -#define PHYSICS_H - -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -// ... - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum { RectangleCollider, CircleCollider } ColliderType; - -// Physics struct -typedef struct Physics { - bool enabled; - bool debug; // Should be used by programmer for testing purposes - Vector2 gravity; -} Physics; - -// Transform struct -typedef struct Transform { - Vector2 position; - float rotation; - Vector2 scale; -} Transform; - -// Rigidbody struct -typedef struct Rigidbody { - bool enabled; - float mass; - Vector2 acceleration; - Vector2 velocity; - bool isGrounded; - bool isContact; // Avoid freeze player when touching floor - bool applyGravity; - float friction; // 0.0f to 1.0f - float bounciness; // 0.0f to 1.0f -} Rigidbody; - -// Collider struct -typedef struct Collider { - bool enabled; - ColliderType type; - Rectangle bounds; // Just used for RectangleCollider type - int radius; // Just used for CircleCollider type -} Collider; - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Module Functions Declaration -//---------------------------------------------------------------------------------- -void InitPhysics(); // Initialize all internal physics values -void SetPhysics(Physics settings); // Set physics settings values using Physics data type to overwrite internal physics settings - -void AddRigidbody(int index, Rigidbody rigidbody); // Initialize a new rigidbody with parameters to internal index slot -void AddCollider(int index, Collider collider); // Initialize a new Collider with parameters to internal index slot - -void ApplyPhysics(int index, Vector2 *position); // Apply physics to internal rigidbody, physics calculations are applied to position pointer parameter -void SetRigidbodyEnabled(int index, bool state); // Set enabled state to a defined rigidbody -void SetRigidbodyVelocity(int index, Vector2 velocity); // Set velocity of rigidbody (without considering of mass value) -void AddRigidbodyForce(int index, Vector2 force); // Set rigidbody force (considering mass value) - -void SetColliderEnabled(int index, bool state); // Set enabled state to a defined collider - -Rigidbody GetRigidbody(int index); // Returns the internal rigidbody data defined by index parameter -Collider GetCollider(int index); // Returns the internal collider data defined by index parameter - -#ifdef __cplusplus -} -#endif - -#endif // PHYSICS_H \ No newline at end of file -- cgit v1.2.3