Im a new to C++ and Dark GDK and am creating a 2D Tile based Zelda like game, it is only for the purpose of improving my skills, but i have become stuck as when ever i add code to classes the compile won't run as it should, i know this means something is wrong with the code, but i just dont know how to fix it, ive been following a tuto on youtube, with the same layout but i just cant fix it, can any one help me fix my code. if you don't understand part of my code please ask and i will try to explain.
here is the Main.cpp and PlayerMain.Cpp + .h
Main.cpp
#include "darkGDK.h"
#include "PlayerMain.h"
#include "WorldMaps.h"
void DarkGDK (void)
{
dbSyncOn;
dbSyncRate(60);
dbDisableEscapeKey;
dbSetImageColorKey(255,0,255);
dbCreateAnimatedSprite(1,"PlayerAll.bmp",5,2,1);
dbSprite(1,300,300,1);
dbSetSpritePriority ( 1 , 2 );
int playerSpeed = 1;
dbLoadImage("grassWF.bmp",2);
dbLoadImage("GGUI.bmp",3);
dbLoadImage("WallTB.bmp",4);
dbLoadImage("Tree.bmp",6);
dbLoadImage("PHouse.bmp",7);
dbCreateAnimatedSprite(90,"Magic.bmp",7,1,90);
dbSetSpriteFrame(90,7);
dbSprite(2,0,0,2);
dbSprite(3,0,0,3);
dbSprite(4,0,0,4);
dbSprite(5,0,350,4);
dbSprite(6,400,200,6);
dbSprite(7,230,150,7);
//boolean hasHappened = false;
//if(hasHappened == false){
//update sprite here;
//hasHappened = true;
//}
dbLoadMusic("MainM.wav",1);
//dbSetSoundSpeed( 1 , 100 );
while (LoopGDK())
{
dbSprite(90,dbSpriteX(1),dbSpriteY(1)+5,90);
//dbPlaySound(1);
dbLoopMusic(1);
dbPlayMusic( 1 );
//dbSetSoundSpeed( 1 , 2000 );
//dbSetSoundVolume(1,1000);
dbSetSpritePriority ( 1 , 2 );
dbSetSpritePriority ( 3 , 2 );
dbSetSpritePriority ( 6 , 3 );
//dbPlaySprite(4,1,7,150);
if (dbKeyState(44) == 1)
{
dbPlaySprite(90,1,7,150);
}
else
{
dbSetSpriteFrame(90,1);
}
if(dbEscapeKey() == 1)
{
break;
}
dbSync();
}
return;
}
PlayerMain.cpp
#include "darkGDK.h"
#include "PlayerMain.h"
PlayerMain::PlayerMain(void)
{
}
PlayerMain::~PlayerMain(void)
{
}
int PlayerMain::movement()
{
void DarkGDK (void)
{
dbCreateAnimatedSprite(1,"PlayerAll.bmp",5,2,1);
dbSprite(1,300,300,1);
dbSetSpritePriority ( 1 , 2 );
int playerSpeed = 1;
while (LoopGDK())
{
dbSetSpritePriority ( 1 , 2 );
if(dbUpKey() == 1)
{
dbPlaySprite(1,4,5,100);
dbMoveSprite(1,playerSpeed);
if (dbSpriteCollision(1,4)||dbSpriteCollision(1,6)||dbSpriteCollision(1,7) == 1)
{
dbMoveSprite(1,-1);
}
}
if(dbDownKey() == 1)
{
dbPlaySprite(1,9,10,100);
dbMoveSprite(1,-playerSpeed);
if (dbSpriteCollision(1,5)||dbSpriteCollision(1,6)||dbSpriteCollision(1,7) == 1)
{
dbMoveSprite(1,1);
}
}
if(dbRightKey() == 1)
{
dbSprite(1,dbSpriteX(1) + playerSpeed,dbSpriteY(1),2);
//dbSprite(3,dbSpriteX(3) + 1, dbSpriteY(3))
dbPlaySprite(1,1,3,100);
if (dbSpriteCollision(1,7) == 1)
{
dbSprite(1,dbSpriteX(1) - 1,dbSpriteY(1),2);
}
}
if(dbLeftKey() == 1)
{
dbSprite(1,dbSpriteX(1) - playerSpeed,dbSpriteY(1),1);
dbPlaySprite(1,6,8,100);
if (dbSpriteCollision(1,7) == 1)
{
dbSprite(1,dbSpriteX(1) + 1,dbSpriteY(1),2);
}
}
if (dbKeyState(42) == 1)
{
playerSpeed = 2;
}
else
{
playerSpeed = 1;
}
return(0);
}
}
}
PlayerMain.h
#pragma once
class PlayerMain
{
public:
PlayerMain(void);
~PlayerMain(void);
int movement();
};
I hope you can help.
Life is like code, you write it and it happends.