ereeer 发表于 2012-9-1 15:42:01

这段SDK代码哪儿错了

根据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

ereeer 发表于 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

重发

ereeer 发表于 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 );
}
好像似这错了

rphero 发表于 2012-9-1 15:55:57

我建议你先看看最最基本的sdk教程,你这些函数,allclr(),drawline()什么的在sdk里都叫什么

ereeer 发表于 2012-9-1 16:01:34

我知道,我已把 fxlib.h翻了个底朝天,我原是学vb的,一些东西大致能懂

ereeer 发表于 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
这样?

ereeer 发表于 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

编译成功,但是实验时怎么一片空白、

ereeer 发表于 2012-9-1 17:02:06

我都逐字检查过了,为什么还是空白

ereeer 发表于 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

ereeer 发表于 2012-9-1 17:11:52

成功了, 原来忘记加mathf.h了

imath 发表于 2012-9-1 17:41:44

Bdisp_DrawlLneVRAM应该改成Bdsisp.DrawlLneVRAM
页: [1]
查看完整版本: 这段SDK代码哪儿错了