diff options
| author | realtradam <[email protected]> | 2024-05-11 17:31:18 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2024-05-11 17:31:18 -0400 |
| commit | b34e7bd903f7c20912cfe696947641a7f37e029d (patch) | |
| tree | 08153acffa182ae56c3b61b5061699b09ad83953 | |
| parent | 3c1eda45872ce11e82cebc729dd1981e73b79b49 (diff) | |
| download | tojam2024-b34e7bd903f7c20912cfe696947641a7f37e029d.tar.gz tojam2024-b34e7bd903f7c20912cfe696947641a7f37e029d.zip | |
rendering player
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | src/main.c (renamed from main.c) | 31 | ||||
| -rw-r--r-- | src/player.c | 16 | ||||
| -rw-r--r-- | src/player.h | 14 | ||||
| -rw-r--r-- | src/second.c | 17 | ||||
| -rw-r--r-- | src/second.h | 1 |
6 files changed, 74 insertions, 13 deletions
@@ -1,7 +1,13 @@ BUILD_DIR=build +SRC_DIRS := ./src include $(N64_INST)/include/n64.mk -src = main.c +//src = src/main.c +src := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s') +OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) +DEPS := $(OBJS:.o=.d) +INC_DIRS := $(shell find $(SRC_DIRS) -type d) +N64_INCLUDEDIR := $(addprefix -I,$(INC_DIRS)) assets_png = $(wildcard assets/*.png) #assets_m3d = $(wildcard assets/*.m3d) @@ -24,12 +24,13 @@ bool flag=true; bool xflag=false; +#include "second.h" +#include "player.h" +Camera camera = { 0 }; - - -//void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured -//void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture +void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured +void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture void updateController() { @@ -49,6 +50,12 @@ extern Texture2D getFontGLTextureId(char *text); Rectangle src={0.0f,0.0f,5.0f,10.0f}; Rectangle dst={0.0f,0.0f,32.0f,32.0f}; +Player player_one = { + .position = { 0 }, + .direction = { 1, 0, 0 }, + .speed = 0 +}; + //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -64,7 +71,6 @@ int main(void) // Define the camera to look into our 3d world - Camera camera = { 0 }; camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; @@ -105,19 +111,20 @@ int main(void) BeginMode3D(camera); + drawPlayer(&player_one); + //DrawModel(model, position, 2.0f, WHITE); // Draw cube with an applied texture - //DrawCubeTexture(texture, (Vector3){ -0.0f, 0.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE); + //test(); + // Draw cube with an applied texture, but only a defined rectangle piece of the texture + //DrawCubeTextureRec(texture, (Rectangle){ 0, texture.height/2, texture.width/2, texture.height/2 }, + // (Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE); - // Draw cube with an applied texture, but only a defined rectangle piece of the texture - //DrawCubeTextureRec(texture, (Rectangle){ 0, texture.height/2, texture.width/2, texture.height/2 }, - // (Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE); + DrawGrid(10, 1.0f); // Draw a grid - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); + EndMode3D(); DrawFPS(10, 10); diff --git a/src/player.c b/src/player.c new file mode 100644 index 0000000..aca5a80 --- /dev/null +++ b/src/player.c @@ -0,0 +1,16 @@ +#include "player.h" + +void +drawPlayer(Player *player) +{ + //DrawCube(player->position, 1.0f, 1.0f, 1.0f, BLUE); + DrawSphereEx(player->position, 0.5f, 3, 3, BLUE); +} + +void +movePlayer(Player *player) +{ + player->position.x += player->direction.x * player->speed; + player->position.y += player->direction.y * player->speed; + player->position.z += player->direction.z * player->speed; +} diff --git a/src/player.h b/src/player.h new file mode 100644 index 0000000..4fea483 --- /dev/null +++ b/src/player.h @@ -0,0 +1,14 @@ +#include "raylib.h" + +typedef +struct +{ + Vector3 position; + Vector3 direction; + float speed; + +} +Player; + +void +drawPlayer(Player *player); diff --git a/src/second.c b/src/second.c new file mode 100644 index 0000000..d63296e --- /dev/null +++ b/src/second.c @@ -0,0 +1,17 @@ + +#include <stdio.h> +#include "second.h" +#include <raylib.h> + +void test(void) +{ + //TraceLog(3, "Test Worked\n"); + for(float i = -2; i <= 2; ++i) + { + for(float j = -2; j <= 2; ++j) + { + //DrawCubeTexture(texture, (Vector3){ i, 0.0f, j }, 1.0f, 1.0f, 1.0f, WHITE); + DrawCube((Vector3){ i, 0.0f, j }, 0.5f, 0.5f, 0.5f, RED); + } + } +} diff --git a/src/second.h b/src/second.h new file mode 100644 index 0000000..c0f76b7 --- /dev/null +++ b/src/second.h @@ -0,0 +1 @@ +void test(void); |
