## JTG2003's Profile User Rating:

Reputation: 0 Apprentice
Group:
Active Members
Active Posts:
51 (0.04 per day)
Joined:
29-February 12
Profile Views:
363
Last Active:
Sep 29 2013 05:58 PM
Currently:
Offline

### Previous Fields

Dream Kudos:
0
JTG2003 has not set their status

1. #### In Topic: Integer and Double Arithmatic

Posted 29 Sep 2013

pbl, on 29 September 2013 - 05:47 PM, said:

That is why you should never compare double with the == operator
calculations can produce
x = 15.0000000000000001
and
y = 14.9999999999999999

both will be considered as != even if, in certain contexts, equal

Well in the code I accidentally posted, I used Math.floor(double)!=int which I think is working correctly..
2. #### In Topic: Integer and Double Arithmatic

Posted 29 Sep 2013

Hm, didn't mean to post that last post there. Was halfway through creating it (realized the code didn't really make sense as is) when I figured out a part of my problem.. but I somehow posted it anyways and didn't realize until it was too late to edit it.

3. #### In Topic: Integer and Double Arithmatic

Posted 29 Sep 2013

Hmm, ok. I've been working on this one part for a couple nights now and I can't seem to properly wrap my head around it. This is what I have:

```private class moveThread extends Thread
{
Entity ent;
int URN,endX,endY,movingX,movingY,dX,dY,delay;
boolean change = false;

public smoothMoveThread(int URN, int[] newCoords, int delay)
{
System.out.println("New smoothMoveThread. URN :" + URN + " X: " + newCoords[0] + " Y: " + newCoords[1] + " Delay: " + delay);
this.URN = URN;
ent = getEntityByURN(URN);

endX = newCoords[0];
endY = newCoords[1];
movingX = ent.getX();
movingY = ent.getY();
dX = endX - movingX;
dY = endY - movingY;

this.delay = delay;

double dXd = (double)dX/delay;
double dYd = (double)dY/delay;

System.out.println("Delay: "+ delay + " dX: " + dX + " dX/delay: " + (double)dX/delay + " dY: " + dY + " dY/delay: " + (double)dY/delay);

}

public void run()
{

for(int i=0;i<10;i++)
{
System.out.println("i: "+i);
double newX = movingX + (((double)dX / delay) *i);
double newY = movingY + (((double)dY / delay) *i);
System.out.println("Dec X: " + newX + " Dec Y: " + newY);

if(Math.floor(newX)!=movingX)
{
movingX = (int) Math.floor(newX);
System.out.println("Moved X updated to " + movingX);
change = true;
}
if(Math.floor(newY)!=movingY)
{
movingY = (int) Math.floor(newY);
System.out.println("Moved Y updated to " + movingY);
change = true;
}
if(change)
{
System.out.println("Updating coords");
getEntityByURN(URN).setCoords(movingX,movingY);
// Possibly trigger redraw here?
change=false;
}
}
}
}

```
4. #### In Topic: Networked Player Movement - Restricting Messages + Interpolation

Posted 6 Sep 2013

BBeck, on 06 September 2013 - 02:09 PM, said:

Is it 2D or 3D?

2D Top-Down 8 directions

BBeck, on 06 September 2013 - 02:09 PM, said:

In my mind, the server always must know the current state of the game <...> anything that actually changes the state of the game world has to be recorded on the server.

Right. I'm just worried about sending too much to the server.

BBeck, on 06 September 2013 - 02:09 PM, said:

You could basically hit the "rewind" button on certain things display wise.

I think this is getting a little beyond what I'm going for. I'm OK with someone jumping around if they have severe lag. I might look into smoothing this later, but for now the main two goals are

1) You must see your own player moving in real-time. If you lag out, yeah you might jump back a bit when the server needs to correct you, but this should not be a regular occurrence.
2) You must see other player moving smoothly. They will have a built in lag for the interpolation so their position will be 100-200ms behind their actual server-side position, but it will ensure a smooth display. Again, lag spikes aside.
5. #### In Topic: Networked Player Movement - Client/Server out of Sync

Posted 27 Aug 2013

Oh jeez, there it is...
```            int dX = 0;
int dY = 0;
waiting(10);
switch(ent.getMoveDirection())

```

Was there the whole time. I'm an idiot. I'm also triple posting because it doesn't let me edit that last post anymore, but I figured it's better to throw one more post on before people try to help.

Member Title:
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

E-mail:
Private

### Friends

JTG2003 hasn't added any friends yet.