|
楼主 |
发表于 2012-9-1 17:04:48
|
显示全部楼层
#include "fxlib.h"
#define BALL_RADIUS 5
int mx, my, bx, by;
int key;
float vx, vy,fx,fy;
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned int key;
Bdisp_AllClr_DDVRAM();
mx = 63;
bx = 63;
my = 10;
by = 10;
vx = 0;
vy = 0;
fx=0;
fy=0;
while( 1 )
{
fx = mx - bx;
fy = my - by + 20;
vx = vx+(fx / 40);
vy =vy +(fy / 40);
vx =vx* 0.98;
vy =vy* 0.98;
bx =bx+ vx;
by = bx+vy;
fillcircle( bx, by, BALL_RADIUS );
drawmouse( mx, my );
Bdisp_DrawLineVRAM( mx, my, bx, by );
Bdisp_PutDisp_DD();
if( IsKeyDown( KEY_CTRL_UP ) )
my -= 3;
if( IsKeyDown( KEY_CTRL_DOWN ) )
my += 3;
if( IsKeyDown( KEY_CTRL_LEFT ) )
mx -= 3;
if( IsKeyDown( KEY_CTRL_RIGHT) )
mx += 3;
if( IsKeyDown( KEY_CTRL_EXIT ) )
break;
Sleep( 30 );
}
return 1;
}
int drawmouse(int x,int y)
{
Bdisp_DrawLineVRAM( x-1, y, x+1, y );
Bdisp_DrawLineVRAM( x, y-1, x, y+1 );
Bdisp_PutDisp_DD();
}
int fillcircle(int cx,int cy,int r)
{
const float PI = 3.1415926535,step = PI/48.0;
int x,y,px,py;
float t;
px = cx + r;
py = cy;
for (t = step;t<2 * PI;t += step){
x = cosf(t) * r + cx;
y = sinf(t) * r + cy;
Bdisp_DrawLineVRAM(x,y,px,py);
px = x,py = y;
}
x = cx + r;
y = cy;
Bdisp_DrawLineVRAM(x,y,px,py);
Bdisp_PutDisp_DD();
}
#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 |
|