cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 6179|回复: 10

[fx-9860/9750] 这段SDK代码哪儿错了

[复制链接]
发表于 2012-9-1 15:42:01 | 显示全部楼层 |阅读模式
根据wudy的WSC & FVM 1.2 中的例子spring.c改编(我是c小白,说详细点)
#include "fxlib.h"
#define BALL_RADIUS 5
int mx, my, bx, by;
  int key;
  float vx, vy;
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;
    Bdisp_AllClr_DDVRAM();
    mx = bx = 63; my = by = 10;
    vx = vy = 0;
  while( 1 )
  {
    float fx = mx - bx;
    float fy = my - by + 20;
    vx += (fx / 40);
    vy += (fy / 40);
    vx *= 0.98; vy *= 0.98;
    bx += vx; by += vy;
     allclr();
    fillcircle( bx, by, BALL_RADIUS );
    drawmouse( mx, my );
    drawline( mx, my, bx, by );
    putdisp();
    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;
}
#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
 楼主| 发表于 2012-9-1 15:46:01 | 显示全部楼层
#include "fxlib.h"
#define BALL_RADIUS 5
int mx, my, bx, by;
  int key;
  float vx, vy;
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;
    Bdisp_AllClr_DDVRAM();
    mx = bx = 63; my = by = 10;
    vx = vy = 0;

  while( 1 )
  {
    float fx = mx - bx;
    float fy = my - by + 20;
    vx += (fx / 40);
    vy += (fy / 40);
    vx *= 0.98; vy *= 0.98;
    bx += vx; by += vy;
     allclr();
    fillcircle( bx, by, BALL_RADIUS );
    drawmouse( mx, my );
    drawline( mx, my, bx, by );
    putdisp();
    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;
}
void drawmouse( int x, int y )
{
  drawline( x-1, y, x+1, y );
  drawline( x, y-1, x, y+1 );
}
#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

重发
 楼主| 发表于 2012-9-1 15:46:49 | 显示全部楼层
void drawmouse( int x, int y )
{
  drawline( x-1, y, x+1, y );
  drawline( x, y-1, x, y+1 );
}
好像似这错了
发表于 2012-9-1 15:55:57 | 显示全部楼层
我建议你先看看最最基本的sdk教程,你这些函数,allclr(),drawline()什么的在sdk里都叫什么
 楼主| 发表于 2012-9-1 16:01:34 | 显示全部楼层
我知道,我已把 fxlib.h翻了个底朝天,我原是学vb的,一些东西大致能懂
 楼主| 发表于 2012-9-1 16:04:46 | 显示全部楼层
#include "fxlib.h"
#define BALL_RADIUS 5
int mx, my, bx, by;
  int key;
  float vx, vy;
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;
    Bdisp_AllClr_DDVRAM();
    mx = bx = 63; my = by = 10;
    vx = vy = 0;

  while( 1 )
  {
    float fx = mx - bx;
    float fy = my - by + 20;
    vx += (fx / 40);
    vy += (fy / 40);
    vx *= 0.98; vy *= 0.98;
    bx += vx; by += vy;
    Bdisp_AllClr_DDVRAM();
    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;
}
void drawmouse( int x, int y )
{
  Bdisp_DrawlLneVRAM( x-1, y, x+1, y );
  Bdisp_DrawLineVRAM( x, y-1, x, y+1 );
  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
这样?
 楼主| 发表于 2012-9-1 16:14:12 | 显示全部楼层
#include "fxlib.h"
#define BALL_RADIUS 5
int mx, my, bx, by;
  int key;
  float vx, vy;
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;
    Bdisp_AllClr_DDVRAM();
    mx = bx = 63; my = by = 10;
    vx = vy = 0;

  while( 1 )
  {
    float fx = mx - bx;
    float fy = my - by + 20;
    vx += (fx / 40);
    vy += (fy / 40);
    vx *= 0.98; vy *= 0.98;
    bx += vx; by += vy;
    Bdisp_AllClr_DDVRAM();
    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);
}
#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

编译成功,但是实验时怎么一片空白、
 楼主| 发表于 2012-9-1 17:02:06 | 显示全部楼层
我都逐字检查过了,为什么还是空白
 楼主| 发表于 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
 楼主| 发表于 2012-9-1 17:11:52 | 显示全部楼层
成功了, 原来忘记加mathf.h了
发表于 2012-9-1 17:41:44 | 显示全部楼层
Bdisp_DrawlLneVRAM应该改成Bdsisp.DrawlLneVRAM
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-22 08:17 , Processed in 0.193993 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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