[ 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.2528169 [View]
File: 195 KB, 804x720, 1434343274776.jpg [View same] [iqdb] [saucenao] [google]
2528169

OP here

Finally got an _extremely_ general and fast hitbox vs hitbox movement code on a torus. I was having trouble with the concepts and assembly, and after several attempts at writing and revising a C program, I finally hit on how this needs to be done.

The purpose of this code is to take a hitbox of width 'wx' at position 'x0' and move it 'dx' to a new position 'x1' under the constraint that it can't pass through a list 'box' of 'boxCount' impassible hit boxes.

This code works on a 0x0100 pixel torus. It can easily be made to work on torii with resolutions of any power of 2 using logical and (&), or any size if one is willing to use (expensive) division instead.

word MoveBoxX(word x0, word dx, word wx, box_t box, word boxCount){
__word x1; // New hitbox x
__word xa; // Hitbox left
__word xb; // Hitbox right
__word bw; // Stop box width
__word ba; // Stop box left
__word bb; // Stop box right
__if(dx){
____x1=(d0+dx)&0x00FF;
____if(dx>=0){
______xa=(x0+wx)%0x00FF;
______xb=(xa+dx-1)%0x00FF;
____}else{
______xb=(x0-1)%0x00FF;
______xa=(xb-dx+1)%0x00FF;
____}
____for(i=0;i<boxCount;i++){
______bw=box.w[i];
______ba=box.x[i];
______bb=(ba+bw-1)%0x00FF;
______if(
________(bw>=wx)&&( // Stopping box wider
__________(bb>=ba)&&(ba<=xa&&xa<=bb || ba<=xb&&xb<=bb)||
__________(bb< ba)&&(ba<=xa||xa<=bb || ba<=xb||xb<=bb)
________)||
________(bw< wx)&&( // Hitbox wider
__________(xb>=xa)&&(xa<=ba&&ba<=xb || xa<=bb&&bb<=xb)||
__________(xb< xa)&&(xa<=ba||ba<=xb || xa<=bb||bb<=xb)
________)
______){
________x1=((dx>=0)?(b0-xw):(b0+bw))&0x00FF;
______}
____}
__}else{
____x1=x0;
__}
__return x1;
}

>> No.2471802 [View]
File: 195 KB, 804x720, 1433390082528.jpg [View same] [iqdb] [saucenao] [google]
2471802

Just finished ff7 like it a lot
Now should I play chrono cross or ff8 next??

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