Hello Everyone,
(Skip the first paragraph if you wanna get to the problem)
First of all, I would like to say thank you to everyone who has responded to any of my post over the past year. I have learned a tremendous amount from everyone's responses while learning how to program and use the DarkGDK library. This will be a valuable tool for years to come and I hope that with my continued use, I will be able to help others on this forum.
Noe for the problem, I have a "Pretty simple" program that has been giving me trouble for a good while. Its my final for a class. I've been working on it for about a semester. I know that there are some things that would make the program more efficient so please bare with me with the code below. The issue I am having is as follows:
Whenever player one scores, their score shoots up to 500+ for no reason.
I have debugged the program several times, changed numerous things within the program, and did every check I could with no success at all. Even my randoms SEEM to be correct. If someone wouldn't mind taking a look or maybe even running that program, that would be great.
I have asked my teacher several times about how to fix this and she doesn't even see the issue.
I am NOT looking for a "Change this to this and its fixed." I'm looking for tips on what is wrong with an explanation. Thank you to anyone who looks and responds to this.
#include "DarkGDK.h"
// Constants
const int BACKGROUND = 30;
const int TILE_WIDTH_HEIGHT = 77;
const int TILE_COLS = 4;
const int TILE_ROWS = 3;
const int SIZED = 12;
const int OFFSET_X = 13;
const int OFFSET_Y = 0;
const int WAIT = 2000;
// Constants to load the cards images
const int APPLE_IMAGE = 1;
const int BANANA_IMAGE = 2;
const int CHERRIES_IMAGE = 3;
const int GRAPES_IMAGE = 4;
const int LEMON_IMAGE = 5;
const int ORANGE_IMAGE = 6;
const int APPLE_IMAGE_COPY = 7;
const int BANANA_IMAGE_COPY = 8;
const int CHERRIES_IMAGE_COPY = 9;
const int GRAPES_IMAGE_COPY = 10;
const int LEMON_IMAGE_COPY = 11;
const int ORANGE_IMAGE_COPY = 12;
const int CARD_BACK_IMAGE = 13;
const int CARD_BACK_IMAGE_1 = 14;
const int CARD_BACK_IMAGE_2 = 15;
const int CARD_BACK_IMAGE_3 = 16;
const int CARD_BACK_IMAGE_4 = 17;
const int CARD_BACK_IMAGE_5 = 18;
const int CARD_BACK_IMAGE_6 = 19;
const int CARD_BACK_IMAGE_7 = 20;
const int CARD_BACK_IMAGE_8 = 21;
const int CARD_BACK_IMAGE_9 = 22;
const int CARD_BACK_IMAGE_10 = 23;
const int CARD_BACK_IMAGE_11 = 24;
// Constants to load the card as Sprites
const int APPLE = 1;
const int BANANA = 2;
const int CHERRIES = 3;
const int GRAPES = 4;
const int LEMON = 5;
const int ORANGE = 6;
const int APPLE_COPY = 7;
const int BANANA_COPY = 8;
const int CHERRIES_COPY = 9;
const int GRAPES_COPY = 10;
const int LEMON_COPY = 11;
const int ORANGE_COPY = 12;
const int CARD_BACK = 13;
const int CARD_BACK_1 = 14;
const int CARD_BACK_2 = 15;
const int CARD_BACK_3 = 16;
const int CARD_BACK_4 = 17;
const int CARD_BACK_5 = 18;
const int CARD_BACK_6 = 19;
const int CARD_BACK_7 = 20;
const int CARD_BACK_8 = 21;
const int CARD_BACK_9 = 22;
const int CARD_BACK_10 = 23;
const int CARD_BACK_11 = 24;
// Constants for the pointer
const int POINTER_IMAGE = 28;
const int POINTER_SPRITE = 28;
// Refresh Rate
const int REFRESH_RATE = 60;
// Prototypes
void setUp();
void shuffle(int [], int);
void checkFirstRun();
bool winCondition(int, int);
void results(int, int);
void cleanUp();
void swap(int &, int&);
void displayDeck(int[][TILE_COLS], int);
void displayCardBacks(int[][TILE_COLS], int);
void arrayConvert(int[], int[][TILE_COLS]);
void initMouse();
void updateMouse();
bool mouseFullClick(int &, int &);
void overlay(int &, int &, int &, int&, int&, int&, int&, int&, int&, int&, int&);
bool checkClick(int &);
int checkCard(int &);
void deleteMatchedSprites(int, int, int);
void playerTurn(int, int, int);
//***********************************************************
// The "Main Function" of the program
//***********************************************************
void DarkGDK()
{
// Variables
int player1Cards, player2Cards;
int card1 = 0, card2 = 0, card3 = 0, card4 = 0, // Initialized to stop the warning
card5 = 0, card6 = 0, card7 = 0, card8 = 0,
card9 = 0, card10 = 0, card11 = 0, card12 = 0;
int rows = TILE_ROWS, cols = TILE_COLS;
int mouseX, mouseY;
int cardHold1 = 0, cardHold2 = 0, tempHold = 0,
sameCard = 0, sameCardHold = 0, card1Back = 0,
card2Back = 0;
int cardsRevealed = 0;
int playTurn = 0;
// Program Setup
setUp();
// Create an array to hold the image numbers
int initDeck[SIZED] = { APPLE, APPLE_COPY, BANANA, BANANA_COPY, CHERRIES, CHERRIES_COPY,
GRAPES, GRAPES_COPY, LEMON, LEMON_COPY, ORANGE, ORANGE_COPY };
int deck[TILE_ROWS][TILE_COLS] = { {card1, card2, card3, card4 },
{card5, card6, card7, card8 },
{card9, card10, card11, card12}
};
int cardBack[TILE_ROWS][TILE_COLS] ={ {CARD_BACK, CARD_BACK_1, CARD_BACK_2, CARD_BACK_3 },
{CARD_BACK_4, CARD_BACK_5, CARD_BACK_6, CARD_BACK_7 },
{CARD_BACK_8, CARD_BACK_9, CARD_BACK_10, CARD_BACK_11 }
};
// shuffles the cards
shuffle(initDeck, SIZED);
// Converts the Array from 1d to 2d
arrayConvert(initDeck, deck);
// Intro Screen and checks first run
checkFirstRun();
player1Cards = 0;
player2Cards = 0;
// Game Loop
while ( LoopGDK() && (!winCondition(player1Cards, player2Cards)))
{
// Display the Background image
dbPasteImage(BACKGROUND, 0, 0);
updateMouse();
displayDeck(deck, TILE_ROWS);
displayCardBacks(cardBack, TILE_ROWS);
playerTurn(playTurn, player1Cards, player2Cards);
dbSync();
if (mouseFullClick(mouseX, mouseY) )
{
overlay(cardsRevealed, cardHold1, cardHold2, tempHold,
sameCard, sameCardHold, card1Back, card2Back, playTurn, player1Cards, player2Cards);
dbSync();
}
}
// Deletes all image files from memory
cleanUp();
// Displays the Results
results(player1Cards, player2Cards);
}
//***********************************************************
// The setUp functions loads everything into memory that
// Program will need to operate.
//***********************************************************
void setUp()
{
// Set Window Title
dbSetWindowTitle("Matching Card Game");
// Set the Image Color Key
dbSetImageColorKey(0,255,0);
// Initialize the mouse
initMouse();
// Load the tile image
dbLoadImage("background.bmp", BACKGROUND);
//Set the text to 24 point Arial font.
dbSetTextFont("Arial");
dbSetTextSize(24);
// Card Imges
dbLoadImage("Apple.bmp", APPLE_IMAGE);
dbLoadImage("Banana.bmp", BANANA_IMAGE);
dbLoadImage("Cherries.bmp", CHERRIES_IMAGE);
dbLoadImage("Grapes.bmp", GRAPES_IMAGE);
dbLoadImage("Lemon.bmp", LEMON_IMAGE);
dbLoadImage("Orange.bmp", ORANGE_IMAGE);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE);
dbLoadImage("Apple.bmp", APPLE_IMAGE_COPY);
dbLoadImage("Banana.bmp", BANANA_IMAGE_COPY);
dbLoadImage("Cherries.bmp", CHERRIES_IMAGE_COPY);
dbLoadImage("Grapes.bmp", GRAPES_IMAGE_COPY);
dbLoadImage("Lemon.bmp", LEMON_IMAGE_COPY);
dbLoadImage("Orange.bmp", ORANGE_IMAGE_COPY);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_1);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_2);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_3);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_4);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_5);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_6);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_7);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_8);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_9);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_10);
dbLoadImage("CardBack.bmp", CARD_BACK_IMAGE_11);
dbSetSpriteImage(APPLE, APPLE_IMAGE);
dbSetSpriteImage(BANANA, BANANA_IMAGE);
dbSetSpriteImage(CHERRIES, CHERRIES_IMAGE);
dbSetSpriteImage(GRAPES, GRAPES_IMAGE);
dbSetSpriteImage(LEMON, LEMON_IMAGE);
dbSetSpriteImage(ORANGE, ORANGE_IMAGE);
dbSetSpriteImage(APPLE_COPY, APPLE_IMAGE_COPY);
dbSetSpriteImage(BANANA_COPY, BANANA_IMAGE_COPY);
dbSetSpriteImage(CHERRIES_COPY, CHERRIES_IMAGE_COPY);
dbSetSpriteImage(GRAPES_COPY, GRAPES_IMAGE_COPY);
dbSetSpriteImage(LEMON_COPY, LEMON_IMAGE_COPY);
dbSetSpriteImage(ORANGE_COPY, ORANGE_IMAGE_COPY);
dbSetSpriteImage(CARD_BACK, CARD_BACK_IMAGE);
dbSetSpriteImage(CARD_BACK_1, CARD_BACK_IMAGE_1);
dbSetSpriteImage(CARD_BACK_2, CARD_BACK_IMAGE_2);
dbSetSpriteImage(CARD_BACK_3, CARD_BACK_IMAGE_3);
dbSetSpriteImage(CARD_BACK_4, CARD_BACK_IMAGE_4);
dbSetSpriteImage(CARD_BACK_5, CARD_BACK_IMAGE_5);
dbSetSpriteImage(CARD_BACK_6, CARD_BACK_IMAGE_6);
dbSetSpriteImage(CARD_BACK_7, CARD_BACK_IMAGE_7);
dbSetSpriteImage(CARD_BACK_8, CARD_BACK_IMAGE_8);
dbSetSpriteImage(CARD_BACK_9, CARD_BACK_IMAGE_9);
dbSetSpriteImage(CARD_BACK_10, CARD_BACK_IMAGE_10);
dbSetSpriteImage(CARD_BACK_11, CARD_BACK_IMAGE_11);
dbSetSpritePriority(APPLE, 3);
dbSetSpritePriority(BANANA, 3);
dbSetSpritePriority(CHERRIES, 3);
dbSetSpritePriority(GRAPES, 3);
dbSetSpritePriority(LEMON, 3);
dbSetSpritePriority(ORANGE, 3);
dbSetSpritePriority(APPLE_COPY, 3);
dbSetSpritePriority(BANANA_COPY, 3);
dbSetSpritePriority(CHERRIES_COPY, 3);
dbSetSpritePriority(GRAPES_COPY, 3);
dbSetSpritePriority(LEMON_COPY, 3);
dbSetSpritePriority(ORANGE_COPY, 3);
dbSetSpritePriority(CARD_BACK, 2);
// Turn off auto refresh and set refresh rate
dbSyncOn();
dbSyncRate(REFRESH_RATE);
}
//***********************************************************
// The shuffle function shuffles the arrays
//***********************************************************
void shuffle(int numbers[], int size)
{
// Variables to hold random subscript
int randomSub;
// Seed the random number generator
dbRandomize( dbTimer() );
// Step throught the array, swapping each element
// with a random element
for (int index = 0; index < size; index++)
{
// Get a random subscript
randomSub = dbRND(size-1);
// Swap two elements
swap( numbers[index], numbers[randomSub] );
}
}
//***********************************************************
// Checks for a first play of the game
//***********************************************************
void checkFirstRun()
{
dbSync();
dbHideSprite(POINTER_SPRITE);
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()/2),
"Match the cards. The player with the most cards wins!");
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()/2 + 90),
"Press any key to begin.");
dbSync();
dbWaitKey();
dbShowSprite(POINTER_SPRITE);
dbCLS();
}
//***********************************************************
// The winCondition Function checks to assure that a win
// condition has not been reached.
//***********************************************************
bool winCondition(int player1Cards, int player2Cards)
{
if ((player1Cards >=4)||(player2Cards >= 4) ||
(player1Cards+player2Cards == 6))
{
return true;
}
else
{
return false;
}
}
//***********************************************************
// The results function displays the end message for the
// winner or the looser
//***********************************************************
void results(int player1Cards, int player2Cards)
{
dbCLS();
if (player1Cards > player2Cards)
{
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()/2), "Player 1 Wins!");
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()*.75), "Press any key to exit...");
dbSync();
dbWaitKey();
}
else if (player1Cards == player2Cards)
{
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()/2), "This game was a tie!");
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()*.75), "Press any key to exit...");
dbSync();
dbWaitKey();
}
else
{
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()/2), "Player 2 Wins!");
dbCenterText((dbScreenWidth()/2), (dbScreenHeight()*.75), "Press any key to exit...");
dbSync();
dbWaitKey();
}
}
//***********************************************************
// The cleanUp deletes everything the program needed loaded
// from memory.
//***********************************************************
void cleanUp()
{
for (int r = 0; r <= 24; r++) // Counts up for the number of images and sprites in 1-24
{
dbDeleteBitmap(r);
dbDeleteSprite(r);
}
dbDeleteSprite(28);
dbDeleteBitmap(28);
dbDeleteBitmap(30);
}
//***********************************************************
// The swap function accepts two int arguments passed
// by reference. The function swaps the contents of the
// two arguments.
//***********************************************************
void swap(int &a, int &b)
{
// Assign a to temp
int temp = a;
// Assign b to a.
a = b;
// Assign temp to b.
b = temp;
}
//***********************************************************
// Converts a 1d array into a 2d array
//***********************************************************
void arrayConvert(int initDeck[], int deck[][TILE_COLS])
{
int q = 0;
for (int r = 0; r < TILE_ROWS; r++)
{
for (int c = 0; c < TILE_COLS; c++)
{
deck[r][c] = initDeck[q];
q++;
}
}
}
//***********************************************************
// Displays the Deck on the screen
//***********************************************************
void displayDeck(int deck[][TILE_COLS], int rows)
{
// Variables for card coordinates
int x = 0, y = 0;
for (int r = 0; r < rows; r++)
{
// Set x to 0.
x = 0;
for (int c = 0; c < TILE_COLS; c++)
{
dbSprite( deck[r][c], x, y, deck[r][c] );
x += TILE_WIDTH_HEIGHT + (TILE_WIDTH_HEIGHT * .4);
}
// Increase y for the next row
y += TILE_WIDTH_HEIGHT + (TILE_WIDTH_HEIGHT * .4);
}
}
//***********************************************************
// Displays the card backs on the screen
//***********************************************************
void displayCardBacks(int cardBacks[][TILE_COLS], int rows)
{
// Variables for card coordinates
int x = 0, y = 0;
for (int r = 0; r < rows; r++)
{
// Set x to 0.
x = 0;
for (int c = 0; c < TILE_COLS; c++)
{
dbSprite( cardBacks[r][c], x, y, cardBacks[r][c] );
x += TILE_WIDTH_HEIGHT + (TILE_WIDTH_HEIGHT * .4);
}
// Increase y for the next row
y += TILE_WIDTH_HEIGHT + (TILE_WIDTH_HEIGHT * .4);
}
}
//***********************************************************
// Initialize the mouse pointer
//***********************************************************
void initMouse()
{
dbHideMouse();
int centerX = dbScreenWidth()*.75;
int centerY = dbScreenHeight()*.75;
dbPositionMouse(centerX, centerY);
dbLoadImage("HandPointer.bmp", POINTER_IMAGE);
dbSprite(POINTER_SPRITE, centerX, centerY, POINTER_IMAGE);
dbOffsetSprite(POINTER_SPRITE, OFFSET_X, OFFSET_Y);
dbSetSpritePriority(POINTER_SPRITE, 1);
}
//***********************************************************
// Update the mouse's position
//***********************************************************
void updateMouse()
{
int mouseX = dbMouseX();
int mouseY = dbMouseY();
dbSprite(POINTER_SPRITE, mouseX, mouseY, POINTER_IMAGE);
}
//***********************************************************
// Checks to see if the mouse is being clicked
//***********************************************************
bool mouseFullClick(int &x, int &y)
{
bool buttonClick = false;
if (dbMouseClick() == 1)
{
x = dbMouseX();
y = dbMouseY();
while ( dbMouseClick() == 1)
{
// Do nothing
}
buttonClick = true;
}
return buttonClick;
}
//***********************************************************
// Check to see if sprite collisions have occured
//***********************************************************
void overlay(int &cardsRevealed, int &card1, int &card2, int &tempHold,
int &sameCard, int &sameCardHold, int &card1Back,
int &card2Back, int &playTurn, int &player1Cards, int &player2Cards)
{
// Variable for temp holding
int temp;
if ( checkClick(tempHold) )
{
if (cardsRevealed == 0)
{
card1Back = tempHold;
card1 = checkCard(sameCard);
sameCardHold = sameCard;
cardsRevealed++;
}
else if (cardsRevealed == 1)
{
card2Back = tempHold;
temp = checkCard(sameCard); // Just calls the function so sameCard is refreshed
if (sameCard != sameCardHold)
{
card2 = checkCard(sameCard);
if (card1 == card2)
{
dbPasteImage(BACKGROUND, 0, 0);
dbCenterText((dbScreenWidth()*.5), (dbScreenHeight()*.8),
"We have a match!");
dbSync();
dbWait(WAIT);
deleteMatchedSprites(card1, card1Back, card2Back);
cardsRevealed = 0;
card1 = 99;
card2 = 98;
if (playTurn == 0)
{
player1Cards++;
playTurn++;
}
else
{
player2Cards++;
playTurn--;
}
dbSync();
}
else
{
cardsRevealed++;
card1 = 99;
card2 = 98;
}
}
else
{
// Do nothing
}
}
else
{
if (playTurn == 0)
playTurn++;
else
playTurn--;
for (int i = 13; i < 25; i++)
{
if (dbSpriteExist(i) == 1)///////
dbShowSprite(i);
}
cardsRevealed = 0;
}
}
else
{
if (cardsRevealed < 2)
{
//Do Nothing
}
else
{
if (playTurn == 0)
playTurn++;
else
playTurn--;
for (int i = 13; i < 25; i++)
{
if (dbSpriteExist(i) == 1)///////
dbShowSprite(i);
}
cardsRevealed = 0;
}
}
}
//***********************************************************
// Check to see if the clicks amount to a collision
//***********************************************************
bool checkClick(int &tempHold)
{
if (dbSpriteCollision(CARD_BACK, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK);
tempHold = CARD_BACK;
}
else if (dbSpriteCollision(CARD_BACK_1, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_1);
tempHold = CARD_BACK_1;
}
else if (dbSpriteCollision(CARD_BACK_2, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_2);
tempHold = CARD_BACK_2;
}
else if (dbSpriteCollision(CARD_BACK_3, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_3);
tempHold = CARD_BACK_3;
}
else if (dbSpriteCollision(CARD_BACK_4, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_4);
tempHold = CARD_BACK_4;
}
else if (dbSpriteCollision(CARD_BACK_5, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_5);
tempHold = CARD_BACK_5;
}
else if (dbSpriteCollision(CARD_BACK_6, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_6);
tempHold = CARD_BACK_6;
}
else if (dbSpriteCollision(CARD_BACK_7, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_7);
tempHold = CARD_BACK_7;
}
else if (dbSpriteCollision(CARD_BACK_8, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_8);
tempHold = CARD_BACK_8;
}
else if (dbSpriteCollision(CARD_BACK_9, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_9);
tempHold = CARD_BACK_9;
}
else if (dbSpriteCollision(CARD_BACK_10, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_10);
tempHold = CARD_BACK_10;
}
else if (dbSpriteCollision(CARD_BACK_11, POINTER_SPRITE))
{
dbHideSprite(CARD_BACK_11);
tempHold = CARD_BACK_11;
}
else
return false;
return true;
}
//***********************************************************
// Check to see which card is being clicked and assign num
// to a variable. For comparison later.
//***********************************************************
int checkCard(int &sameCard)
{
int cardNumber;
if (dbSpriteCollision(APPLE, POINTER_SPRITE))
{
cardNumber = 1;
sameCard = 1;
}
else if (dbSpriteCollision(APPLE_COPY, POINTER_SPRITE))
{
cardNumber = 1;
sameCard = 2;
}
else if (dbSpriteCollision(BANANA, POINTER_SPRITE))
{
cardNumber = 2;
sameCard = 3;
}
else if (dbSpriteCollision(BANANA_COPY, POINTER_SPRITE))
{
cardNumber = 2;
sameCard = 4;
}
else if (dbSpriteCollision(CHERRIES, POINTER_SPRITE))
{
cardNumber = 3;
sameCard = 5;
}
else if (dbSpriteCollision(CHERRIES_COPY, POINTER_SPRITE))
{
cardNumber = 3;
sameCard = 6;
}
else if (dbSpriteCollision(GRAPES, POINTER_SPRITE))
{
cardNumber = 4;
sameCard = 7;
}
else if (dbSpriteCollision(GRAPES_COPY, POINTER_SPRITE))
{
cardNumber = 4;
sameCard = 8;
}
else if (dbSpriteCollision(LEMON, POINTER_SPRITE))
{
cardNumber = 5;
sameCard = 9;
}
else if (dbSpriteCollision(LEMON_COPY, POINTER_SPRITE))
{
cardNumber = 5;
sameCard = 10;
}
else if (dbSpriteCollision(ORANGE, POINTER_SPRITE))
{
cardNumber = 6;
sameCard = 11;
}
else if (dbSpriteCollision(ORANGE_COPY, POINTER_SPRITE))
{
cardNumber = 6;
sameCard = 12;
}
return cardNumber;
}
//***********************************************************
// Deletes the matched sprites
//***********************************************************
void deleteMatchedSprites(int card1, int cardBack1, int cardBack2)
{
if (card1 == 1)
{
dbHideSprite(APPLE);
dbHideSprite(APPLE_COPY);
dbDeleteImage(APPLE);
dbDeleteImage(APPLE_COPY);
dbDeleteSprite(APPLE);
dbDeleteSprite(APPLE_COPY);
}
else if (card1 == 2)
{
dbHideSprite(BANANA);
dbHideSprite(BANANA_COPY);
dbDeleteImage(BANANA);
dbDeleteImage(BANANA_COPY);
dbDeleteSprite(BANANA);
dbDeleteSprite(BANANA_COPY);
}
else if (card1 == 3)
{
dbHideSprite(CHERRIES);
dbHideSprite(CHERRIES_COPY);
dbDeleteImage(CHERRIES);
dbDeleteImage(CHERRIES_COPY);
dbDeleteSprite(CHERRIES);
dbDeleteSprite(CHERRIES_COPY);
}
else if (card1 == 4)
{
dbHideSprite(GRAPES);
dbHideSprite(GRAPES_COPY);
dbDeleteImage(GRAPES);
dbDeleteImage(GRAPES_COPY);
dbDeleteSprite(GRAPES);
dbDeleteSprite(GRAPES_COPY);
}
else if (card1 == 5)
{
dbHideSprite(LEMON);
dbHideSprite(LEMON_COPY);
dbDeleteImage(LEMON);
dbDeleteImage(LEMON_COPY);
dbDeleteSprite(LEMON);
dbDeleteSprite(LEMON_COPY);
}
else if (card1 == 6)
{
dbHideSprite(ORANGE);
dbHideSprite(ORANGE_COPY);
dbDeleteImage(ORANGE);
dbDeleteImage(ORANGE_COPY);
dbDeleteSprite(ORANGE);
dbDeleteSprite(ORANGE_COPY);
}
dbDeleteImage(cardBack1);
dbDeleteImage(cardBack2);
dbDeleteSprite(cardBack1);
dbDeleteSprite(cardBack2);
}
//***********************************************************
// Deletes the matched sprites
//***********************************************************
void playerTurn(int playTurn, int player1Cards, int player2Cards)
{
dbCenterText((dbScreenWidth()*.8), (dbScreenHeight()*.15), "Player 1");
dbCenterText((dbScreenWidth()*.8), (dbScreenHeight()*.25), dbStr(player1Cards));
dbCenterText((dbScreenWidth()*.8), (dbScreenHeight()*.65), "Player 2");
dbCenterText((dbScreenWidth()*.8), (dbScreenHeight()*.75), dbStr(player2Cards));
if (playTurn == 0)
{
dbCenterText((dbScreenWidth()*.8), (dbScreenHeight()*.40), "Player 1 Turn");
}
else
{
dbCenterText((dbScreenWidth()*.8), (dbScreenHeight()*.40), "Player 2 Turn");
}
}