How do I pass a string to a function, I tried the most obvious way but it doesn't compile
#include "DarkGDK.h"
void CalculateShooting();
void CalculateMovement(char sCharX, char sCharY, char sCharZ, float fX, float fY, float fZ);
void DarkGDK() {
dbSyncOn();
//dbSetDisplayMode (800, 600, 16);
dbMakeObjectCube(1, 10.0);
dbMakeObjectCube(2, 1.0);
dbHideObject(2);
// dbMoveCamera(-50);
float fX = dbObjectPositionX(1);
float fY;
float fZ;
dbPositionObject(1, fX, -125.0, 200.0);
char sX[255];
char sY[255];
char sZ[255];
while (!dbEscapeKey()) {
CalculateMovement(sX, sY, sZ, fX, fY, fZ);
CalculateShooting();
dbSync();
}
}
void CalculateShooting() {
// void at the moment until I figure out the movement function
}
void CalculateMovement(char sCharX, char sCharY, char sCharZ, float fX, float fY, float fZ) {
if (dbLeftKey()) {
dbMoveObjectLeft(1, 2.0);
}
else if (dbRightKey()) {
dbMoveObjectRight(1, 2.0);
}
else if (dbUpKey()) {
dbMoveObjectUp(1, 2.0);
}
else if (dbDownKey()) {
dbMoveObjectDown(1, 2.0);
}
fX = dbObjectPositionX(1);
fY = dbObjectPositionY(1);
fZ = dbObjectPositionZ(1);
sprintf(sChaX, "%f", fX);
sprintf(sCharY, "%f", fY);
sprintf(sCharZ, "%f", fZ);
dbText(10.0, 10.0, sCharX);
dbText(10.0, 20.0, sCharY);
dbText(10.0, 30.0, sCharZ);
}
Sorry for being such a noob, i'm trying really hard.
- Scarface