316
Projects / Re: Robombs
« on: September 22, 2008, 09:42:45 am »
Nice game, glad to see you finally got it finally out. I was just going to ask about the sources, wouldn't mind seeing how you did a few things
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
News: New forum version (1.1.4)
In my unfinished and buggy project FLierMatch, the server manages the position and direccion of a spaceship and for each movement it transfer it to each client and each client upgrades the position and direction of the ship inside the client game.Thats what I did first. But caused a lot of warp back.
guessPos.translate(clientX, y, clientZ);
guessPos.rotateY(rotation);
SimpleVector a = guessPos.getZAxis();
a.scalarMul(xSpeed);
guessPos.translate(a);
charObj.translate(x, y, z);
charObj.rotateY(rotation);
final SimpleVector charPos = charObj.getTranslation();
a = guessPos.getTranslation();
newPos.translate(x, y, z);
float ang = (float) ((float) Math.atan2(x - a.x, z - a.z) +Math.PI);
newPos.rotateY(ang);
//System.out.println("ang: " + ang + " x: " + x + " a.x:" + a.x + " z: " + z + " a.z: " + a.z);
clientX = a.x;
clientZ = a.z;
a = newPos.getZAxis();
a.scalarMul(xSpeed);
a = MapLocation.get().checkCollision(charPos, a);
charObj.translate(a);
a = charObj.getTranslation();
x = a.x;
y = a.y;
z = a.z;
public static float calcAngle(SimpleVector s1, SimpleVector s2) {
SimpleVector s1n = s1.normalize();
SimpleVector s2n = s2.normalize();
float pa=s1n.x*s2n.x+s1n.y*s2n.y+s1n.z*s2n.z;
// Inaccuracies may cause NaN...fix this:
if (pa<-1) {
pa=-1;
}
if (pa>1) {
pa=1;
}
pa=(float) Math.acos(pa);
return pa;
}
float differenceAngle = oldrotation - rotation; //has the player turned since last cycle.
final Object3D guessPos = new Object3D(0), charObj = new Object3D(0), newPos = new Object3D(0);
guessPos.translate(clientX, y, clientZ);
guessPos.rotateY(calcAngle(new SimpleVector(oldClientX,y,oldClientZ),new SimpleVector(clientX,y,clientZ)) + differenceAngle);
charObj.translate(x, y, z);
charObj.rotateY(rotation);
final SimpleVector charPos = charObj.getTranslation();
SimpleVector a = guessPos.getZAxis();
a.scalarMul(xSpeed);
newPos.translate(x, y, z);
newPos.rotateY(calcAngle(new SimpleVector(charPos.x,charPos.y,charPos.z),new SimpleVector(a.x,a.y,a.z)));
clientX = a.x;
clientZ = a.y;
clientRotation = a.z;
a = newPos.getZAxis();
a.scalarMul(xSpeed);
a = m.getWorld().checkCollisionEllipsoid(charPos, a, Zone.ELLIPSOID_RADIUS, 2);
charObj.translate(a);
a = charObj.getTranslation();
x = a.x;
y = a.y;
z = a.z;
oldClientX = clientX;
oldClientZ = clientZ;
oldClientRotation = clientRotation;
oldrotation = rotation;