Some of the code I use for mouse replacement using sprites includes-
Header:
#ifndef __TAMOUSE_H__
#define __TAMOUSE_H__
#ifndef __TADARKSDK_H__
#include "DarkSDK.h"
#endif
// our classes
class taPointer
{
private:
int plainid; // sprite image id for free-float pointer
int handid; // sprite image id for pointer over object
int currid; // id to use for image
int m_x,m_y; // mouse position
void UsePlainPointer() {currid=plainid;}
void UseHandPointer() {currid=handid;}
public:
taPointer::taPointer() {plainid=0;handid=0;m_x=0;m_y=0;}
int Initialise(char* plain,char* hand);
void CheckForMouseAction();
};
// object for access
extern taPointer myPtr;
#endif
Implementation:
#include "DarkSDK.h"
#include "taMouse.hpp"
#include "taImages.hpp"
// my class
taPointer myPtr;
int taPointer::Initialise(char* plainfile,char* handfile)
{
// prior to loading images, set something to allow black as see through
dbSetImageColorKey(0,0,0);
// load the images for the plain and pointer files
plainid = myImages.AddNewImage("plainpnt",plainfile);
// check results
if (plainid == 0) return 0;
// get image ids for plain pointer image
handid = myImages.AddNewImage("handpnt",handfile);
// check results
if (handid == 0) return 0;
// set initial image type
currid = plainid;
// initialise the mouse position
m_x = dbScreenWidth()/2;
m_y = dbScreenHeight()/2;
// create the sprite
dbSprite(1,m_x,m_y,currid);
// size it
dbScaleSprite(1,16);
// hide the mouse
dbHideMouse();
// return good
return 1;
}
void taPointer::CheckForMouseAction()
{
// get the basic mouse position
m_x = dbMouseX();
m_y = dbMouseY();
// set the sprite position and image
dbSprite(1,m_x,m_y,currid);
}
My pointer class only uses two types, at the moment, a hand and a ball.
The taImages class (myImages), loads images and makes them accessable by name. Replace those bits with whatever you want to load you pointers.
Somewhere in the main loop, you call the CheckForMouseAction() function to update the mouse.
I've been porting my DBPro code and haven't gotten to where the CheckForMouseAction() changes which image is used. I haven't finished the port yet, but this gives the basics for using a sprite for your mouse. The header includes functions for switching between the two types.
You can easily change this to have an array of image ideas and use an index to pick the one that is active.
Just some sample code that currently works.
Cheers,
Ancient Lady