Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Sprite Movement Complication

Author
Message
JackMS
2
Years of Service
User Offline
Joined: 5th Oct 2015
Location:
Posted: 5th Oct 2015 04:18
So here is a problem I have been having that I just cannot seem to get around no matter how many times I try:

I am working on making a 2D game which reflects a current tabletop game. I have 28 tiles that a player can move by clicking and dragging with the mouse. What I have found so far is that any arrays I set up to store the locations of the pieces might reset themselves every so often without any inherit call to reset. Another problem I found is that a player can move about 16 of the sprites without any difficulty. Once the player attempts to move the next sprite, the piece does not respond to the mouse movement anymore. Key presses still work but not the mouse. Here is an example excerpt to show what I am doing to move the pieces.

...
#define Pointer 996
#define White 0
#define x 0
#define y 1
...

void LegalMoves (int Piece)
void LoadPieces (void)
...

//global variables
int PieceSelected = 0, Turn = 0, Location[100][4];
...
if (Turn == White)
{
for (int i = 1; i < 15; i++)
{
if (dbSpriteCollision (Pointer, i) && PieceSelected == 0)
PieceSelected = i;
}
}
dbSprite (PieceSelected, dbMouseX(), dbMouseY(), PieceSelected);
dbSetSpritePriority (PieceSelected, 1);
if (PieceSelected !=0)LegalMoves(PieceSelected);
...
for (int i = 1; i < 29; i++)
{
dbSprite (i, Location[i][x], Location[i][y], i);
}
void LegalMoves(int Piece)
{
//Displays where the next piece may be placed
}
void LoadPieces(void)
{
//LoadImages...
...
for (int i = 1; i <= 100; i++)
{
dbOffsetSprite (i, 89/2, 78/2);
}
}

So this works for about the first 15 - 16 pieces. It initially worked for all the pieces but then stopped out of no where and I cannot seem to find out why. I have searched the internet for any similar problems and have yet to come across any. If anyone knows some tips in regards with this it would be greatly appreciated. Thanks.

Login to post a reply

Server time is: 2017-12-15 13:56:47
Your offset time is: 2017-12-15 13:56:47