did stuff
This commit is contained in:
parent
18fb5dd971
commit
10ed515e86
54
src/main.c
54
src/main.c
@ -31,34 +31,6 @@ void castRay(s16 angle){
|
|||||||
fix16 dx = cosFix16(ind);
|
fix16 dx = cosFix16(ind);
|
||||||
fix16 tan = FIX16(0);
|
fix16 tan = FIX16(0);
|
||||||
if(dx != 0) tan = fix16Div(dy, dx);
|
if(dx != 0) tan = fix16Div(dy, dx);
|
||||||
char str[9];
|
|
||||||
sprintf(str, "Ang: %4d", angle);
|
|
||||||
BMP_drawText(str, 20, 0);
|
|
||||||
char str2[13];
|
|
||||||
bool neg = false;
|
|
||||||
fix16 nsin = dy;
|
|
||||||
if (dy < 0){
|
|
||||||
neg = true;
|
|
||||||
nsin = 0 - nsin;
|
|
||||||
}
|
|
||||||
sprintf(str2, "Sin: %s%3d.%03d", neg ? "-" : " ", nsin >> FIX16_FRAC_BITS, 1000*fix16Frac(nsin)/(1<<FIX16_FRAC_BITS));
|
|
||||||
BMP_drawText(str2, 20, 1);
|
|
||||||
neg = false;
|
|
||||||
fix16 ncos = dx;
|
|
||||||
if (dx < 0){
|
|
||||||
neg = true;
|
|
||||||
ncos = 0 - ncos;
|
|
||||||
}
|
|
||||||
sprintf(str2, "Cos: %s%3d.%03d", neg ? "-" : " ", ncos >> FIX16_FRAC_BITS, 1000*fix16Frac(ncos)/(1<<FIX16_FRAC_BITS));
|
|
||||||
BMP_drawText(str2, 20, 2);
|
|
||||||
neg = false;
|
|
||||||
fix16 ntan = tan;
|
|
||||||
if (tan < 0){
|
|
||||||
neg = true;
|
|
||||||
ntan = 0 - ntan;
|
|
||||||
}
|
|
||||||
sprintf(str2, "Tan: %s%3d.%03d", neg ? "-" : " ", ntan >> FIX16_FRAC_BITS, 1000*fix16Frac(ntan)/(1<<FIX16_FRAC_BITS));
|
|
||||||
BMP_drawText(str2, 20, 3);
|
|
||||||
fix16 aTan = FIX16(0);
|
fix16 aTan = FIX16(0);
|
||||||
if(tan != 0) aTan = fix16Div(FIX16(-1), tan);
|
if(tan != 0) aTan = fix16Div(FIX16(-1), tan);
|
||||||
s16 tanInt = fix16ToInt(fix16Mul(aTan, FIX16(100)));
|
s16 tanInt = fix16ToInt(fix16Mul(aTan, FIX16(100)));
|
||||||
@ -107,7 +79,13 @@ void castRay(s16 angle){
|
|||||||
fix16 distV = FIX16(500);
|
fix16 distV = FIX16(500);
|
||||||
fix16 vx = FIX16(l.pt1.x);
|
fix16 vx = FIX16(l.pt1.x);
|
||||||
fix16 vy = FIX16(l.pt1.y);
|
fix16 vy = FIX16(l.pt1.y);
|
||||||
float nTan = 0-tan;
|
fix16 nTan = 0-tan;
|
||||||
|
if(fix16ToInt(nTan) > 51){
|
||||||
|
nTan = FIX16(51);
|
||||||
|
}
|
||||||
|
if(fix16ToInt(nTan) < -51){
|
||||||
|
nTan = FIX16(-51);
|
||||||
|
}
|
||||||
if(angle > 90 && r < 270) {
|
if(angle > 90 && r < 270) {
|
||||||
rx = FIX16(l.pt1.x / 10 * 10)-FIX16(1);
|
rx = FIX16(l.pt1.x / 10 * 10)-FIX16(1);
|
||||||
ry = fix16Mul(FIX16(l.pt1.x) - rx,nTan) + FIX16(l.pt1.y);
|
ry = fix16Mul(FIX16(l.pt1.x) - rx,nTan) + FIX16(l.pt1.y);
|
||||||
@ -152,6 +130,8 @@ void castRay(s16 angle){
|
|||||||
l.pt2.x = fix16ToInt(hx);
|
l.pt2.x = fix16ToInt(hx);
|
||||||
l.pt2.y = fix16ToInt(hy);
|
l.pt2.y = fix16ToInt(hy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapscan(){
|
void mapscan(){
|
||||||
@ -184,15 +164,17 @@ void render(){
|
|||||||
mapscan();
|
mapscan();
|
||||||
if(angle >= 360) angle = angle - 360;
|
if(angle >= 360) angle = angle - 360;
|
||||||
if(angle < 0) angle = 360 + angle;
|
if(angle < 0) angle = 360 + angle;
|
||||||
//castRay(angle-20);
|
castRay(angle-20);
|
||||||
//BMP_drawLine(&l);
|
BMP_drawLine(&l);
|
||||||
//castRay(angle-10);
|
castRay(angle-10);
|
||||||
//BMP_drawLine(&l);
|
BMP_drawLine(&l);
|
||||||
|
for (int i = 0; i < 16; i++){
|
||||||
castRay(angle);
|
castRay(angle);
|
||||||
//BMP_drawLine(&l);
|
//BMP_drawLine(&l);
|
||||||
//castRay(angle+10);
|
}
|
||||||
//BMP_drawLine(&l);
|
castRay(angle+10);
|
||||||
//castRay(angle+20);
|
BMP_drawLine(&l);
|
||||||
|
castRay(angle+20);
|
||||||
BMP_drawLine(&l);
|
BMP_drawLine(&l);
|
||||||
BMP_showFPS(0);
|
BMP_showFPS(0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user