better movement
This commit is contained in:
parent
0135a07875
commit
48e1ff0475
23
src/main.c
23
src/main.c
@ -4,6 +4,7 @@
|
||||
|
||||
Line l;
|
||||
s16 angle = 0;
|
||||
s16 x, y;
|
||||
|
||||
const u8 map[10][10] = {{1,1,1,1,1,1,1,1,1,1},
|
||||
{1,0,0,0,0,0,0,0,0,1},
|
||||
@ -141,6 +142,8 @@ void mapscan(){
|
||||
|
||||
|
||||
void render(){
|
||||
l.pt1.x = x / 10;
|
||||
l.pt1.y = y / 10;
|
||||
//Clear the bitmap
|
||||
BMP_clear();
|
||||
|
||||
@ -165,13 +168,13 @@ void render(){
|
||||
BMP_flip(1);
|
||||
|
||||
//Increment the destination y coordinate
|
||||
l.pt2.y = l.pt2.y + 2;
|
||||
//l.pt2.y = l.pt2.y + 2;
|
||||
|
||||
//Reset the destination y coordinate if it hits 160
|
||||
if (l.pt2.y == 160)
|
||||
{
|
||||
l.pt2.y = 0;
|
||||
}
|
||||
//if (l.pt2.y == 160)
|
||||
//{
|
||||
//l.pt2.y = 0;
|
||||
//}
|
||||
|
||||
SYS_doVBlankProcess();
|
||||
|
||||
@ -191,15 +194,15 @@ void update(){
|
||||
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)));
|
||||
y += fix16ToInt(fix16Mul(dy, FIX16(SPEED)));
|
||||
x += fix16ToInt(fix16Mul(dx, FIX16(SPEED)));
|
||||
}
|
||||
if(joy & BUTTON_DOWN) {
|
||||
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)));
|
||||
y -= fix16ToInt(fix16Mul(dy, FIX16(SPEED)));
|
||||
x -= fix16ToInt(fix16Mul(dx, FIX16(SPEED)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,6 +214,8 @@ void initVDP(){
|
||||
|
||||
int main()
|
||||
{
|
||||
x = 150;
|
||||
y = 150;
|
||||
initVDP();
|
||||
|
||||
//Initialise the bitmap engine
|
||||
|
Loading…
Reference in New Issue
Block a user