WIP docs: commenting in player.c/player.h and README updates
This commit is contained in:
@@ -10,6 +10,8 @@ It consists of several components:
|
|||||||
- `src/main.c`, Main script. Takes all other src and actually renders the engine.
|
- `src/main.c`, Main script. Takes all other src and actually renders the engine.
|
||||||
- `src/physics.c`, All the science & math crap. Ugh. (physics.h: exposes UpdateEntities function)
|
- `src/physics.c`, All the science & math crap. Ugh. (physics.h: exposes UpdateEntities function)
|
||||||
- `src/render.c`, Rendering of entities. Entities are currently limited to rectangles for... no particular reason. (render.h: exposes DrawEntities function)
|
- `src/render.c`, Rendering of entities. Entities are currently limited to rectangles for... no particular reason. (render.h: exposes DrawEntities function)
|
||||||
|
- `src/player.c`, Player control scripting. (player.h: exposes UpdatePlayerControls function)
|
||||||
|
|
||||||
|
|
||||||
- More stuff in src. README in progress.
|
- More stuff in src. README in progress.
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
main.c - Done
|
main.c - Done
|
||||||
physics.c - Done, refine later
|
physics.c - Done, refine later
|
||||||
physics.h - Done
|
physics.h - Done
|
||||||
renderer.c - Done
|
render.c - Done
|
||||||
renderer.h - Done
|
render.h - Done
|
||||||
player.c
|
player.c - Done
|
||||||
player.h
|
player.h - Done
|
||||||
world.c
|
world.c
|
||||||
world.h
|
world.h
|
||||||
config.h
|
config.h
|
||||||
|
|||||||
@@ -5,11 +5,15 @@
|
|||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
// let's a go!
|
||||||
|
|
||||||
void UpdatePlayerControls(void)
|
void UpdatePlayerControls(void)
|
||||||
{
|
{
|
||||||
|
// if there isn't a player, you probably can't do much
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// if a key pressed, push player to the left
|
||||||
if (IsKeyDown(KEY_A))
|
if (IsKeyDown(KEY_A))
|
||||||
{
|
{
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
@@ -17,7 +21,7 @@ void UpdatePlayerControls(void)
|
|||||||
(Vector2){-PLAYER_FORCE, 0}
|
(Vector2){-PLAYER_FORCE, 0}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// if d key pressed, push player to the right
|
||||||
if (IsKeyDown(KEY_D))
|
if (IsKeyDown(KEY_D))
|
||||||
{
|
{
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
@@ -25,7 +29,7 @@ void UpdatePlayerControls(void)
|
|||||||
(Vector2){PLAYER_FORCE, 0}
|
(Vector2){PLAYER_FORCE, 0}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// if sspace key pressed (and player isn't already jumping), push player upward
|
||||||
if (IsGrounded(player) &&
|
if (IsGrounded(player) &&
|
||||||
IsKeyPressed(KEY_SPACE))
|
IsKeyPressed(KEY_SPACE))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef PLAYER_H
|
#ifndef PLAYER_H
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
|
|
||||||
|
// FUNction declaration! yay!!!
|
||||||
|
// run by main.c constantly to allow player input.
|
||||||
void UpdatePlayerControls(void);
|
void UpdatePlayerControls(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user