Skip to content

Commit

Permalink
qol fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
s4Ys369 committed Jun 26, 2024
1 parent dc264bd commit c611363
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <t3d/t3d.h>

// SEED is used to place objects at random
#define SEED 564
#define NUM_PLAYERS 1
#define SEED 6969
#define NUM_PLAYERS 3
#define NUM_HILLS 5
#define NUM_LILYPADS 5
#define NUM_SPRINGS 5
Expand Down
7 changes: 4 additions & 3 deletions src/actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,12 @@ void fly_update(void){
t3d_vec3_norm(&normalizedDir);

// Calculate yaw (rotation around y-axis)
flyYaw[i] = atan2f(normalizedDir.v[0], normalizedDir.v[2]);
t3d_lerp_angle((normalizedDir.v[0] * flyYaw[i]), (normalizedDir.v[2] * flyYaw[i]), deltaTime/0.1f);
float newYaw = atan2f(normalizedDir.v[0], normalizedDir.v[2]);
flyYaw[i] = t3d_lerp_angle(flyYaw[i], newYaw, 0.5f);

// Calculate pitch (rotation around x-axis)
flyPitch[i] = asinf((normalizedDir.v[1] * deltaTime));
float newPitch = asinf((normalizedDir.v[1]));
flyPitch[i] = t3d_lerp_angle(flyPitch[i], newPitch, 0.5f);

flyPos[i].v[0] += flyDir[i].v[0] * flySpeed[i] * deltaTime;
flyPos[i].v[1] += flyDir[i].v[1] * flySpeed[i] * deltaTime;
Expand Down
2 changes: 1 addition & 1 deletion src/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#endif

T3DVec3 lightDirVec;
uint8_t colorAmbient[4] = {0xAA, 0xAA, 0xAA, 0xFF};
uint8_t colorAmbient[4] = {0x69, 0x64, 0x5D, 0xFF};
uint8_t colorDir[4] = {0xFF, 0xAA, 0xAA, 0xFF};
T3DViewport viewport[NUM_PLAYERS];
T3DVec3 camPos[NUM_PLAYERS];
Expand Down
2 changes: 1 addition & 1 deletion src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void draw_debug_ui(void){
if(NUM_PLAYERS == 3) {
t3d_debug_printf(posX, posY/2, "SCORE %d", player[0].score);
t3d_debug_printf(posX, posY, "SCORE %d", player[1].score);
t3d_debug_printf((posX*14)+4, posY, "SCORE %d", player[2].score);
t3d_debug_printf((posX*14)+4, posY+20, "SCORE %d", player[2].score);
}
if(NUM_PLAYERS == 4) {
t3d_debug_printf(posX, posY/2, "SCORE %d", player[0].score);
Expand Down
26 changes: 23 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ int main()


if (!btnheld[0].start){
sound_update_buffer();
if(NUM_PLAYERS < 3){
sound_update_buffer();
}

// CAMERA_LOGIC
cam_update();
Expand Down Expand Up @@ -144,19 +146,37 @@ int main()
rdpq_attach(display_get(), &depthBuffer);
t3d_frame_start();

t3d_screen_clear_color(RGBA32(155, 242, 238, 0xFF));
color_t fogColor = (color_t){0x12, 0x03, 0x21, 0xFF};
rdpq_set_prim_color((color_t){0x12, 0x03, 0x21, 0xFF});
rdpq_mode_fog(RDPQ_FOG_STANDARD);
rdpq_set_fog_color(fogColor);

t3d_screen_clear_color(fogColor);
t3d_screen_clear_depth();

t3d_fog_set_range(20.0f, 80.0f);
t3d_fog_set_enabled(true);

t3d_light_set_ambient(colorAmbient);
t3d_light_set_count(1);

// Run gfx calls
float fov = T3D_DEG_TO_RAD(75.0f);
float fov2p = T3D_DEG_TO_RAD(50.0f);
for (int i = 0; i < NUM_PLAYERS; ++i) {
T3DViewport *vp = &viewport[i];
T3DVec3 CP = camPos[i];
T3DVec3 CT = camTarget[i];

t3d_viewport_set_projection(vp, T3D_DEG_TO_RAD(85.0f), 10.0f, 150.0f);
if (NUM_PLAYERS == 2){
t3d_viewport_set_projection(vp, fov2p, 10.0f, 150.0f);
}else if (NUM_PLAYERS == 3){
t3d_viewport_set_projection(&viewport[0], fov2p, 10.0f, 150.0f);
t3d_viewport_set_projection(&viewport[1], fov, 10.0f, 150.0f);
t3d_viewport_set_projection(&viewport[2], fov, 10.0f, 150.0f);
} else {
t3d_viewport_set_projection(vp, fov, 10.0f, 150.0f);
}
t3d_viewport_look_at(vp, &CP, &CT, &(T3DVec3){{0,1,0}});
t3d_viewport_attach(vp);
t3d_light_set_directional(0, colorDir, &lightDirVec);
Expand Down

0 comments on commit c611363

Please sign in to comment.