Skip to content

Commit

Permalink
mp models
Browse files Browse the repository at this point in the history
  • Loading branch information
s4Ys369 committed Jun 25, 2024
1 parent 94cd1c1 commit 655f248
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 10 deletions.
Binary file modified assets/frog.blend
Binary file not shown.
Binary file modified assets/frog.glb
Binary file not shown.
Binary file added assets/frogA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/frogB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/frogC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/frog_p2.glb
Binary file not shown.
Binary file added assets/frog_p3.glb
Binary file not shown.
Binary file added assets/frog_p4.glb
Binary file not shown.
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// SEED is used to place objects at random
#define SEED 1234
#define NUM_PLAYERS 4
#define NUM_PLAYERS 2
#define NUM_LILYPADS 5
#define NUM_SPRINGS 5
#define NUM_FLYS 10
Expand Down
8 changes: 2 additions & 6 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void draw_debug_ui(void){
t3d_debug_print_start();

float posX = 12;
float posY = 12;

int text_debug = 0;
int text_controls = 0;

Expand All @@ -46,11 +46,7 @@ void draw_debug_ui(void){

rdpq_set_prim_color(RGBA32(0xFF, 0xFF, 0xFF, 0xFF));
if (text_debug){
t3d_debug_printf(posX, posY+50, "camPos\n");
t3d_debug_printf(posX, posY+60, "%.0f %.0f %.0f\n", camPos[0].v[0], camPos[0].v[1], camPos[0].v[2]);
t3d_debug_printf(posX, posY+70, "camFocus\n");
t3d_debug_printf(posX, posY+80, "%.0f %.0f %.0f\n", camTarget[0].v[0], camTarget[0].v[1], camTarget[0].v[2]);
t3d_debug_printf(posX, posY+90, "camMode%u", cam_mode[0]);

}

rdpq_set_prim_color(RGBA32(0xAA, 0xAA, 0xAA, 0xFF));
Expand Down
5 changes: 4 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ int main()
t3d_viewport_attach(vp);
t3d_light_set_directional(0, colorDir, &lightDirVec);

for (int i = 0; i < NUM_PLAYERS; ++i) {
rspq_block_run(dplFrog[i]);
}

t3d_matrix_push_pos(1);
rspq_block_run(dplMap);
t3d_matrix_pop(1);
Expand All @@ -186,7 +190,6 @@ int main()
t3d_matrix_push_pos(1);
for (int i = 0; i < NUM_PLAYERS; ++i) {
rspq_block_run(dplShadow[i]);
rspq_block_run(dplFrog[i]);
if(player[i].tongue[i].isActive == true) {
rspq_block_run(dplTongue[i]);
}
Expand Down
46 changes: 44 additions & 2 deletions src/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ T3DMat4FP* tongueMatFP[NUM_PLAYERS];
T3DMat4FP* sphereMatFP[NUM_PLAYERS];
T3DMat4FP* sphere2MatFP[NUM_PLAYERS];
T3DModel *model[NUM_PLAYERS];
T3DModel *modelP1;
T3DModel *modelP2;
T3DModel *modelP3;
T3DModel *modelP4;
T3DModel *modelTongue[NUM_PLAYERS];
T3DModel *modelShadow[NUM_PLAYERS];
T3DSkeleton skel[NUM_PLAYERS];
Expand All @@ -42,14 +46,51 @@ rspq_block_t *dplShadow[NUM_PLAYERS];
PlayerParams player[NUM_PLAYERS];

void player_init(void){

modelP1 = t3d_model_load("rom:/frog.t3dm");
if(NUM_PLAYERS > 1){
if(NUM_PLAYERS == 2){
modelP2 = t3d_model_load("rom:/frog_p2.t3dm");
}
if(NUM_PLAYERS == 3){
modelP2 = t3d_model_load("rom:/frog_p2.t3dm");
modelP3 = t3d_model_load("rom:/frog_p3.t3dm");
}
if(NUM_PLAYERS == 4){
modelP2 = t3d_model_load("rom:/frog_p2.t3dm");
modelP3 = t3d_model_load("rom:/frog_p3.t3dm");
modelP4 = t3d_model_load("rom:/frog_p4.t3dm");
}
}

switch(NUM_PLAYERS){
case 1:
model[0] = modelP1;
break;
case 2:
model[0] = modelP1;
model[1] = modelP2;
break;
case 3:
model[0] = modelP1;
model[1] = modelP2;
model[2] = modelP3;
break;
case 4:
model[0] = modelP1;
model[1] = modelP2;
model[2] = modelP3;
model[3] = modelP4;
break;
}

for (int i = 0; i < NUM_PLAYERS; ++i) {
modelMatFP[i] = malloc_uncached(sizeof(T3DMat4FP));
shadowMatFP[i] = malloc_uncached(sizeof(T3DMat4FP));
tongueMatFP[i] = malloc_uncached(sizeof(T3DMat4FP));

sphereMatFP[i] = malloc_uncached(sizeof(T3DMat4FP));
sphere2MatFP[i] = malloc_uncached(sizeof(T3DMat4FP));
model[i] = t3d_model_load("rom:/frog.t3dm");
modelTongue[i] = t3d_model_load("rom:/tongue.t3dm");
modelShadow[i] = t3d_model_load("rom:/shadow.t3dm");
skel[i] = t3d_skeleton_create(model[i]);
Expand Down Expand Up @@ -94,9 +135,10 @@ void player_init(void){
dplDebugSphere2[i] = rspq_block_end();

rspq_block_begin();
t3d_matrix_set(modelMatFP[i], true);
t3d_matrix_push(modelMatFP[i]);
rdpq_set_prim_color(RGBA32(255, 255, 255, 255));
t3d_model_draw_skinned(model[i], &skel[i]);
t3d_matrix_pop(1);
dplFrog[i] = rspq_block_end();

rspq_block_begin();
Expand Down
4 changes: 4 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ extern T3DMat4FP* tongueMatFP[NUM_PLAYERS];
extern T3DMat4FP* sphereMatFP[NUM_PLAYERS];
extern T3DMat4FP* sphere2MatFP[NUM_PLAYERS];
extern T3DModel *model[NUM_PLAYERS];
extern T3DModel *modelP1;
extern T3DModel *modelP2;
extern T3DModel *modelP3;
extern T3DModel *modelP4;
extern T3DModel *modelTongue[NUM_PLAYERS];
extern T3DModel *modelShadow[NUM_PLAYERS];
extern T3DSkeleton skel[NUM_PLAYERS];
Expand Down

0 comments on commit 655f248

Please sign in to comment.