7 Replies - 1555 Views - Last Post: 25 November 2009 - 07:01 PM Rate Topic: -----

#1 hawksprite  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 137
  • Joined: 11-September 09

Transfer Data

Posted 29 October 2009 - 02:08 PM

Hi, i am working on a FPS and i have the basics done ( Collision, gravity, guns, ammo,lives, level) But now i am on to Multiplayer and A Online Leveling system. So the question im asking is this, how do you transfer data to a remote location? Should the data be taken from a string and put into a text file? And also how do i send the file up while reading other files on the same server? I was trying to use FTP but i couldnt find any good (free) solutions, i dont have a budget so i cant afford to buy expensive solutions.


Current Game Source =
[code]
#include "DarkGDK.h"
#include "SC_Collision.h"
#include <ctime>
#include "Wininet.h"
//#include "aehandle.h"
int collide = 0;
int pause = 0;
float enemymove = 0.2;
int ammo = 700;
int random = rand();
int norm = 0;
int scopeon = 0;
int scoped = 0;
int nextshot = 0;
float world = 0;
int score = 0;
int gameover = 0;
int lives = 10;
int guntype = 0;
int J = 2;
int allloaded = 0;
int E = 0;
int level = 1;
int spawn2 = 0;
float statue = 300.0f;
int running = 1;
float fuel100 = 5.0f;
float fuel101 = 5.0f;
float fuel102 = 5.0f;
float fuel103 = 5.0f;
float fuel126 = 5.0f;
float fuel127 = 5.0f;
float fuel128 = 5.0f;
float fuel129 = 5.0f;
int allreadysetup = 0;
float fuel = 100.0f;
float flashbang = 0.5f;
int numSpheres = 5;
float radius = 7.0f;
float littleRadius = 2.0f;

int rtimer = 0;
int ran = 0;
int stimer = 10;
int vtimer = 0;
float wlevel = 0;
float gravity = -0.1f;
float slope = 0.5f;
int ground = 1;
int jumptimer = 0;

int syncmode = 60;
int view = 0;
int hide = 0;

//player movement vector
float vx = 0;
float vy = 0;
float vz = 0;

