Archived

This topic is now archived and is closed to further replies.

drarem

values = 0 ? Help please...

Recommended Posts

Here is what I have so far.
    class hSprite {
  private:
    DD7S sprite;
    char fname[128];
    RECT *bnk;        // for tiled sprites (sprite banks)

    DWORD clrref;
    DWORD options;
  public:
    int xs;
    int ys;
    int *HitMap;
    int *xxs;    // for sprite banks

    int *yys;    // for sprite banks

    int **BHitMap;
    RECT lpB;
    int LoadSprite(char *, int, int, DWORD, BOOL);
    int LoadSpriteBank(char *, int, int, int, int, DWORD, BOOL);
    int Sprite(DD7S, int x, int y);
    int Sprite(int num, DD7S bg, int x, int y);  
    int SprPut(DD7S);
    int SprUpdate(int, int);
    int Collide(int *, int *, int, int, int, int);
};  

and then here's where I fill the array of *xxs and *yys when I call Sprite (being pre-allocated in another function):

      int hSprite::Sprite(int num, DD7S bg, int x, int y)  {
    xxs[num]=x; yys[num]=y;
    bg->BltFast(xxs[num], yys[num], sprite, &bnk[num], options);
}  

Now when I call Collide(sprite1.sprite, sprite1.xxs[0], sprite2.sprite, sprite2.xxs[1]) from my main loop, the correct values are in there.

When I do this:
      
int CollisionBank(hSprite spr1, int frm1, hSprite spr2, int frm2) {
    int i, j, nx, ny, col=0, ncx=0, ncy=0, rmax=0;
    int dx=spr1.xxs[frm1];
    int dy=spr1.yys[frm1];
    int sx=spr2.xxs[frm2];
    int sy=spr2.yys[frm2];
    char buff[255];

    nx = abs(dx-sx); // nx = x offset from border of tile2 into tile1

    ny = abs(dy-sy); // ny = y offset from border of tile2 into tile1

    sprintf(buff,"dx,dy,sx,sy,xwid,yhgt=%d,%d,%d,%d,%d,%d\n\n",dx,dy,sx,sy,spr1.xwid,spr2.yhgt);    
in the sprintf, the values are 0 when there should be x and y coords in there. The spr1.xwid and spr2.yhgt are good however, they are 32 x 32. The CollisionBank is called from the main loop, which exists in another .H/.CPP file. I fseek, therefore I fam. [edited by - drarem on July 16, 2002 11:38:21 AM]

Share this post


Link to post
Share on other sites