Jump to content

  • Log In with Google      Sign In   
  • Create Account

gareth_mcdaid

Member Since 22 May 2007
Offline Last Active May 18 2014 06:38 PM

Posts I've Made

In Topic: My Online RPG - Update #3

13 December 2013 - 12:13 AM

Random thoughts.
4 connected clients each running at a different FPS, each with different ping/pong times, requires Frame rate independent movement
Using the elapsed time between frames to update the position , 1000/60 elapsed time = 16.6.

One method is reading keyboard input detecting directional changes, recording a time stamp and position for each directional change, this information is sent back to the server on average once every 200 milliseconds.

The sever as a tick rate of say 5 ticks for each second of time.
 
The server and client can use a buffer of previous player positions to achieve movement interpolation, this approach can’t be used for PVP in real time as there is no prediction ahead of time for the new player  positions.

Projectiles can have predetermined behaviour using a sine wave generator, the client sends a player shoot packet back to the server, included is the position, angle and a time stamp, the server positions each projectile based of it’s elapsed time from being alive, With this information the server checks to see the bullet isn’t being positioned elsewhere and proceeds to send all connected clients the ally shoot packet.
 


In Topic: How many pictures calculator

08 May 2009 - 04:40 AM

#include <iostream>
#include <time.h>
#include <stdio.h>


using namespace std;

FILE *output_log = NULL;

const int numofbits=2;
int current_pos=numofbits;

const char target_num=122,start_num=97;
char bits[numofbits];
char result_bits[numofbits];
clock_t ticks1;


int string_length(char* string1)
{
int len=0;
while (1)
{
if (*string1==0)
{
break;
}
string1+=1;
len+=1;
}
return len;
}


void init_bits()
{
int i=0;
for(i=0; i<=numofbits; i+=1)
{
bits[i]=start_num;
result_bits[i]=target_num;
}
output_log=fopen("c:\\output_log.txt","w");
}

void running()
{
int i=0,found=0,total_count=0;
double clock_count=0;
//char string1[1];

while (1==1)
{
clock_count+=1;
if (clock_count>10000000)
{
//ticks1=clock();
total_count+=1;
cout << total_count << endl;
clock_count=0;
}

for(i=0; i<=numofbits; i+=1)
{
char a;
//sprintf(string1,"%d",bits[i]);
//fprintf(output_log,string1);
a=bits[i];
fprintf(output_log, &a );
}
fprintf(output_log,"\n");



found=1;
for(i=0; i<=numofbits; i+=1)
{
if (bits[i] != result_bits[i])
{
found=0;
break;
}

}

if (found==1)
{
break;
}

//cout << current_pos << endl;
bits[current_pos]+=1;

if ( bits[current_pos] >target_num)
{
bits[current_pos]=start_num;
current_pos-=1;

for (i=current_pos; i>=0; i-=1)
{
bits[i]+=1;
if (bits[i]>target_num)
{
bits[i]=start_num;
}
else
{
current_pos=numofbits;
break;
}
}

}

}
}


int main()
{
init_bits();
//cout << "Hello world!" << endl;
running();
fclose(output_log);
return 0;
}

PARTNERS