void userInput ( void );
void refreshammo ()
{
ammo = 700;
}
void makeLevel()
{
//dbLoadObject( "level.x",1 );
//SC_SetupComplexObject( 1,1,2 );
if (world == 11)
{

dbLoadObject ("build3.x",4922);
dbPositionObject (4922,100,5,100);
SC_SetupComplexObject ( 4922,1,2);
dbLoadObject ("build3.x",4923);
dbPositionObject (4923,600,5,100);
SC_SetupComplexObject ( 4923,1,2);
dbLoadObject ("build3.x",4924);
dbPositionObject (4924,1100,5,100);
SC_SetupComplexObject ( 4924,1,2);
dbLoadObject ("ctower.x",4925);
dbPositionObject (4925,600,100,100);
SC_SetupComplexObject ( 4925,1,2);
dbLoadObject ("bunker.x",4926);
dbPositionObject (4926,59,5,827);
SC_SetupComplexObject ( 4926,1,2);
dbLoadObject ("wtower.x",4927);
dbPositionObject (4927,636,5,658);
SC_SetupComplexObject ( 4927,1,2);
dbLoadObject ("wtower.x",4928);
dbPositionObject (4928,636,5,958);
SC_SetupComplexObject ( 4928,1,2);
dbLoadObject ("build1.x",4929);
dbPositionObject (4929,987,5,670);

SC_SetupObject ( 4929,1,2);

dbLoadObject ("build1.x",4930);
dbPositionObject (4930,1000,5,670);

SC_SetupObject ( 4930,1,2);

dbLoadObject ("build1.x",4931);
dbPositionObject (4931,987,5,700);

SC_SetupObject ( 4931,1,2);

dbMakeObjectBox ( 4933, 900,20,20);
dbPositionObject (4933,59,20,427);
dbLoadImage ( "cmmdmtal.bmp", 4933);
dbTextureObject ( 4933,4933);
SC_SetupObject ( 4933,1,2);
SC_UpdateObject ( 4933 );

dbMakeObjectBox ( 4934, 900,20,20);
dbPositionObject (4934,509,212,261);
dbLoadImage ( "fsbrik.bmp", 4934);
dbTextureObject ( 4934,4934);
SC_SetupObject ( 4934,1,2);
SC_UpdateObject ( 4934 );



}
if (world == 12)
{
dbLoadObject ("CASTLE1.x",4928);
dbPositionObject (4928,100,100,100);
dbRotateObject(4928,90,90,90);
dbScaleObject(4928,10000,10000,10000);
SC_SetupComplexObject ( 4928,1,2);
}
if (world == 0)
{
dbMakeObjectBox ( 456, 8,2,2);
dbPositionObject ( 456, 600,3,550);
SC_SetupObject (456,1,2);
dbHideObject ( 456 );
dbLoadObject ("H-MP5-Static.x",1234567);
dbPositionObject ( 1234567, 600,3,550);
dbScaleObject ( 1234567, 1000,1000,1000);
}
else
{
if (world == 11)
{
dbMakeObjectBox ( 456, 8,2,2);
dbPositionObject ( 456, 536,58,436);
SC_SetupObject (456,1,2);
dbHideObject ( 456 );
dbLoadObject ("H-MP5-Static.x",1234567);
dbPositionObject ( 1234567, 536,58,436);
dbScaleObject ( 1234567, 1000,1000,1000);
}
}

if (world == 0)
{
dbMakeObjectBox ( 457, 8,2,2);
dbPositionObject ( 457, 396,2,697);
SC_SetupObject (457,1,2);
dbHideObject ( 457 );
dbLoadObject ("H-AK47-Static.x",789789);
dbPositionObject ( 789789,396,2,697 );
dbScaleObject (789789,1000,1000,1000);
}
else
{
if (world == 11)
{
dbMakeObjectBox ( 457, 8,2,2);
dbPositionObject ( 457, 234,212,199);
SC_SetupObject (457,1,2);
dbHideObject ( 457 );
dbLoadObject ("H-AK47-Static.x",789789);
dbPositionObject ( 789789,234,212,199 );
dbScaleObject (789789,1000,1000,1000);
}
}

if (world == 0)
{
dbMakeObjectBox ( 458, 8,2,2);
dbPositionObject ( 458, 84,55,196);
SC_SetupObject (458,1,2);
dbHideObject(458);
dbLoadObject ("Atomiser.x", 567567);
dbPositionObject (567567,84,55,196);
dbScaleObject ( 567567, 80,20,20);
dbRotateObject ( 567567, -90,0,0);
dbSetObjectLight ( 567567, 0 );
}
else
{
if (world == 11)
{
dbMakeObjectBox ( 458, 8,2,2);
dbPositionObject ( 458, 293,22,783);
SC_SetupObject (458,1,2);
dbHideObject(458);
dbLoadObject ("Atomiser.x", 567567);
dbPositionObject (567567,293,22,783);
dbScaleObject ( 567567, 80,20,20);
dbRotateObject ( 567567, -90,0,0);
dbSetObjectLight ( 567567, 0 );
}
}


if (world == 0)
{
dbMakeObjectBox ( 459, 8,1,1);
dbPositionObject ( 459, 244,125,404);
SC_SetupObject (459,1,2);
dbHideObject(459);
dbLoadObject ("H-Enfield-Static.x", 5675671);
dbPositionObject (5675671,244,120,404);
dbScaleObject ( 5675671, 1000,1000,1000);
//dbRotateObject ( 5675671, -90,0,0);
}
else
{
if (world == 11)
{
dbMakeObjectBox ( 459, 8,1,1);
dbPositionObject ( 459, 513,752,60);
SC_SetupObject (459,1,2);
dbHideObject(459);
dbLoadObject ("H-Enfield-Static.x", 5675671);
dbPositionObject (5675671,513,752,60);
dbScaleObject ( 5675671, 1000,1000,1000);
//dbRotateObject ( 5675671, -90,0,0);
}
}

//dbLoadImage( "1.jpg",1 );
//dbTextureObject( 1,1 );

//add box and sphere to the level
//dbMakeObjectBox( 3,10,20,30 );
//dbPositionObject( 3,-80,30,30 );
//dbRotateObject( 3,(float)dbRnd(360),(float)dbRnd(360),(float)dbRnd(360) );
//SC_SetupObject( 3,1,2 );

//dbMakeObjectSphere( 4,30 );
//dbPositionObject( 4,80,30,30 );
//dbRotateObject( 4,(float)dbRnd(360),(float)dbRnd(360),(float)dbRnd(360) );
//SC_SetupObject( 4,1,1 );

//all level objects are group 1
}

