odd wii crash November 26, 2010 07:53AM | Registered: 15 years ago Posts: 444 |
float wallDistance(int lvlnum,int wallnum,bullet myBullet){ float X; float Y; float a; float b; float c; float d; float X1; float Y1; float X2; float Y2; float newX; float newY; float mew; float final; X = myBullet.getX(); Y = myBullet.getY(); testWall.X = X; testWall.Y = Y; X1 = levelList[lvlnum].wallX1[wallnum]; Y1 = levelList[lvlnum].wallY1[wallnum]; X2 = levelList[lvlnum].wallX2[wallnum]; Y2 = levelList[lvlnum].wallY2[wallnum]; if(X1==X2){ final = abs(X-X1); newX = X1; newY = Y; testWall.X = newX; testWall.Y = newY; } else { a = X1; b = Y1; c = X2-X1; d = Y2-Y1; //The code below finds the distance between the ball, and the line given mew = ((a*d)+(c*Y)-(c*b)-(d*X))/((c*c)+(d*d)); final = sqrt(((c*mew)*(c*mew))+((d*mew)*(d*mew))); //newX and newY are the X and Y locations of the closes point on the line newX = X+(mew*d); newY = Y+(mew*(-c)); testWall.X = newX; testWall.Y = newY; } /*The code below checks to make sure that the ball is colliding within the wall The way the if statements below work is each statement check to make sure that the ball is within the wall line, and then the if will return true if it isn't that way I can use a simple return -1; to symbolize that the ball is not colliding with the wall the reason for all of the Xn>Xn and Yn>Yn statements is that the range of values to check if the ball is within the wall is different if Y1>Y2 then if Y2>Y1 -2 is returned if both X's and Y's are equal to each other */ if(X2 > X1){ if(Y2 > Y1){ if(!((newX < X2)&&(newX > X1)&&(newY < Y2)&&(newY > Y1))) return -1; } else if(Y1>Y2){ if(!((newX < X2)&&(newX > X1)&&(newY > Y2)&&(newY < Y1))) return -1; } else { if(!((newX < X2)&&(newX > X1)&&(newY==Y2))) return -1; } } else if(X1 > X2){ if(Y2 > Y1){ if(!((newX > X2)&&(newX < X1)&&(newY < Y2)&&(newY > Y1))) return -1; } else if(Y1>Y2){ if(!((newX > X2)&&(newX < X1)&&(newY > Y2)&&(newY < Y1))) return -1; } else { if(!((newX>X2)&&(newXY1){ if(!((newY < Y2)&&(newY > Y1))) return -1; } else if(Y1 > Y2){ if(!((newY > Y2)&&(newY < Y1))) return -1; } else { return -2; } } return final; }
for(i=0;i < levelList[lvlnum].numWalls;i++){ wallDist = wallDistance(lvlnum,i,shootingBullet);//If I replace this line with wallDist = 80; then the wii doesn't crash if((wallDist <= 16)&&(wallDist > -1)){ bulletAlive = false; shootingBullet.resetBullet(initX,initY,.000000001,0,0,0); } }When a level is completed, then all that happens is that the level function returns to the caller. for example:
void runLevel(args...){ do{ } while(levelDone==false) }For this reason, I think that my wallDistance function is somehow corrupting the stack, and placing the wrong return values for my runLevel function, but I am not sure where that problem would even be at. All that is happening in that function is some arithmetic functions.
Re: odd wii crash November 26, 2010 10:16AM | Registered: 14 years ago Posts: 379 |
Re: odd wii crash November 26, 2010 05:42PM | Registered: 15 years ago Posts: 444 |
void bullet::resetBullet(float initX,float initY,float initspeed,float initangle,float initaccel,float initaccelAng){ X=initX; Y=initY; speed=initspeed; angle=initangle; accel=initaccel; accelAng=initaccelAng; }
Re: odd wii crash December 02, 2010 02:51AM | Registered: 15 years ago Posts: 444 |