cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 2501|回复: 0

[求助] 哪儿错了

[复制链接]
发表于 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[37];
float cos_table[37];
int key;
void recalc_table()
{
int t;
for (t = 0;t < 180 ;t+=4){
sin_table[t] = sinf(PI*t/180.0);
cos_table[t] = 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[t] * r + cx;
y = sin_table[t] * 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cnCalc计算器论坛

GMT+8, 2024-4-20 03:16 , Processed in 0.038006 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表