void spawn()
{
if (spawn2 == 0)
{
if (world == 0)
{
dbPositionObject (2, 100, 700, 100);
}
else
{
if ( world == 11)
{
dbPositionObject (2, 600,1000,100);
}
}
spawn2 = 1;
}
else
{
if (spawn2 == 1)
{
dbPositionObject (2, 510, 300, 740 );
spawn2 = 2;
}
else
{
if (spawn2 == 2)
{
dbPositionObject (2,220,400,334);
spawn2 = 0;
}
else
{
if (spawn2 == 3)
{
dbPositionObject (2,510,1000,302);
spawn2 = 2;

}
}
}
}
}
void makePlayer()
{
refreshammo();
dbMakeObjectSphere( 2,radius*1.0f );
//dbLoadObject ("Bezerker.x", 2);
if (wlevel == 0)
{
dbPositionObject( 2,90,215,220 );
}
if (wlevel == 2 )
{
dbPositionObject ( 2, 434, 42, -517 );
}

dbColorObject (2, dbRGB ( 487,900,300));
SC_SetupObject( 2,0,1 );

spawn ();
if (allreadysetup == 0)
{
if (wlevel == 2 )
{
}
if (wlevel == 0 )
{
dbLoadObject ( "New Statue.x", 789 );
//dbLoadObject ( "ColZ.x", 7765 );
dbPositionObject ( 789, 500, 0, 400 );
dbRotateObject (789, -90, 0, 0);
SC_SetupComplexObject ( 789,1,2 );
//dbPositionObject ( 7765, 600,0,400 );
//dbRotateObject ( 7765, -90, 0, 0 );
//SC_SetupObject ( 7765, 1, 2 );


allreadysetup = allreadysetup + 1;
}

}





//player has no group
}
void makeEnemy129()
{
dbLoadObject("H-Alien Psionic-Static.x",895);
//dbColorObject (101, dbRGB (234, 345, 654));
//SC_SetupObject (101, 0, 1);
dbPositionObject (895,200,20,600);
dbScaleObject(895,200,400,200);

dbMakeObjectBox (129,3,9,3);
SC_SetupObject ( 129, 0 ,2 );
dbHideObject ( 129 );
dbPositionObject ( 129, 900,-2,600);
SC_UpdateObject( 129 );

}
void makeEnemy128()
{
dbLoadObject("H-Alien Psionic-Static.x",894);
//dbColorObject (101, dbRGB (234, 345, 654));
//SC_SetupObject (101, 0, 1);
dbPositionObject (894,200,20,600);
dbScaleObject(894,200,400,200);

dbMakeObjectBox (128,3,9,3);
SC_SetupObject ( 128, 0 ,2 );
dbHideObject ( 128 );
dbPositionObject (128,800,-2,600);
SC_UpdateObject( 128 );
}
void makeEnemy127()
{
dbLoadObject("H-Alien Psionic-Static.x",893);
//dbColorObject (101, dbRGB (234, 345, 654));
//SC_SetupObject (101, 0, 1);
dbPositionObject (893,200,20,600);
dbScaleObject(893,200,400,200);

dbMakeObjectBox (127,3,9,3);
SC_SetupObject ( 127, 0 ,2 );
dbHideObject ( 127 );
dbPositionObject (127,700,-2,600);
SC_UpdateObject( 127 );

}
void makeEnemy126()
{
dbLoadObject("H-Alien Psionic-Static.x",892);
//dbColorObject (101, dbRGB (234, 345, 654));
//SC_SetupObject (101, 0, 1);
dbPositionObject (892,200,20,600);
dbScaleObject(892,200,400,200);

dbMakeObjectBox (126,3,9,3);
SC_SetupObject ( 126, 0 ,2 );
dbHideObject ( 126 );
dbPositionObject (126,300,-2,600);
SC_UpdateObject( 126 );

}
void makeEnemy102()
{
dbLoadObject("H-Alien Psionic-Static.x",891);
//dbColorObject (101, dbRGB (234, 345, 654));
//SC_SetupObject (101, 0, 1);
dbPositionObject (891,200,20,600);
dbScaleObject(891,200,400,200);

dbMakeObjectBox (102,3,9,3);
SC_SetupObject ( 102, 0 ,2 );
dbHideObject ( 102 );
dbPositionObject (102,100,-3,600);
SC_UpdateObject( 102 );
}
void makeEnemy101()
{
dbLoadObject("H-Alien Psionic-Static.x",890);
//dbColorObject (101, dbRGB (234, 345, 654));
//SC_SetupObject (101, 0, 1);
dbPositionObject (890,200,20,600);
dbScaleObject(890,200,400,200);

dbMakeObjectBox (101,3,9,3);
dbPositionObject(101,200,-2,600);
SC_SetupObject ( 101, 0 ,2 );
dbHideObject ( 101 );
SC_UpdateObject( 101 );
}


