This is my first attemped at a basic 2d game, i have only done a few levels so far but what i want is if you get killed to return to a certain point in the game ie level, i can get this to work to a point by deleting the specific level sprites(this is not in the code as i have reverted back to an older copy) but the sprites that are moving and not loaded in the loadlevelsprites function appear on the previous screen as still images and when i reload that level the collision is stuck to the sprites start position, as you can see i am trying to use Boolean's to load the levels when needed and the plan was to go back to any level by setting the bool values as required, anyway heres the code its big so any help at this stage would be great before i get lost in the code.
#include "DarkGDK.h"
//Menu Image constant variables.
const int BACKGROUND = 1;
const int PLAY_NORMAL = 2;
const int PLAY_HOVER = 3;
const int EXIT_NORMAL = 4;
const int EXIT_HOVER = 5;
const int CURSOR = 6;
const int GALLERY_NORMAL = 7;
const int GALLERY_HOVER = 8;
const int CREDITS_NORMAL = 9;
const int CREDITS_HOVER = 10;
const int EXIT = 11;
//player sprite
const int playerSprite = 12;
//startscreen constants
const int FirstScreen = 20;
const int Sign = 21;
const int SignText = 22;
const int Item = 23;
const int Bush = 24;
const int Rock = 25;
const int Goal1 = 26;
const int GotItem = 27;
//beach 1 constants
const int Water = 28;
const int Sand = 29;
const int Crab = 30;
const int Goal2 = 31;
const int Item2 = 32;
const int GotBeachItem1 = 33;
const int Rock2 = 34;
const int Rock3 = 35;
const int Crab1 = 36;
const int Crab2 = 37;
const int BeachSound = 38;
//beach 2 constants
const int Sand2 = 41;
const int Fence1 = 42;
const int Fence2 = 43;
const int Fence3 = 44;
const int Fence4 = 45;
const int Fence5 = 46;
const int Fence6 = 47;
const int Fence7 = 48;
const int Fence8 = 49;
const int Fence9 = 50;
const int Fence10 = 51;
const int Crab3 = 52;
const int SoftSand = 53;
const int Goal3 = 54;
const int WetSand = 55;
const int Item3 = 56;
const int GotBeachItem2 = 57;
const int PalmTree = 58;
const int PalmTree2 = 59;
const int PalmTree3 = 60;
const int PalmTree4 = 61;
const int JungleSound = 39;
const int CaveSound = 40;
//Menu BOOLEAN
bool Menu = true;
bool Exit = false;
//Level BOOLEAN's
bool StartScreen = false;
bool Item1 = false;
bool Beach1 = false;
bool BeachItem1 = false;
bool Beach2 = false;
bool BeachItem2 = false;
bool Beach3 = false;
bool BeachItem3 = false;
//debug bool
bool debugEnabled = true;
void SetupScreen();
void playerMovement(int &playerX, int &playerY, float playerSpeed, int ¤tDirection);
void debug(int &playerX,int &playerY);
void LoadImages(int &playerX,int &playerY);
void LoadMenuSprites();
void LoadSounds();
void MainMenu();
void DeleteMenu();
void LoadStartScreenSprites(int &playerX,int &playerY);
void PlayStartScreen(int &playerX, int &playerY, float playerSpeed, int ¤tDirection);
void LoadBeach1Sprites(int &playerX,int &playerY);
void PlayBeach1(int &playerX, int &playerY, float playerSpeed, int ¤tDirection);
void LoadBeach2Sprites(int &playerX,int &playerY);
void PlayBeach2(int &playerX, int &playerY, float playerSpeed, int ¤tDirection);
// the main entry point for the application is this function
void DarkGDK ( void )
{
// Variables
const int playerSpeed = 2;
int playerX = 528;
int playerY = 460;
int currentDirection = 0;
int num = 0;
int CrabY = 0;
int Crab1Y = 1;
int Crab2Y = 1;
int Crab3Y = 250;
int Reset = 1;
int Reset1 = 1;
int Reset3 = 1;
int WaterY = 150;
int WaterReset = 1;
dbDisableEscapeKey ();
SetupScreen();
LoadImages(playerX,playerY);
LoadSounds();
dbDrawSpritesFirst();
while ( LoopGDK ( ) )
{
if(Menu == true)
{
LoadMenuSprites();
MainMenu();
}//end if
if(StartScreen == true)
{
PlayStartScreen(playerX, playerY, playerSpeed, currentDirection);
}//end if
if(Beach1 == true)
{
LoadBeach1Sprites(playerX,playerY);
PlayBeach1(playerX, playerY, playerSpeed, currentDirection);
dbSprite(Crab,200,0,Crab);
dbSizeSprite(Crab,30,30);
dbSprite(Crab1,450,0,Crab);
dbSizeSprite(Crab1,30,30);
dbSprite(Crab2,730,0,Crab);
dbSizeSprite(Crab2,30,30);
dbSprite(Water,0,600,Water);
//The speed the crab moves at
int Crab_speed = 1;
int Crab_speed2 = 2;
float Water_speed = 2;
//if the reset point is reached then move water in the other direction
if(WaterReset == 1)
{
dbSprite(Water,0, WaterY,Water);
WaterY=WaterY+Water_speed/2;
if(WaterY==680)
{
WaterReset = 0;
}
}
else if(WaterReset == 0)
{
dbSprite(Water,0,WaterY,Water);
WaterY=WaterY-Water_speed;
if(WaterY == 150)
{
WaterReset = 1;
}
}
//if the reset point is reached then move crab in the other direction
if(Reset == 1)
{
dbSprite(Crab,200, CrabY,Crab);
CrabY=CrabY+Crab_speed;
if(CrabY==135)
{
Reset = 0;
}
}
else if(Reset == 0)
{
dbSprite(Crab,200,CrabY,Crab);
CrabY=CrabY-Crab_speed;
if(CrabY == 0)
{
Reset = 1;
}
}
//if the reset point is reached then move crab in the other direction
if(Reset1 == 1)
{
dbSprite(Crab1,450, Crab1Y,Crab);
Crab1Y=Crab1Y+Crab_speed2;
if(Crab1Y==135)
{
Reset1 = 0;
}
}
else if(Reset1 == 0)
{
dbSprite(Crab1,450,Crab1Y,Crab);
Crab1Y=Crab1Y-Crab_speed2;
if(Crab1Y == 1)
{
Reset1 = 1;
}
}
//if the reset point is reached then move crab in the other direction
if(Reset == 1)
{
dbSprite(Crab2,730, Crab2Y,Crab);
Crab2Y=Crab2Y+Crab_speed;
if(Crab2Y==135)
{
Reset = 0;
}
}
else if(Reset == 0)
{
dbSprite(Crab2,730,Crab2Y,Crab);
Crab2Y=Crab2Y-Crab_speed;
if(Crab2Y == 0)
{
Reset = 1;
}
}
}//end if
if(Beach2 == true)
{
PlayBeach2(playerX, playerY, playerSpeed, currentDirection);
int Crab_speed = 1;
float Water_speed = 2;
dbSprite(Crab3,400,400,Crab);
dbSizeSprite(Crab3,30,30);
//if the reset point is reached then move crab in the other direction
if(Reset3 == 1)
{
dbSprite(Crab3,400, Crab3Y,Crab);
Crab3Y=Crab3Y+Crab_speed+1;
if(Crab3Y==400)
{
Reset3 = 0;
}
}
else if(Reset3 == 0)
{
dbSprite(Crab3,400,Crab3Y,Crab);
Crab3Y=Crab3Y-Crab_speed-1;
if(Crab3Y == 200)
{
Reset3 = 1;
}
}
}//end if
if ( dbEscapeKey ( ) )
{
break;
}// end if
debug(playerX,playerY);
//playerMovement(playerX,playerY,playerSpeed,currentDirection);
// here we make a call to update the contents of the screen
dbSync ( );
}
//DeleteMenu();
return;
}//end main function
void SetupScreen()
{
// Set up Game Screen
dbSyncOn ();
dbSyncRate (60);
dbSetWindowTitle("Nightmare Island");
dbSetDisplayMode(1000,690,0);
dbMaximizeWindow();
}//end function set up screen
void LoadImages(int &playerX,int &playerY)
{
// Set Transparency
dbSetImageColorKey ( 0, 0, 0 );
//Load the menu images
dbLoadImage("Menu\\Menu_Background.png", BACKGROUND);
dbLoadImage("Menu\\Play_Game_Up.png", PLAY_NORMAL);
dbLoadImage("Menu\\Play_Game_Down.png", PLAY_HOVER);
dbLoadImage("Menu\\Gallery_Up.png", GALLERY_NORMAL);
dbLoadImage("Menu\\Gallery_Down.png", GALLERY_HOVER);
dbLoadImage("Menu\\Credits_Up.png", CREDITS_NORMAL);
dbLoadImage("Menu\\Credits_Down.png", CREDITS_HOVER);
dbLoadImage("Menu\\Exit_Game_Up.png", EXIT_NORMAL);
dbLoadImage("Menu\\Exit_Game_Down.png", EXIT_HOVER);
dbLoadImage("Menu\\mouse.png", CURSOR);
dbLoadImage("Menu\\ExitScreen.png", EXIT);
//load the player image
dbLoadImage("Player\\Player.png",playerSprite);
//load the first screen sprites
dbLoadImage("FirstLevel\\Sign.png", Sign);
dbLoadImage("FirstLevel\\SignText.png", SignText);
dbLoadImage("FirstLevel\\Screen1.png", FirstScreen);
dbLoadImage("FirstLevel\\Item.png", Item);
dbLoadImage("FirstLevel\\Goal.png", Goal1);
dbLoadImage("FirstLevel\\Empty_Item.png", GotItem);
//Load beach 1 images
dbLoadImage("Beach1\\Crab.png", Crab);
dbLoadImage("Beach1\\Rocks.png", Rock);
dbLoadImage("Beach1\\Sand.png", Sand);
dbLoadImage("Beach1\\Water.png", Water);
//Load Beach 2 images
dbLoadImage("Beach2\\Fence1.png", Fence1);
dbLoadImage("Beach2\\Fence2.png", Fence2);
dbLoadImage("Beach2\\Fence3.png", Fence3);
dbLoadImage("Beach2\\Fence4.png", Fence4);
dbLoadImage("Beach2\\Fence5.png", Fence5);
dbLoadImage("Beach2\\Fence6.png", Fence6);
dbLoadImage("Beach2\\Fence7.png", Fence7);
dbLoadImage("Beach2\\Fence8.png", Fence8);
dbLoadImage("Beach2\\Fence9.png", Fence9);
dbLoadImage("Beach2\\Fence10.png", Fence10);
dbLoadImage("Beach2\\WetSand.png", WetSand);
dbLoadImage("Beach2\\PalmTree.png", PalmTree);
}//end function load Images
void LoadMenuSprites()
{
//Load the menu sprites
dbSprite(CURSOR, dbMouseX(), dbMouseY(), CURSOR);
dbSprite(BACKGROUND, 0, 0, BACKGROUND);
dbSprite(PLAY_NORMAL, 620, 200, PLAY_NORMAL);
dbSprite(GALLERY_NORMAL,620,320, GALLERY_NORMAL);
dbSprite(CREDITS_NORMAL,620,440, CREDITS_NORMAL);
dbSprite(EXIT_NORMAL,620,560, EXIT_NORMAL);
//dbHideSprite(CURSOR);
}//end function load menu sprites
void MainMenu()
{
// Draw the cursor at the current mouse position.
dbSprite(CURSOR, dbMouseX(), dbMouseY(), CURSOR);
if (dbSpriteCollision(CURSOR, PLAY_NORMAL))
{
// Mouse hovering, switch button image accordingly.
dbSetSpriteImage(PLAY_NORMAL, PLAY_HOVER);
if (dbMouseClick() == 1) // 1 means a left click.
{
// Button clicked, print a message.
dbText(10, 10, "You clicked the \"Play\" button.");
Menu = false;
StartScreen = true;
DeleteMenu();
dbPlaySound(BeachSound);
dbLoopSound(BeachSound);
dbCLS();
//TO BE REPLACED WITH CALLING THE RELEVANT FUNCTION
}//end if
}//end if
else
{
// Mouse not hovering, draw image normal.
dbSetSpriteImage(PLAY_NORMAL, PLAY_NORMAL);
}//end else
if (dbSpriteCollision(CURSOR, GALLERY_NORMAL))
{
// Mouse hovering, switch button image accordingly.
dbSetSpriteImage(GALLERY_NORMAL, GALLERY_HOVER);
if (dbMouseClick() == 1) // 1 means a left click.
{
// Button clicked, print a message.
dbText(10, 10, "You clicked the \"Gallery\" button.");
//TO BE REPLACED WITH CALLING THE RELEVANT FUNCTION
}//end if
}//end if
else
{
// Mouse not hovering, draw image normal.
dbSetSpriteImage(GALLERY_NORMAL, GALLERY_NORMAL);
}//end else
if (dbSpriteCollision(CURSOR, CREDITS_NORMAL))
{
// Mouse hovering, switch button image accordingly.
dbSetSpriteImage(CREDITS_NORMAL, CREDITS_HOVER);
if (dbMouseClick() == 1) // 1 means a left click.
{
// Button clicked, print a message.
dbText(10, 10, "You clicked the \"Credits\" button.");
//TO BE REPLACED WITH CALLING THE RELEVANT FUNCTION
}//end if
}//end if
else
{
// Mouse not hovering, draw image normal.
dbSetSpriteImage(CREDITS_NORMAL, CREDITS_NORMAL);
}//end else
if (dbSpriteCollision(CURSOR, EXIT_NORMAL))
{
// Mouse hovering, switch button image accordingly.
dbSetSpriteImage(EXIT_NORMAL, EXIT_HOVER);
if (dbMouseClick() == 1) // 1 means a left click.
{
DeleteMenu();
Menu = false;
dbCLS();
// Button clicked. Exit game.
dbSprite(EXIT, 10, 10, EXIT);
dbSync();
}//end if
}//end if
else
{
// Mouse not hovering, draw image normal.
dbSetSpriteImage(EXIT_NORMAL, EXIT_NORMAL);
}//end else
// update the screen
dbSync ( );
return;
}//end function MainMenu
void DeleteMenu()
{
//Delete menu sprites from memory
for(int count = 0; count < 10; count ++)
{
dbDeleteImage(count);
}
}//end function delete menu
void LoadStartScreenSprites(int &playerX,int &playerY)
{
// Load Player Sprite
dbCreateAnimatedSprite(playerSprite,"Player\\Player.png",4,4,playerSprite);
dbSprite(playerSprite,playerX,playerY,playerSprite);
//dbHideSprite(playerSprite);
//load screen 1 sprites
dbSprite(FirstScreen,0,0,FirstScreen);
dbSprite(Sign,500,300,Sign);
dbSizeSprite(Sign,30,30);
dbSprite(Goal1,150,30,Goal1);
}//end function load screen one sprites
void playerMovement(int &playerX, int &playerY, float playerSpeed, int ¤tDirection)
{
int walkAnimationSpeed = 150;
int OldplayerX = playerX;
int OldplayerY = playerY;
// Standard Movement
if(dbLeftKey() && dbDownKey() == 0 && dbUpKey() == 0)
{
if( currentDirection != 1)
{
dbSetSpriteFrame(playerSprite,5);
}
currentDirection = 1;
dbPlaySprite(playerSprite,5,8,walkAnimationSpeed);
playerX -= playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
if(dbRightKey() && dbDownKey() == 0 && dbUpKey() == 0)
{
if( currentDirection != 2)
{
dbSetSpriteFrame(playerSprite,9);
}
currentDirection = 2;
dbPlaySprite(playerSprite,9,12,walkAnimationSpeed);
playerX += playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
if(dbUpKey() && dbLeftKey() == 0 && dbRightKey() == 0)
{
if( currentDirection != 3)
{
dbSetSpriteFrame(playerSprite,13);
}
currentDirection = 3;
dbPlaySprite(playerSprite,13,16,walkAnimationSpeed);
playerY -= playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
if(dbDownKey() && dbLeftKey() == 0 && dbRightKey() == 0)
{
if( currentDirection != 4)
{
dbSetSpriteFrame(playerSprite,1);
}
currentDirection = 4;
dbPlaySprite(playerSprite,1,4,walkAnimationSpeed);
playerY += playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
// Diagonal Movement
if(dbLeftKey() && dbUpKey())
{
if( currentDirection != 5)
{
dbSetSpriteFrame(playerSprite,5);
}
currentDirection = 5;
dbPlaySprite(playerSprite,5,8,walkAnimationSpeed);
playerX -= playerSpeed;
playerY -= playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
if(dbRightKey() && dbUpKey())
{
if( currentDirection != 6)
{
dbSetSpriteFrame(playerSprite,9);
}
currentDirection = 6;
dbPlaySprite(playerSprite,9,12,walkAnimationSpeed);
playerX += playerSpeed;
playerY -= playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
if(dbLeftKey() && dbDownKey())
{
if( currentDirection != 7)
{
dbSetSpriteFrame(playerSprite,5);
}
currentDirection = 7;
dbPlaySprite(playerSprite,5,8,walkAnimationSpeed);
playerX -= playerSpeed;
playerY += playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
if(dbRightKey() && dbDownKey())
{
if( currentDirection != 8)
{
dbSetSpriteFrame(playerSprite,9);
}
currentDirection = 8;
dbPlaySprite(playerSprite,9,12,walkAnimationSpeed);
playerX += playerSpeed;
playerY += playerSpeed;
dbSprite(playerSprite,playerX,playerY,playerSprite);
}
/* //set sprite collision
if(dbSpriteCollision(playerSprite,0))
{
playerX = OldplayerX;
playerY = OldplayerY;
}
*/
// Check to prevent players leaving screen
if (playerX > 970)
{
dbPasteSprite(playerSprite,970,playerY);
playerX = 970;
}
if (playerX < 0)
{
dbPasteSprite(playerSprite,0,playerY);
playerX = 0;
}
if (playerY < 0)
{
dbPasteSprite(playerSprite,playerX,0);
playerY = 0;
}
if (playerY > 640)
{
dbPasteSprite(playerSprite,playerX,640);
playerY = 640;
}
// Teleport helps to debug
if(dbShiftKey() && dbMouseClick() == 1 && debugEnabled == true)
{
playerX = dbMouseX();
playerY = dbMouseY();
}
// Update screen position.
dbPasteSprite(playerSprite,playerX,playerY);
}//end function player movement
void debug(int &playerX,int &playerY)
{
if (debugEnabled == true)
{
// Debug Display
dbInk(dbRGB(255,0,0),1);
dbText(770,0,dbStr(dbScreenFPS()));
dbText(770,15,dbStr(dbScanCode()));
dbText(770,30,dbStr(playerX));
dbText(770,45,dbStr(playerY));
dbText(770,60,dbStr(dbMouseX()));
dbText(770,75,dbStr(dbMouseY()));
}//end if
}//end function debug
void PlayStartScreen(int &playerX, int &playerY, float playerSpeed, int ¤tDirection)
{
LoadStartScreenSprites(playerX,playerY);
playerMovement(playerX,playerY,playerSpeed,currentDirection);
if(dbSpriteHit(playerSprite,Sign))
{
dbPasteImage(SignText,10,10);
dbSync();
dbWaitKey();
}//end if
if(dbSpriteHit(playerSprite,Goal1))
{
Beach1 = true;
StartScreen = false;
playerX = 10;
playerY = 10;
dbSync();
dbWaitKey();
}//end if
if(Item1 == false)
{
dbSprite(Item,550,300,Item);
dbSizeSprite(Item,30,30);
}
if(Item1 == true)
{
dbSprite(GotItem,900,10,GotItem);
dbSizeSprite(GotItem,20,20);
}
if(dbSpriteHit(playerSprite,Item))
{
dbCenterText(500,400,"Collect the boss items! If you look at the top right you'll see items collected");
Item1 = true;
dbDeleteSprite(Item);
dbSync();
dbWaitKey();
}//end if
debug(playerX,playerY);
}//end function play start screen
void LoadBeach1Sprites(int &playerX,int &playerY)
{
// Load Player Sprite
dbCreateAnimatedSprite(playerSprite,"Player\\Player.png",4,4,playerSprite);
dbSprite(playerSprite,playerX,playerY,playerSprite);
//dbHideSprite(playerSprite);
//load screen 1 sprites
dbSprite(Sand,0,0,Sand);
dbSprite(Rock,150,150,Rock);
dbSizeSprite(Rock,150,90);
dbSprite(Rock2,430,150,Rock);
dbSizeSprite(Rock2,150,90);
dbSprite(Rock3,700,150,Rock);
dbSizeSprite(Rock3,150,90);
dbSprite(Goal2,900,30,Goal1);
}//end function load beach 1 sprites
void PlayBeach1(int &playerX, int &playerY, float playerSpeed, int ¤tDirection)
{
int OldplayerX = playerX;
int OldplayerY = playerY;
playerMovement(playerX,playerY,playerSpeed,currentDirection);
if(dbSpriteHit(playerSprite,Goal2))
{
Beach2 = true;
Beach1 = false;
playerX = 1;
playerY = 516;
dbSync();
dbWaitKey();
}//end if
if((dbSpriteHit(playerSprite,Rock))||(dbSpriteHit(playerSprite,Rock2))||(dbSpriteHit(playerSprite,Rock3)))
{
playerX = OldplayerX;
playerY = OldplayerY;
dbSync();
}//end if
if(BeachItem1 == false)
{
dbSprite(Item2,500,500,Item);
dbSizeSprite(Item2,30,30);
}
if(BeachItem1 == true)
{
dbSprite(GotBeachItem1,900,10,GotItem);
dbSizeSprite(GotBeachItem1,20,20);
}
if(dbSpriteHit(playerSprite,Item2))
{
BeachItem1 = true;
dbDeleteSprite(Item2);
dbSync();
}//end if
debug(playerX,playerY);
}//end function play beach 1
void LoadSounds()
{
dbLoadSound("Sounds\\beach3.wav",BeachSound);
dbSetSoundVolume(BeachSound,80);
dbLoadSound("Sounds\\rainforestambience.wav",JungleSound);
dbSetSoundVolume(JungleSound,80);
dbLoadSound("Sounds\\wind-cave.wav",CaveSound);
dbSetSoundVolume(CaveSound,50);
}//end function load sounds
void LoadBeach2Sprites(int &playerX,int &playerY)
{
// Load Player Sprite
dbCreateAnimatedSprite(playerSprite,"Player\\Player.png",4,4,playerSprite);
dbSprite(playerSprite,playerX,playerY,playerSprite);
//dbHideSprite(playerSprite);
//load screen 1 sprites
dbSprite(Sand2,0,0,Sand);
dbSprite(Fence1,0,490,Fence1);
dbHideSprite(Fence1);
dbSprite(Fence2,-100,590,Fence2);
dbHideSprite(Fence2);
dbSprite(Fence3,100,290,Fence3);
dbHideSprite(Fence3);
dbSprite(Fence4,200,390,Fence4);
dbHideSprite(Fence4);
dbSprite(Fence5,100,290,Fence5);
dbHideSprite(Fence5);
dbSprite(Fence6,200,390,Fence6);
dbHideSprite(Fence6);
dbSprite(Fence7,800,290,Fence7);
dbHideSprite(Fence7);
dbSprite(Fence8,500,390,Fence8);
dbHideSprite(Fence8);
dbSprite(Fence9,800,490,Fence9);
dbHideSprite(Fence9);
dbSprite(Fence10,500,590,Fence10);
dbHideSprite(Fence10);
dbSprite(Goal3,900,520,Goal1);
dbSprite(WetSand,200,290,WetSand);
dbSprite(PalmTree2,200,300,PalmTree);
dbSprite(PalmTree3,400,420,PalmTree);
dbSprite(PalmTree4,150,420,PalmTree);
}//end function load beach 2 sprites
void PlayBeach2(int &playerX, int &playerY, float playerSpeed, int ¤tDirection)
{
int OldplayerX = playerX;
int OldplayerY = playerY;
playerSpeed = 2;
LoadBeach2Sprites(playerX,playerY);
playerMovement(playerX,playerY,playerSpeed,currentDirection);
if((dbSpriteHit(playerSprite,Fence1))||(dbSpriteHit(playerSprite,Fence2))||(dbSpriteHit(playerSprite,Fence3))||(dbSpriteHit(playerSprite,Fence4))||(dbSpriteHit(playerSprite,Fence5))||(dbSpriteHit(playerSprite,Fence6))||(dbSpriteHit(playerSprite,Fence7))||(dbSpriteHit(playerSprite,Fence8))||(dbSpriteHit(playerSprite,Fence9))||(dbSpriteHit(playerSprite,Fence10)))
{
playerX = OldplayerX;
playerY = OldplayerY;
dbSync();
}//end if
if(dbSpriteHit(playerSprite,WetSand))
{
playerSpeed = playerSpeed-1.5;
dbSync();
}//end if
if(BeachItem2 == false)
{
dbSprite(Item3,545,500,Item);
dbSizeSprite(Item3,30,30);
}
dbSprite(PalmTree,500,420,PalmTree);
if(BeachItem2 == true)
{
dbSprite(GotBeachItem2,900,10,GotItem);
dbSizeSprite(GotBeachItem2,20,20);
}
if(dbSpriteHit(playerSprite,Item3))
{
BeachItem2 = true;
dbDeleteSprite(Item3);
dbSync();
}//end if
}//end function play beach 2