[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/vr/ - Retro Games

Search:


View post   

>> No.2533958 [View]
File: 73 KB, 601x605, graviton_mob_intersection.jpg [View same] [iqdb] [saucenao] [google]
2533958

Finally an update. Debugged code:

word x0; // Initial position
word dx; // Delta position
word xw; // Move box width
word x1; // Final position
word xa; // Move box left
word xb; // Move box right
word ba; // Block box left(top)
word bb; // Block box right(bottom)
word bw; // Block box width
word box.n; // Crate max index
word box.wx[]; // Crate width
word box.x; // Crate position

void MoveMob(){
___if(abs(dx)>=abs(dy)){
______Push(x0);
______MoveMobX();
______x0=x1;
______MoveMobY();
______x0=Pull();
___}else{
______Push(y0);
______MoveMobY();
______y0=y1;
______MoveMobX();
______y0=Pull();
___}
__return;
}

void MoveMobX(){
___if(dx==0){
______x1=x0;
______return;
___}
___x1=(x0+dx)&0x00FF;
___if(dx>=0){
______xa=(x0+xw)&0x00FF;
______xb=(xa+xy-1)&0x00FF;
___}else{
______xb=(x0-1)&0x00FF;
______xa=(xb+dx+1)&0x00FF;
___}
___ya=y0;
___yb=(ya+yw-1)&0x00FF;
___for(X=0:X<box.n:X++){
______bw=box.wy[X];
______ba=box.y[X];
______bb=(ba+bw-1)&0x00FF;
______if(!MoveIntersectY(yw)) continue;
______bw=box.wx[X];
______ba=box.x[X];
______bb=(ba+bw-1)&0x00FF;
______if(!MoveIntersectX(dx)) continue;
______x1=(dx>=0?ba-xw:ba+bw)&0x00FF;
______xa=x0;
______xb=(xa+dx)&0x00FF;
______if(dx<0) A=xa, Y=xb, xa=Y, xb=A;
______if(!MoveInIntervalX()){
_________x1=x0;
_________dx=0;
_________return;
______}
______A=x1-x0;
______if(A){
_________if(dx>=0){
____________if(A<0) A+=0x0100;
_________}else{
____________if(A>=0) A-=0x0100;
_________}
______}
______dx=A;
______xb=(xa+xw+dx-1)&0x00FF;
___}
___return;
}

bool MoveInIntervalX(){
___return (xb>=xa)&&(xa<=x1&&x1<=xb) || (xb<xa)&&(xa<=x1||x1<=xb) ?1:0;
}

bool MoveIntersectX(A){
___return (
______(abs(A)<bw)&&(
_________(bb>=ba)&&( (ba<=xa&&xa<=bb) || (ba<=xb&&xb<=bb) )||
_________(bb< ba)&&( (ba<=xa||xa<=bb) || (ba<=xb||xb<=bb) )
______)||
______(abs(A)>=bw)&&(
_________(xb>=xa)&&( (xa<=ba&&ba<=xb) || (xa<=bb&&bb<=xb) )||
_________(xb< xa)&&( (xa<=ba||ba<=xb) || (xa<=bb||bb<=xb) )
______)
__)?1:0;
}

>>2532402
Right both times.

Navigation
View posts[+24][+48][+96]