void makeExtraSpheres( int num )
{
for( int i = 10; i < 10 + num; i++ )
{
dbMakeObjectSphere( i,littleRadius*2.0f );
dbPositionObject( i,(float)dbRnd(50)-25,(float)dbRnd(50)+100,(float)dbRnd(50)-25 );
dbColorObject( i,dbRgb(dbRnd(255),dbRnd(255),dbRnd(255)) );
SC_SetupObject( i,3,1 );
SC_AllowObjectScaling( i );
}

//extra spheres are group 3
}

void handleExtraSpheres( int num )
{
for( int i = 10; i < 10+num; i++ )
{
//move all the little spheres towards the player and slide them
float oldx = dbObjectPositionX(i);
float oldy = dbObjectPositionY(i);
float oldz = dbObjectPositionZ(i);
dbPointObject( i,dbObjectPositionX(2),dbObjectPositionY(2),dbObjectPositionZ(2) );
dbMoveObject( i,0.5 );
float x = dbObjectPositionX(i);
float y = dbObjectPositionY(i);
float z = dbObjectPositionZ(i);
//little spheres collide with all (0)
int collide = SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius, i );

if ( collide > 0 )
{
dbPositionObject( i, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
SC_UpdateObject( i );
}

//show/hide the extra spheres
if ( dbReturnKey() == 1 && rtimer < dbTimer() )
{
rtimer = dbTimer() + 300;
hide = 1 - hide;

if ( hide == 1 )
{
for( int i = 10; i < 10+num; i++ ) dbHideObject( i );
}
else
{
for( int i = 10; i < 10+num; i++ ) dbShowObject( i );
}
}
}

void movePlayer()
{
//rotate player with mouse
dbYRotateObject( 2,dbObjectAngleY(2) + dbMouseMoveX()/3.0f );
dbXRotateObject( 2,dbObjectAngleX(2) + dbMouseMoveY()/3.0f );

float oldx = dbObjectPositionX(2);
float oldy = dbObjectPositionY(2);
float oldz = dbObjectPositionZ(2);

//apply gravity, and user changes to movement
float angy = dbObjectAngleY(2);
vx = 0;
vz = 0;

//if player is jumping or falling then apply 'normal' gravity
//if not attempt to keep the player stuck to the floor
if ( vy == 0 && jumptimer == 0 ) vy = vy + 10*gravity;
else vy = vy + gravity;

if (dbKeyState(32) == 1 ) { vx = vx + dbCos(angy); vz = vz - dbSin(angy); }
if (dbKeyState(30) == 1 ) { vx = vx - dbCos(angy); vz = vz + dbSin(angy); }
if (dbKeyState(31) == 1 ) { vx = vx - dbSin(angy); vz = vz - dbCos(angy); }
if (dbKeyState(17) == 1 ) { vx = vx + dbSin(angy); vz = vz + dbCos(angy); }

//only jump if on ground, and a certain time after last jump
if ( ground == 1 )
{
if ( dbSpaceKey() == 1 && jumptimer == 0 )
{
vy = vy + 3.0f;
jumptimer = 20;
}
}

//this would be the player's final position without collision
float x = oldx + vx;
float y = oldy + vy;
float z = oldz + vz;

//first handle gravity - seperated from horizontal movement
//to achieve a more realistic effect
//Method: simple - cast a sphere vertically down, if it hits the level then
// position the object there (sticky collision) then move
// on to horizontal movement
// more complex - if we were to only use the simple method the player would be
// allowed to climb almost vertical slopes. Alternative is to
// get the normalY direction to work out how flat the gorund
// below the player is, 0-slope# is flatter, slope#-1 is steeper.
// if it's flat, use sticky collision, if it's steep slide the
// player down the slope. Changing slope# determines how steep the
// player can climb. NOTE: this also effects stairs.
int collide = SC_SphereCastGroup( 1, oldx,oldy,oldz, oldx,oldy+vy,oldz, radius,0 );

if ( collide > 0 )
{

if (collide == 456)
{
guntype = 2;
refreshammo();
}
if (collide == 457)
{
guntype = 1;
refreshammo();
}
if (collide == 458)
{
guntype = 0;
refreshammo();
}
if (collide == 459)
{
guntype = 3;
refreshammo();
}
//how flat is this ground
float ny = SC_GetCollisionNormalY();
if ( dbAbs(ny) > slope )
{
//FLAT, stick
oldy = SC_GetStaticCollisionY();
}
else
{
//STEEP, slide
x = x - oldx; z = z - oldz;
oldx = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
oldz = SC_GetCollisionSlideZ();
x = x + oldx; z = z + oldz;
}

//ny#<0 means the player has hit a ceiling rather than a floor

if ( ny > slope )
{
//only on ground if standing on flat ground
ground = 1;
vy = 0;
}
else
{
ground = 0;
//if player has hit a flat ceiling then stop vy# movement
if ( ny < -slope ) vy = gravity;
}
}
else
{
//nothing below player, not on ground, add vertical speed to player
oldy = oldy + vy;
ground = 0;
}

//jumptimer will decrease only when player is back on ground
//creates a pause between two successive jumps
if ( ground == 1 && jumptimer > 0 ) jumptimer--;

//handle horizontal movement as sliding
//player only collides with group 1 (level) objs and moves freely through others
collide = SC_SphereSlideGroup( 1, oldx,oldy,oldz, x,oldy,z, radius,0 );

if ( collide > 0 )
{
//if hit, reposition player, halt movement vector
x = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
z = SC_GetCollisionSlideZ();
vx = 0;
vz = 0;

//possible code for giving the player a jumping help up stairs...
//might be useful if slope# is set very high but stairs are still required
//dy = oldy - SC_GetStaticCollisionY()
//if ( dy < slope && dy > 0 && ground == 1 ) vy = 0.5;
}

//position the player
dbPositionObject( 2,x,oldy,z );
//dbRotateObject (2, 90,90,90);
SC_UpdateObject( 2 );
}

void positionCameraToObject( int obj, int thirdPerson)
{
dbPositionCamera( dbObjectPositionX(2) + 9,dbObjectPositionY(2),dbObjectPositionZ(2) );
dbRotateCamera( dbObjectAngleX(2),dbObjectAngleY(2),dbObjectAngleZ(2) );

if ( thirdPerson == 1 )
{
dbPitchCameraDown( 10 );
dbMoveCamera( -30 );
}


}
void aehandle ()
{







char* szKey = dbInKey ( );
//handle shooting
if ( strcmp ( szKey, "f" ) == 0)
{
if (ammo == 0)
{
dbText (300,300,"Your out of Ammo! Pick up a gun to get more!");
}
else
{
dbShowObject ( 11 );
ammo = ammo - 1;
//get our collision vector


float oldx = dbCameraPositionX();
float oldy = dbCameraPositionY();
float oldz = dbCameraPositionZ();
dbMoveCamera( 200 );
float x = dbCameraPositionX();
float y = dbCameraPositionY();
float z = dbCameraPositionZ();
dbMoveCamera( -200 );

collide = SC_RayCast( 0, oldx,oldy,oldz, x,y,z, 0 );

if ( collide > 0 )
{
//get the collision point
float newx = SC_GetStaticCollisionX();
float newy = SC_GetStaticCollisionY();
float newz = SC_GetStaticCollisionZ();
//get collision normal
float normx = SC_GetCollisionNormalX();
float normy = SC_GetCollisionNormalY();
float normz = SC_GetCollisionNormalZ();

//position and point a marker in the right direction
dbPositionObject( 501, newx + normx/100.0f, newy + normy/100.0f, newz + normz/100.0f );
dbPointObject( 501, newx + normx, newy + normy, newz + normz );

if (collide == 1)
{
dbHideObject ( 501 );
dbHideObject ( 503 );
}
else
{
dbShowObject( 501 );
dbShowObject ( 503 );
}
}
}

}



//enemy two

if (running == 1)
{
for (int s=1; s < 10; s++)
{
float oldx = dbObjectPositionX(101);
float oldy = dbObjectPositionY(101);
float oldz = dbObjectPositionZ(101);
dbPointObject( 101,dbObjectPositionX(J),dbObjectPositionY(J),dbObjectPositionZ(J) );
dbMoveObject (101, enemymove);
float x = dbObjectPositionX(101);
float y = dbObjectPositionY(101);
float z = dbObjectPositionZ(101);
//SC_UpdateObject (123);

int brittany= SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius, 101 );

if ( brittany > 0 )
{
if (world == 11)
{

}
else
{
dbPositionObject( 101, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
}
if ( brittany == 2)
{
fuel = fuel - 20;
fuel101 = 0.0f;

}
SC_UpdateObject( 101 );
}
}

if (collide == 101)
{
fuel101 = fuel101 - 5.0f;
collide = 0;
}
if (fuel101 == 0.0f)
{
makeEnemy101();
fuel101 = 5.0f;
score = score + 25;
}


//enemy three

if (running == 1)
{
for (int s=1; s < 10; s++)
{
float oldx = dbObjectPositionX(102);
float oldy = dbObjectPositionY(102);
float oldz = dbObjectPositionZ(102);
dbPointObject( 102,dbObjectPositionX(J),dbObjectPositionY(J),dbObjectPositionZ(J) );
dbMoveObject (102, enemymove);
float x = dbObjectPositionX(102);
float y = dbObjectPositionY(102);
float z = dbObjectPositionZ(102);
//SC_UpdateObject (123);

int brittany= SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius, 102 );

if ( brittany > 0 )
{
if (world == 11)
{

}
else
{
dbPositionObject( 102, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
}
if ( brittany == 2)
{
fuel = fuel - 20.0f;
fuel102 = 0.0f;

}
SC_UpdateObject( 102 );
}
}
if (collide == 102)
{
fuel102 = fuel102 - 5.0f;
collide = 0;
}
if (fuel102 == 0.0f)
{
makeEnemy102();
fuel102 = 5.0f;
score = score + 25;
}
//make enemy four

if (running == 1)
{
for (int s=1; s < 10; s++)
{
float oldx = dbObjectPositionX(126);
float oldy = dbObjectPositionY(126);
float oldz = dbObjectPositionZ(126);
dbPointObject( 126,dbObjectPositionX(J),dbObjectPositionY(J),dbObjectPositionZ(J) );
dbMoveObject (126, enemymove);
float x = dbObjectPositionX(126);
float y = dbObjectPositionY(126);
float z = dbObjectPositionZ(126);
//SC_UpdateObject (123);

int brittany= SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius, 126 );

if ( brittany > 0 )
{
if (world == 11)
{

}
else
{
dbPositionObject( 126, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
}
if ( brittany == 2)
{
fuel = fuel - 20.0f;
fuel126 = 0.0f;

}
SC_UpdateObject( 126 );
}
}
if (collide == 126)
{
fuel126 = fuel126 - 5.0f;
collide = 0;
}
if (fuel126 == 0.0f)
{
makeEnemy126();
fuel126 = 5.0f;
score = score + 25;
}
//make enemy five


if (running ==1)
{
for (int s=1; s < 10; s++)
{
float oldx = dbObjectPositionX(127);
float oldy = dbObjectPositionY(127);
float oldz = dbObjectPositionZ(127);
dbPointObject( 127,dbObjectPositionX(J),dbObjectPositionY(J),dbObjectPositionZ(J) );
dbMoveObject (127, enemymove);
float x = dbObjectPositionX(127);
float y = dbObjectPositionY(127);
float z = dbObjectPositionZ(127);
//SC_UpdateObject (123);

int brittany= SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius, 102 );

if ( brittany > 0 )
{
if (world == 11)
{

}
else
{
dbPositionObject( 102, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
}
if ( brittany == 2)
{
fuel = fuel - 20.0f;
fuel127 = 0.0f;

}
SC_UpdateObject( 127 );
}
}
if (collide == 127)
{
fuel127 = fuel127 - 5.0f;
collide = 0;
}
if (fuel127 == 0.0f)
{
makeEnemy127();
fuel127 = 5.0f;
score = score + 25;
}
//make enemy six

if(running ==1)
{
for (int s=1; s < 10; s++)
{
float oldx = dbObjectPositionX(128);
float oldy = dbObjectPositionY(128);
float oldz = dbObjectPositionZ(128);
dbPointObject( 128,dbObjectPositionX(J),dbObjectPositionY(J),dbObjectPositionZ(J) );
dbMoveObject (128, enemymove);
float x = dbObjectPositionX(128);
float y = dbObjectPositionY(128);
float z = dbObjectPositionZ(128);
//SC_UpdateObject (123);

int brittany= SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius, 128 );

if ( brittany > 0 )
{
if (world == 11)
{

}
&

Is This A Good Question/Topic? 0
  • +

Replies To: Transfer Data

#2 mastersmith98  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 22-December 08

Re: Transfer Data

Posted 29 October 2009 - 07:13 PM

I'm not familiar with networking at all, but one solution might be to check out winsock and transfer the data that way to a remote server.

Personally I would refine my code a bit before I started worrying about that though. It seems like all your code is in one cpp file, which will be a nightmare to organize and add anything new.
Was This Post Helpful? 0
  • +
  • -

#3 hawksprite  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 137
  • Joined: 11-September 09

Re: Transfer Data

Posted 30 October 2009 - 12:57 PM

View Postmastersmith98, on 29 Oct, 2009 - 06:13 PM, said:

I'm not familiar with networking at all, but one solution might be to check out winsock and transfer the data that way to a remote server.

Personally I would refine my code a bit before I started worrying about that though. It seems like all your code is in one cpp file, which will be a nightmare to organize and add anything new.


Thank you. Two things. First yes i have been working on cleaning up the code so it's more feasible to work with. Second i looked into winsock and it looks like it could do what i need it to, but i cant seem to figure out how to use it to transfer data. I have googled Tutorials and came up empty handed.
Was This Post Helpful? 0
  • +
  • -

#4 Aeternalis  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 291
  • Joined: 13-July 09

Re: Transfer Data

Posted 30 October 2009 - 02:20 PM

Your probably NOT going to like what I have to say.

If your still interested in reading on.. then sign this non-complaint form and realize that everything I say here is an opinion that I cannot be held accountable for..Signed? good..

Your going to want to start over.

there.. I said it. If your still interested in reading on..well, you get the idea.

Why you are going to want to start over:

The simple version:
You can't take a game that was developed as a single player game on a local PC or console, or whatever.. and magically change it into a multiplayer game by adding some code.

the more graphic version:
In a single player game, the game state and the way your game gets information about the world is all included on the local PC and is completely self reliant. The server IS your local machine. Now taking a game that is designed like that and changing it into a multiplayer network based game is akin to taking a living animal and removing it's brain, placing that brain in a jar of electolytic fluid providing a blood flow to it, and keeping it alive. Wait.. Im not done.. that's just the server side, You also need to provide a connection from the base of the brain and transmit those signals from it back to the body and reconnect it to the spinal cord. All while keeping the body(client) alive too.

It could get messy is an understatement. Now you don't HAVE to start over. I never said you HAVE to .. but considering the time and effort you are going to spend trying to do that.. it would be more efficient to redesign it from the ground up as a networked multiplayer game. You will also end up with a cleaner, better designed and coded game.

As far as transferring data to a server, if your talking about files- you can use any FTP software commonly available. If your talking about client server communication in a game.. you could take a look at the tutorial here for a C# chat server by psychcoder. It's a good start to understanding a client server application.

Aet
Was This Post Helpful? 0
  • +
  • -

#5 hawksprite  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 137
  • Joined: 11-September 09

Re: Transfer Data

Posted 31 October 2009 - 08:11 PM

View PostAeternalis, on 30 Oct, 2009 - 01:20 PM, said:

Your probably NOT going to like what I have to say.

If your still interested in reading on.. then sign this non-complaint form and realize that everything I say here is an opinion that I cannot be held accountable for..Signed? good..

Your going to want to start over.

there.. I said it. If your still interested in reading on..well, you get the idea.

Why you are going to want to start over:

The simple version:
You can't take a game that was developed as a single player game on a local PC or console, or whatever.. and magically change it into a multiplayer game by adding some code.

the more graphic version:
In a single player game, the game state and the way your game gets information about the world is all included on the local PC and is completely self reliant. The server IS your local machine. Now taking a game that is designed like that and changing it into a multiplayer network based game is akin to taking a living animal and removing it's brain, placing that brain in a jar of electolytic fluid providing a blood flow to it, and keeping it alive. Wait.. Im not done.. that's just the server side, You also need to provide a connection from the base of the brain and transmit those signals from it back to the body and reconnect it to the spinal cord. All while keeping the body(client) alive too.

It could get messy is an understatement. Now you don't HAVE to start over. I never said you HAVE to .. but considering the time and effort you are going to spend trying to do that.. it would be more efficient to redesign it from the ground up as a networked multiplayer game. You will also end up with a cleaner, better designed and coded game.

As far as transferring data to a server, if your talking about files- you can use any FTP software commonly available. If your talking about client server communication in a game.. you could take a look at the tutorial here for a C# chat server by psychcoder. It's a good start to understanding a client server application.

Aet


I read over your post and i thank you for responding. I re-wrote most of the code when i decided to clean it up (Put into separate files, get rid of the useless comments, etc.) The multiplayer functions i need are very simple. Allow me to explain.

The game reads a file from the server. The file contains three numbers X Y Z
Then the game positions a sprite in coordinates X Y Z.
It re-reads the File and Re-positions the Sprite.

The other client has a user move a sprite on screen, it then takes that sprites Positions X Y Z and puts them into the file that the other client reads.

And Vice-Verse, That's the main functionality i need. The majority of the game is Single player Story Drivern. But for certain sections i need Multiplayer Functionality.

Second thing. I was looking into FTP clients but couldnt find a good (free) one for C++.
I dont have much time now, but when i look into that C# tutorial i will edit this post with my opinon on it ( Thanks for the tutorial link)
Was This Post Helpful? 0
  • +
  • -

#6 Aeternalis  Icon User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 291
  • Joined: 13-July 09

Re: Transfer Data

Posted 02 November 2009 - 10:39 AM

Ok so you decide to keep a single player story line and only have a small multiplayer section. There are a couple things wrong with what you are suggesting to handle the multiplayer sprite moving.

In your model, the client is accessing files on a remote server in order to retrieve the sprite location information. If you intend to do it this way, your going to need some sort of signal between the clients that say.. "ok, the sprite location information has changed, its your turn to go look at it." Alternatively, you can check the timestamp in the fileinfo and compare that to what it was before, if it changed .. it's your turn.

One of the problems with this design model is there is nothing to prevent anyone from writing jibberish to the file. Say a glitch happens and a client writes z, y , x instead of x, y, z or even worse.. writes J, K 09805983984598349849i3934898 .... you get the picture.

In a client server model, the server can validate the data and work with the client until it has received a valid sprite location information. Without a server, your stuck with whatever the other client writes.. and no way to tell them that the data was bad.. or invalid in some way.

OK, second problem.. without a server controlling the game state, how does anyone know Which client the sprite information was supposed to be sent to..or read by? Assuming you have more than 2 people playing the game, you need a method to control the communication of the sprite info from one client to only one other client.. unless you intend broadcasting the move? and if that is the case.. Who answers the move?

As you can see.. the server code is a huge part of any multiplayer game. Even the small simple version you suggest. There are solutions that do not use a server.. but they are much more rare and more difficult to find information on how to implement them.

At the very least, you are going to want to write a server that is capable of passing information between the clients. The tutorial Link above for the chat server is a great start at that.

good luck!
Aet
Was This Post Helpful? 0
  • +
  • -

#7 hawksprite  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 137
  • Joined: 11-September 09

Re: Transfer Data

Posted 02 November 2009 - 03:47 PM

Thanks! I've looked over the C# Code and read your suggestion it's helped alot!
Was This Post Helpful? 0
  • +
  • -

#8 Flamingkat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-November 09

Re: Transfer Data

Posted 25 November 2009 - 07:01 PM

Although this may be a bump. but if your interested in learning how to send data over the internet, via files or message structures, etc for a game, maybe you should check out http://www.CelestialCoding.com
They have some pretty good internet examples. I think the admin built a easy networking class to send files or message structures. Quite a bit of resources and examples as well. Check it out.

This post has been edited by Flamingkat: 25 November 2009 - 07:02 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1