Fix pad, slightly better jump, respawn actor when falling from level
This commit is contained in:
parent
9447dabd21
commit
044ec65e22
@ -1,5 +1,5 @@
|
||||
#define VMODE 0 // 0 == NTSC, 1 == PAL
|
||||
#define VSYNC 0
|
||||
#define VSYNC 1
|
||||
#define SCREENXRES 320
|
||||
#define SCREENYRES 240
|
||||
#define CENTERX SCREENXRES/2
|
||||
@ -74,11 +74,17 @@ asm(\
|
||||
#define PadRight ( 1 << 5 )
|
||||
#define PadDown ( 1 << 6 )
|
||||
#define PadLeft ( 1 << 7 )
|
||||
|
||||
#define Tri ( 1 << 12 )
|
||||
#define Circ ( 1 << 13 )
|
||||
#define Cross ( 1 << 14 )
|
||||
#define Squar ( 1 << 15 )
|
||||
// Joysticks
|
||||
#define PadR3 ( 1 << 2 )
|
||||
#define PadL3 ( 1 << 1 )
|
||||
|
||||
// Triggers applied on PADR
|
||||
#define PadShldL1 ( 1 << 2 )
|
||||
#define PadShldL2 ( 1 )
|
||||
#define PadShldR1 ( 1 << 3 )
|
||||
#define PadShldR2 ( 1 << 1 )
|
||||
#define PadShldL1 ( 1 << 10 )
|
||||
#define PadShldL2 ( 1 << 8)
|
||||
#define PadShldR1 ( 1 << 11 )
|
||||
#define PadShldR2 ( 1 << 9 )
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <libetc.h>
|
||||
#include <libgpu.h>
|
||||
#include "../include/defines.h"
|
||||
#include "../include/math.h"
|
||||
#include "../include/macros.h"
|
||||
#include "../custom_types.h"
|
||||
|
||||
@ -15,4 +16,5 @@ void checkBodyCol(BODY * one, BODY * two);
|
||||
void applyAngMom(LEVEL curLvl );
|
||||
void ResolveCollision( BODY * one, BODY * two );
|
||||
VECTOR angularMom(BODY body);
|
||||
void applyAcceleration(BODY * actor);
|
||||
void applyAcceleration(BODY * actor, int dt);
|
||||
u_int jump(BODY * actor, int dt);
|
||||
|
1831
levels/level0.c
1831
levels/level0.c
File diff suppressed because it is too large
Load Diff
@ -9539,8 +9539,8 @@ BODY level1_modelSphere_body = {
|
||||
{0, 0, 0, 0},
|
||||
333,-129,-298, 0,
|
||||
0,0,0, 0,
|
||||
2,
|
||||
ONE/2,
|
||||
10,
|
||||
ONE/10,
|
||||
-25,-24,-24, 0,
|
||||
24,24,25, 0,
|
||||
2048,
|
||||
|
136
src/main.c
136
src/main.c
@ -83,12 +83,7 @@ VECTOR fVecActor = {0,0,0,0};
|
||||
u_long triCount = 0;
|
||||
LEVEL curLvl = {0};
|
||||
LEVEL * loadLvl;
|
||||
// Callback variables
|
||||
u_short lastPad;
|
||||
int lerpValues[4096 >> 7];
|
||||
short cursor = 0;
|
||||
short angleCamTimer = 0;
|
||||
short forceApplied = 0;
|
||||
VECTOR lvlStartPos = {0};
|
||||
// Callback function is used for pads
|
||||
void callback();
|
||||
// variable FPS
|
||||
@ -158,8 +153,11 @@ int main() {
|
||||
for (int k = 0; k < *curLvl.meshes_length; k++){
|
||||
triCount += curLvl.meshes[k]->tmesh->len;
|
||||
}
|
||||
// Save actor starting pos
|
||||
copyVector(&lvlStartPos, &curLvl.actorPtr->body->position);
|
||||
// Set camera starting pos
|
||||
setCameraPos(&camera, &curLvl.camPtr->campos->pos, &curLvl.camPtr->campos->rot);
|
||||
|
||||
// Find curCamAngle if using pre-calculated BGs
|
||||
if (camMode == 2) {
|
||||
if (curLvl.camPtr->tim_data){
|
||||
@ -210,7 +208,7 @@ int main() {
|
||||
if (time % timediv == 0){
|
||||
atime ++;
|
||||
}
|
||||
// Spatial partitioning
|
||||
// Spatial partitioning
|
||||
if (curLvl.curNode){
|
||||
for ( int msh = 0; msh < curLvl.curNode->siblings->index; msh ++ ) {
|
||||
// Actor
|
||||
@ -233,7 +231,7 @@ int main() {
|
||||
// if(time%1 == 0){
|
||||
for ( int k = 0; k < *curLvl.meshes_length; k ++ ) {
|
||||
if ( curLvl.meshes[k]->isRigidBody == 1 ) {
|
||||
applyAcceleration( curLvl.meshes[k]->body);
|
||||
applyAcceleration( curLvl.meshes[k]->body, dt);
|
||||
// Get col between actor and level
|
||||
if ( curLvl.meshes[k]->isActor ){
|
||||
checkBodyCol( curLvl.meshes[k]->body , curLvl.levelPtr->body );
|
||||
@ -268,6 +266,10 @@ int main() {
|
||||
ClearOTagR(otdisc[db], OT2LEN);
|
||||
// Clear Secondary OT
|
||||
ClearOTagR(ot[db], OTLEN);
|
||||
|
||||
if(curLvl.actorPtr->pos.vy >= 200){
|
||||
copyVector(&curLvl.actorPtr->body->position, &lvlStartPos );
|
||||
}
|
||||
// Set camera according to mode
|
||||
setCameraMode(&curLvl, &camera, &posToActor, &angle, &angleCam, curCamAngle, camMode, &lerping);
|
||||
// Render scene
|
||||
@ -297,8 +299,8 @@ int main() {
|
||||
// Add secondary OT to main OT
|
||||
AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]);
|
||||
|
||||
FntPrint("\nTime : %d\n", time);
|
||||
FntPrint("#Tri : %d\n", triCount);
|
||||
//~ FntPrint("\nTime : %d\n", time);
|
||||
FntPrint("#Tri : %d\n", triCount);
|
||||
FntPrint("#RCnt : %d %d\n", oldTime, dt);
|
||||
FntFlush(-1);
|
||||
display( &disp[db], &draw[db], otdisc[db], primbuff[db], &nextpri, &db);
|
||||
@ -310,12 +312,13 @@ void callback() {
|
||||
read_controller( &theControllers[0], &controllers[0].pad[0], 0 ); // Read controllers
|
||||
// Pad 2
|
||||
read_controller( &theControllers[1], &controllers[1].pad[0], 1 );
|
||||
u_char PADL = ~theControllers[0].button1;
|
||||
u_char PADR = ~theControllers[0].button2;
|
||||
//~ static u_short lastPad;
|
||||
//~ static int lerpValues[4096 >> 7];
|
||||
//~ static short cursor = 0;
|
||||
//~ static short angleCamTimer = 0;
|
||||
|
||||
u_short PAD = ~*((u_short*)(&theControllers[0].button1));
|
||||
|
||||
static u_short lastPad;
|
||||
static int lerpValues[4096 >> 7];
|
||||
static short cursor = 0;
|
||||
static short angleCamTimer = 0;
|
||||
//~ static short forceApplied = 0;
|
||||
int div = 32;
|
||||
|
||||
@ -327,13 +330,16 @@ void callback() {
|
||||
if( timer ) {
|
||||
timer--;
|
||||
}
|
||||
if (!timer){
|
||||
curLvl.actorPtr->body->gForce.vy = 0;
|
||||
}
|
||||
if( cursor ) {
|
||||
cursor--;
|
||||
}
|
||||
if (angleCam.vy > 2048 || angleCam.vy < -2048) {
|
||||
angleCam.vy = 0;
|
||||
}
|
||||
if ( PADR & PadShldR1 && !timer ) {
|
||||
if ( PAD & PadShldR1 && !timer ) {
|
||||
if (!curLvl.camPtr->tim_data){
|
||||
if(camMode < 5){
|
||||
camMode ++;
|
||||
@ -354,59 +360,59 @@ void callback() {
|
||||
LoadTexture(curLvl.camPtr->tim_data, curLvl.camPtr->BGtim);
|
||||
}
|
||||
}
|
||||
lastPad = PADR;
|
||||
lastPad = PAD;
|
||||
timer = 10;
|
||||
}
|
||||
//~ if ( !(PADR & PadShldR1) && lastPad & PadShldR1 ) {
|
||||
//~ if ( !(PAD & PadShldR1) && lastPad & PadShldR1 ) {
|
||||
//pressed = 0;
|
||||
//~ }
|
||||
if ( PADR & PadShldL2 ) {
|
||||
if ( PAD & PadShldL2 ) {
|
||||
dc_lgtangp->vy += 32;
|
||||
}
|
||||
if ( PADR & PadShldL1 ) {
|
||||
if ( PAD & PadShldL1 ) {
|
||||
dc_lgtangp->vz += 32;
|
||||
}
|
||||
if ( PADR & PadUp && !timer ){
|
||||
if ( PAD & Tri && !timer ){
|
||||
if (curLvl.actorPtr->isPrism){
|
||||
curLvl.actorPtr->isPrism = 0;
|
||||
} else {
|
||||
curLvl.actorPtr->isPrism = 1;
|
||||
}
|
||||
timer = 10;
|
||||
lastPad = PADR;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PADR & PadDown && !timer ){
|
||||
if (curLvl.actorPtr->body->gForce.vy >= 0 && curLvl.actorPtr->body->position.vy >= curLvl.actorPtr->body->min.vy ){
|
||||
forceApplied -= 150;
|
||||
if ( PAD & Cross && !timer ){
|
||||
if (curLvl.actorPtr->body->gForce.vy == 0 && (curLvl.actorPtr->body->position.vy - curLvl.actorPtr->body->min.vy) == curLvl.levelPtr->body->min.vy ){
|
||||
// Use delta to find jump force
|
||||
curLvl.actorPtr->body->gForce.vy = - ((200/((ONE/(dt<1?1:dt))<1?1:(ONE/(dt<1?1:dt))))*14);
|
||||
}
|
||||
cursor = div - 15;
|
||||
timer = 30;
|
||||
lastPad = PADR;
|
||||
//~ cursor = div - 15;
|
||||
timer = 10;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( !(PADR & PadDown) && lastPad & PadDown ) {
|
||||
//~ lastPad = pad;
|
||||
if ( !(PAD & Cross) && lastPad & Cross ) {
|
||||
//~ curLvl.actorPtr->body->gForce.vy = 0;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PADR & PadLeft && !timer ) {
|
||||
if ( PAD & PadLeft && !timer ) {
|
||||
if (curLvl.actorPtr->anim->interpolate){
|
||||
curLvl.actorPtr->anim->interpolate = 0;
|
||||
} else {
|
||||
curLvl.actorPtr->anim->interpolate = 1;
|
||||
}
|
||||
timer = 10;
|
||||
lastPad = PADR;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if (theControllers[0].type == 0x73){
|
||||
// Analog stick L up
|
||||
if ( theControllers[0].analog3 >= 0 && theControllers[0].analog3 < (128 - DS_DZ/2)) {
|
||||
curLvl.actorPtr->body->gForce.vz = getVectorTo(fVecActor, curLvl.actorPtr->pos).vz * (128 - theControllers[0].analog3 ) >> 14 ;
|
||||
curLvl.actorPtr->body->gForce.vx = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vx * (128 - theControllers[0].analog3 ) >> 14 ;
|
||||
lastPad = PADL;
|
||||
curLvl.actorPtr->body->gForce.vz = getVectorTo(fVecActor, curLvl.actorPtr->pos).vz * (128 - theControllers[0].analog3 ) >> 13 ;
|
||||
curLvl.actorPtr->body->gForce.vx = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vx * (128 - theControllers[0].analog3 ) >> 13 ;
|
||||
}
|
||||
// Analog stick L down
|
||||
if ( theControllers[0].analog3 > (128 + DS_DZ/2) && theControllers[0].analog3 <= 255 ) {
|
||||
curLvl.actorPtr->body->gForce.vz = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vz * ( theControllers[0].analog3 - 128 ) >> 14 ;
|
||||
curLvl.actorPtr->body->gForce.vx = getVectorTo(fVecActor, curLvl.actorPtr->pos).vx * ( theControllers[0].analog3 - 128 ) >> 14 ;
|
||||
lastPad = PADL;
|
||||
curLvl.actorPtr->body->gForce.vz = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vz * ( theControllers[0].analog3 - 128 ) >> 13 ;
|
||||
curLvl.actorPtr->body->gForce.vx = getVectorTo(fVecActor, curLvl.actorPtr->pos).vx * ( theControllers[0].analog3 - 128 ) >> 13 ;
|
||||
}
|
||||
// Analog stick L dead zone
|
||||
if ( theControllers[0].analog3 > (128 - DS_DZ/2) && theControllers[0].analog3 < (128 + DS_DZ/2) ) {
|
||||
@ -415,42 +421,42 @@ void callback() {
|
||||
}
|
||||
// Analog stick L left
|
||||
if ( theControllers[0].analog2 >= 0 && theControllers[0].analog2 < (128 - DS_DZ/2) ) {
|
||||
curLvl.actorPtr->rot.vy -= ( 64 * ( 128 - theControllers[0].analog2 ) ) >> 7 ;
|
||||
curLvl.actorPtr->rot.vy -= ( 64 * ( 128 - theControllers[0].analog2 ) ) >> 8 ;
|
||||
}
|
||||
// Analog stick L right
|
||||
if ( theControllers[0].analog2 > (128 + DS_DZ/2) && theControllers[0].analog2 <= 255 ) {
|
||||
curLvl.actorPtr->rot.vy += ( 64 * ( theControllers[0].analog2 - 128 ) ) >> 7 ;
|
||||
curLvl.actorPtr->rot.vy += ( 64 * ( theControllers[0].analog2 - 128 ) ) >> 8 ;
|
||||
}
|
||||
}
|
||||
if ( PADL & PadUp ) {
|
||||
curLvl.actorPtr->body->gForce.vz = getVectorTo(fVecActor, curLvl.actorPtr->pos).vz >> 7 ;
|
||||
curLvl.actorPtr->body->gForce.vx = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vx >> 7;
|
||||
lastPad = PADL;
|
||||
if ( PAD & PadUp ) {
|
||||
curLvl.actorPtr->body->gForce.vz = getVectorTo(fVecActor, curLvl.actorPtr->pos).vz >> 6 ;
|
||||
curLvl.actorPtr->body->gForce.vx = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vx >> 6;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( !(PADL & PadUp) && lastPad & PadUp) {
|
||||
if ( !(PAD & PadUp) && lastPad & PadUp) {
|
||||
curLvl.actorPtr->body->gForce.vz = 0;
|
||||
curLvl.actorPtr->body->gForce.vx = 0;
|
||||
lastPad = PADL;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PADL & PadDown ) {
|
||||
curLvl.actorPtr->body->gForce.vz = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vz >> 7 ;
|
||||
curLvl.actorPtr->body->gForce.vx = getVectorTo(fVecActor, curLvl.actorPtr->pos).vx >> 7 ;
|
||||
lastPad = PADL;
|
||||
if ( PAD & PadDown ) {
|
||||
curLvl.actorPtr->body->gForce.vz = -getVectorTo(fVecActor, curLvl.actorPtr->pos).vz >> 6 ;
|
||||
curLvl.actorPtr->body->gForce.vx = getVectorTo(fVecActor, curLvl.actorPtr->pos).vx >> 6 ;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( !( PADL & PadDown ) && lastPad & PadDown) {
|
||||
if ( !( PAD & PadDown ) && lastPad & PadDown) {
|
||||
curLvl.actorPtr->body->gForce.vz = 0;
|
||||
curLvl.actorPtr->body->gForce.vx = 0;
|
||||
lastPad = PADL;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PADL & PadLeft ) {
|
||||
if ( PAD & PadLeft ) {
|
||||
curLvl.actorPtr->rot.vy -= 64;
|
||||
lastPad = PADL;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PADL & PadRight ) {
|
||||
if ( PAD & PadRight ) {
|
||||
curLvl.actorPtr->rot.vy += 64;
|
||||
lastPad = PADL;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PADL & PadSelect && !timer ) {
|
||||
if ( PAD & PadSelect && !timer ) {
|
||||
//~ if (!levelHasChanged){
|
||||
#ifndef USECD
|
||||
printf("load:%p:%08x:%s", &load_all_overlays_here, &level, overlayFile);
|
||||
@ -462,24 +468,24 @@ void callback() {
|
||||
#endif
|
||||
//~ }
|
||||
timer = 30;
|
||||
lastPad = PADL;
|
||||
lastPad = PAD;
|
||||
}
|
||||
if( theControllers[0].type == 0x73 && camMode == 0){
|
||||
// Cam control - horizontal
|
||||
if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < (128 - DS_DZ/2) ) {
|
||||
angleCam.vy += ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 7 ;
|
||||
angleCam.vy += ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 8 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
if ( theControllers[0].analog0 > (128 + DS_DZ/2) && theControllers[0].analog0 <= 255 ) {
|
||||
angleCam.vy -= ( 16 * ( theControllers[0].analog0 - 128 ) ) >> 7 ;
|
||||
angleCam.vy -= ( 16 * ( theControllers[0].analog0 - 128 ) ) >> 8 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
if ( theControllers[0].analog0 >= 0 && theControllers[0].analog0 < (128 - DS_DZ/2) ) {
|
||||
angleCam.vy += ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 7 ;
|
||||
angleCam.vy += ( 16 * ( 128 - theControllers[0].analog0 ) ) >> 8 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
if ( theControllers[0].analog0 > (128 + DS_DZ/2) && theControllers[0].analog0 <= 255) {
|
||||
angleCam.vy -= ( 16 * ( theControllers[0].analog0 - 128 ) ) >> 7 ;
|
||||
angleCam.vy -= ( 16 * ( theControllers[0].analog0 - 128 ) ) >> 8 ;
|
||||
angleCamTimer = 120;
|
||||
}
|
||||
// Timer to lerp cam back behind actor
|
||||
@ -500,5 +506,7 @@ void callback() {
|
||||
//~ theControllers[0].analog2, // L3 hor : left : 0 7F right: 7F FF : dz 69 81 68 - 8E
|
||||
//~ theControllers[0].analog3 ); // L3 vert : up : 0 7F down : 7F FF : dz 74 8D
|
||||
if ( cursor ) {
|
||||
curLvl.actorPtr->body->position.vy = lerpValues[cursor];}
|
||||
//~ curLvl.actorPtr->body->gForce.vy = 0;
|
||||
//~ curLvl.actorPtr->body->position.vy = lerpValues[cursor];
|
||||
}
|
||||
};
|
||||
|
@ -107,10 +107,12 @@ VECTOR getExtCollision(BODY one, BODY two){
|
||||
void checkBodyCol(BODY * one, BODY * two){
|
||||
VECTOR colInt, colExt;
|
||||
colInt = getIntCollision( *one , *two );
|
||||
colExt = getExtCollision( *one , *two );
|
||||
//~ colExt = getExtCollision( *one , *two );
|
||||
if ( colInt.vy ) {
|
||||
if ( !colInt.vx && !colInt.vz ) {
|
||||
one->position.vy = one->min.vy;
|
||||
one->velocity.vy = 0;
|
||||
two->velocity.vy = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -126,19 +128,40 @@ void applyAngMom(LEVEL curLvl ){
|
||||
}
|
||||
}
|
||||
};
|
||||
void applyAcceleration(BODY * actor){
|
||||
//~ short dt = VSync(-1) - oldTime ;
|
||||
short dt = 1;
|
||||
//~ if (dt < 1) { dt = 1; }
|
||||
//~ void applyAcceleration(BODY * actor, int dt){
|
||||
//~ dt = 1;
|
||||
//~ VECTOR acceleration = {actor->invMass * actor->gForce.vx , (actor->invMass * actor->gForce.vy) + (GRAVITY * ONE), actor->invMass * actor->gForce.vz};
|
||||
//FntPrint("acc: %d %d %d\n", acceleration.vx, acceleration.vy, acceleration.vz );
|
||||
//~ actor->velocity.vx += (acceleration.vx * dt) >> 12;
|
||||
//~ actor->velocity.vy += (acceleration.vy * dt) >> 12;
|
||||
//~ actor->velocity.vz += (acceleration.vz * dt) >> 12;
|
||||
//FntPrint("acc: %d %d %d\n", acceleration.vx / ONE, acceleration.vy / ONE, acceleration.vz / ONE );
|
||||
//~ actor->position.vx += (actor->velocity.vx * dt);
|
||||
//~ actor->position.vy += (actor->velocity.vy * dt);
|
||||
//~ actor->position.vz += (actor->velocity.vz * dt);
|
||||
//FntPrint("vel: %d %d %d\n", actor->velocity.vx, actor->velocity.vy, actor->velocity.vz );
|
||||
//~ };
|
||||
|
||||
void applyAcceleration(BODY * actor, int dt){
|
||||
// Make sure no div by 0 occurs
|
||||
if (dt < 1) { dt = 1; }
|
||||
int dtfx = ONE/dt;
|
||||
if (dtfx < 1) { dtfx = 1; }
|
||||
VECTOR acceleration = {actor->invMass * actor->gForce.vx , (actor->invMass * actor->gForce.vy) + (GRAVITY * ONE), actor->invMass * actor->gForce.vz};
|
||||
//~ FntPrint("acc: %d %d %d\n", acceleration.vx, acceleration.vy, acceleration.vz );
|
||||
actor->velocity.vx += (acceleration.vx * dt) >> 12;
|
||||
actor->velocity.vy += (acceleration.vy * dt) >> 12;
|
||||
actor->velocity.vz += (acceleration.vz * dt) >> 12;
|
||||
//~ FntPrint("acc: %d %d %d\n", acceleration.vx / ONE, acceleration.vy / ONE, acceleration.vz / ONE );
|
||||
actor->position.vx += (actor->velocity.vx * dt);
|
||||
actor->position.vy += (actor->velocity.vy * dt);
|
||||
actor->position.vz += (actor->velocity.vz * dt);
|
||||
//~ FntPrint("acc: %d %d %d %d\n", acceleration.vx, acceleration.vy, acceleration.vz , delta);
|
||||
//~ actor->velocity.vx += (acceleration.vx * dt) >> 12;
|
||||
//~ actor->velocity.vy += (acceleration.vy * dt) >> 12;
|
||||
//~ actor->velocity.vz += (acceleration.vz * dt) >> 12;
|
||||
actor->velocity.vx += (acceleration.vx / dtfx) / 256;
|
||||
actor->velocity.vy += (acceleration.vy / dtfx) / 256;
|
||||
actor->velocity.vz += (acceleration.vz / dtfx) / 256;
|
||||
//~ FntPrint("acc: %d %d %d\n", (acceleration.vx / (ONE/dt)) , (acceleration.vy / (ONE/dt)), (acceleration.vz / (ONE/dt)) );
|
||||
//~ actor->position.vx += (actor->velocity.vx * dt);
|
||||
//~ actor->position.vy += (actor->velocity.vy * dt);
|
||||
//~ actor->position.vz += (actor->velocity.vz * dt);
|
||||
actor->position.vx += (actor->velocity.vx );
|
||||
actor->position.vy += (actor->velocity.vy );
|
||||
actor->position.vz += (actor->velocity.vz );
|
||||
//~ FntPrint("vel: %d %d %d\n", actor->velocity.vx, actor->velocity.vy, actor->velocity.vz );
|
||||
};
|
||||
//~ // https://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331
|
||||
@ -193,3 +216,15 @@ VECTOR angularMom(BODY body){
|
||||
//~ FntPrint("v: %d, r:%d, w:%d\n", body.velocity.vz * r, r * r, w.vz);
|
||||
return w;
|
||||
};
|
||||
u_int jump(BODY * actor, int dt){
|
||||
// https://medium.com/@brazmogu/physics-for-game-dev-a-platformer-physics-cheatsheet-f34b09064558
|
||||
// y = -0.5gt² + v't
|
||||
// vt = sqrt( (vel.vx)² + (vel.vz)² + (vel.vy - 9,81t)² )
|
||||
//~ long long velocity = patan(actor->velocity.vx, actor->velocity.vy);
|
||||
//~ int y = (GRAVITY/2 * dt) + (velocity * dt );
|
||||
u_int vt = psqrt( (actor->velocity.vx * actor->velocity.vx) +
|
||||
(actor->velocity.vz * actor->velocity.vz) +
|
||||
( (actor->velocity.vy - (GRAVITY * dt)) * (actor->velocity.vy - (GRAVITY * dt)) )
|
||||
);
|
||||
return vt;
|
||||
};
|
||||
|
14
src/psx.c
14
src/psx.c
@ -101,6 +101,8 @@ void LvlPtrSet(LEVEL * curLevel, LEVEL * level){
|
||||
curLevel->camPath = level->camPath;
|
||||
curLevel->camAngles = level->camAngles;
|
||||
curLevel->curNode = level->curNode; // Blank
|
||||
|
||||
//~ curLevel->actorPtr->body = level->actorPtr->body;
|
||||
// Move these to drawPoly()
|
||||
//~ curLevel->meshPlan = level->meshPlan;
|
||||
//~ FntPrint("%x %x", curLevel->meshes, level->meshes);
|
||||
@ -130,6 +132,18 @@ void SwitchLevel( LEVEL * curLevel, LEVEL * loadLevel ){
|
||||
SVECTOR lgtang = {0,0,0,0};
|
||||
// Light environment
|
||||
setDCLightEnv(curLevel->cmat, curLevel->lgtmat, &lgtang);
|
||||
// Reset physics
|
||||
// TODO : put in a function
|
||||
copyVector(&curLevel->actorPtr->body->position, &loadLevel->actorPtr->body->position );
|
||||
copyVector(&curLevel->actorPtr->pos, &curLevel->actorPtr->body->position);
|
||||
copyVector(&curLevel->propPtr->body->position, &loadLevel->propPtr->body->position );
|
||||
copyVector(&curLevel->propPtr->pos, &curLevel->propPtr->body->position);
|
||||
applyVector( &curLevel->actorPtr->body->position, 0, 100, 0, -=);
|
||||
applyVector( &curLevel->actorPtr->body->velocity, 0, 0, 0, =);
|
||||
applyVector( &curLevel->actorPtr->body->gForce, 0, 0, 0, =);
|
||||
applyVector( &curLevel->propPtr->body->position, 0, 100, 0, -=);
|
||||
applyVector( &curLevel->propPtr->body->velocity, 0, 0, 0, =);
|
||||
applyVector( &curLevel->propPtr->body->gForce, 0, 0, 0, =);
|
||||
};
|
||||
void LoadTexture(u_long * tim, TIM_IMAGE * tparam){ // This part is from Lameguy64's tutorial series : lameguy64.net/svn/pstutorials/chapter1/3-textures.html login/pw: annoyingmous
|
||||
OpenTIM(tim); // Open the tim binary data, feed it the address of the data in memory
|
||||
|
Loading…
Reference in New Issue
Block a user