movement update
This commit is contained in:
parent
20e8375f18
commit
0135a07875
26
src/main.c
26
src/main.c
@ -1,6 +1,6 @@
|
||||
#include <genesis.h>
|
||||
|
||||
#define SPEED 2
|
||||
#define SPEED 5
|
||||
|
||||
Line l;
|
||||
s16 angle = 0;
|
||||
@ -21,11 +21,11 @@ int dist(int ax, int ay, int bx, int by){
|
||||
}
|
||||
|
||||
void castRay(s16 angle){
|
||||
|
||||
if(angle >= 360) angle = angle - 360;
|
||||
if(angle < 0) angle = 360 + angle;
|
||||
u16 r,mx,my,mp,dof;
|
||||
fix16 rx,ry,ra,xo,yo;
|
||||
s16 ind = (int)((float)angle/360.0f*1024.0f);
|
||||
|
||||
fix16 dy = sinFix16(ind);
|
||||
fix16 dx = cosFix16(ind);
|
||||
fix16 tan = FIX16(0);
|
||||
@ -149,7 +149,15 @@ void render(){
|
||||
mapscan();
|
||||
if(angle >= 360) angle = angle - 360;
|
||||
if(angle < 0) angle = 360 + angle;
|
||||
castRay(angle-20);
|
||||
BMP_drawLine(&l);
|
||||
castRay(angle-10);
|
||||
BMP_drawLine(&l);
|
||||
castRay(angle);
|
||||
BMP_drawLine(&l);
|
||||
castRay(angle+10);
|
||||
BMP_drawLine(&l);
|
||||
castRay(angle+20);
|
||||
BMP_drawLine(&l);
|
||||
BMP_showFPS(0);
|
||||
|
||||
@ -180,10 +188,18 @@ void update(){
|
||||
angle += 1;
|
||||
}
|
||||
if(joy & BUTTON_UP) {
|
||||
l.pt1.y -= SPEED;
|
||||
s16 ind = (int)((float)angle/360.0f*1024.0f);
|
||||
fix16 dy = sinFix16(ind);
|
||||
fix16 dx = cosFix16(ind);
|
||||
l.pt1.y += fix16ToInt(fix16Mul(dy, FIX16(SPEED)));
|
||||
l.pt1.x += fix16ToInt(fix16Mul(dx, FIX16(SPEED)));
|
||||
}
|
||||
if(joy & BUTTON_DOWN) {
|
||||
l.pt1.y += SPEED;
|
||||
s16 ind = (int)((float)angle/360.0f*1024.0f);
|
||||
fix16 dy = sinFix16(ind);
|
||||
fix16 dx = cosFix16(ind);
|
||||
l.pt1.y -= fix16ToInt(fix16Mul(dy, FIX16(SPEED)));
|
||||
l.pt1.x -= fix16ToInt(fix16Mul(dx, FIX16(SPEED)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user