Dumb-ways-to-memorize
2D game
|
#include "entity.h"
Go to the source code of this file.
Enumerations | |
enum | physics_laws_t { PHYSICS_NULL = 0, PHYSICS_BASE_FRICTION = 1, PHYSICS_BASE_SPEED_X = 5, PHYSICS_BASE_SPEED_Y = 10, PHYSICS_MAX_SPEED = 16, PHYSICS_MAX } |
Functions | |
void | RunPhysics () |
int | CheckCollision (entity_t *self, entity_t *other) |
void | DoCollision (entity_t *self, entity_t *other) |
void | ApplySpeedLimit (vec2_t *a) |
void | ApplyBounds (entity_t *ent) |
void | ApplyFriction (vec2_t *a) |
enum physics_laws_t |
Defines the Preset Physics values
Definition at line 7 of file dumb_physics.h.
void ApplyBounds | ( | entity_t * | ent | ) |
Applies the bounds to specified ent, defined by the screen dimensions.
[in,out] | ent | If non-null, the ent. |
Definition at line 168 of file dumb_physics.c.
References gScreenHeight, gScreenWidth, and PHYSICS_MAX_SPEED.
Referenced by RunPhysics().
void ApplyFriction | ( | vec2_t * | a | ) |
Applies the friction to vector a, for the nonzero values. Uses Physics_base_friction for friction coefficient.
[in,out] | a | If non-null, the vec2_t to process. |
Definition at line 194 of file dumb_physics.c.
References PHYSICS_BASE_FRICTION, vec2_t::x, and vec2_t::y.
Referenced by RunPhysics().
void ApplySpeedLimit | ( | vec2_t * | a | ) |
Applies the speed limit to vector a, defined by physics max speed.
[in,out] | a | If non-null, the vec2_t to process. |
Definition at line 162 of file dumb_physics.c.
References PHYSICS_MAX_SPEED, vec2_t::x, and vec2_t::y.
Referenced by RunPhysics().
int CheckCollision | ( | entity_t * | self, |
entity_t * | other | ||
) |
Check collision between entities. (AABB)
[in,out] | self | If non-null, the class instance that this method operates on. |
[in,out] | other | If non-null, the other. |
Definition at line 57 of file dumb_physics.c.
References COLLISION_TYPE_CLIP.
Referenced by RunPhysics().
void DoCollision | ( | entity_t * | self, |
entity_t * | other | ||
) |
Executes the collision operation. Place self farthest x or y away from other, vice versa. And negative the velocity to half of orginal collision vel, for bounce back.
[in,out] | self | If non-null, the class instance that this method operates on. |
[in,out] | other | If non-null, the other. |
Definition at line 75 of file dumb_physics.c.
References COLLISION_TYPE_RAGDOLL, Vec2Add(), vec2_t::x, and vec2_t::y.
Referenced by RunPhysics().
void RunPhysics | ( | ) |
Executes physics. RunTime O( n(n+1)/2 ) Applies velocity, acceleration, gravity, and friction. Limits velocity, acceleration, and sets bounds.
Definition at line 9 of file dumb_physics.c.
References ApplyBounds(), ApplyFriction(), ApplySpeedLimit(), CheckCollision(), COLLISION_TYPE_STATIC, DoCollision(), gEntities, MAX_ENTITIES, PHYSICS_LIMITER, Vec2Add(), and vec2_t::y.
Referenced by UpdatePlaying().