cheronder 发表于 2012-11-24 17:12:24

哪儿错了

哪儿错了?
#include "fxlib.h"
#include "mathf.h"
#define BALL_RADIUS 5
#define X_MAX       127
#define Y_MAX       63
#define LOST      -0.95
float x, y, vx, vy, ax, ay;
const float PI = 3.1415926;
float sin_table;
float cos_table;
int key;
void recalc_table()
{
int t;
for (t = 0;t < 180 ;t+=4){
sin_table = sinf(PI*t/180.0);
cos_table = cosf(PI*t/180.0);
}
}
void fillcircle(int cx,int cy,int r)
{
int x,y,t;
for (t = 0;t<180;t+=4){
x = cos_table * r + cx;
y = sin_table * r + cy;
Bdisp_DrawLineVRAM(x,y,x,2*cy-y);
}


int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;

x= 10; y= 10;
vx = 2;vy = 0;
ax = 0;ay = 0.2;
Bdisp_AllClr_DDVRAM();
recalc_table();
while( 1 )
{
   Bdisp_AllClr_DDVRAM();
    fillcircle( x, y, BALL_RADIUS );   
if (Bkey_GetKeyWait(&kcode1, &kcode2, KEYWAIT_HALTOFF_TIMEROFF, 0,1, &unused)==KEYREP_KEYEVENT) {
if ((kcode1==2)&&(kcode2==9))
vy -= 0.5;
if ((kcode1==3)&&(kcode2==8))
vy += 0.5;
if ((kcode1==3)&&(kcode2==9))
vx -= 0.5;
if ((kcode1==2)&&(kcode2==8))
vx += 0.5;
if ((kcode1==4)&&(kcode2==8))
break;
}
Bdisp_PutDisp_DD();
    update();
    Sleep( 30 );
}

}




void update()
{
vx += ax; vy += ay;
x += vx*0.75; y += vy*0.75;

if( x > X_MAX - BALL_RADIUS + 1 )
{
    x = X_MAX - BALL_RADIUS; vx *= LOST;
}
else if( x < BALL_RADIUS - 1 )
{
    x = BALL_RADIUS; vx *= LOST;
}

if( y > Y_MAX - BALL_RADIUS + 1 )
{
    y = Y_MAX - BALL_RADIUS; vy *= LOST;
}
else if( y < BALL_RADIUS - 1 )
{
    y = BALL_RADIUS; vy *= LOST;
}
}



#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
int InitializeSystem(int isAppli, unsigned short OptionNum)
{
    return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}
#pragma section
页: [1]
查看完整版本: 哪儿错了