- Joined
- Dec 21, 2016
- Messages
- 98 (0.03/day)
- Location
- A dusty server room
System Name | HP DL380 G5 |
---|---|
Processor | 2x Intel Xeon X5460 @3.16 Ghz |
Motherboard | HP DL 380 |
Cooling | 6 60mm intake fans rated for 14k RPM max load |
Memory | 16GB of DDR2 667Mhz |
Video Card(s) | AMD XFX R7 360 |
Storage | 3x 140GB 10K SAS JBOD |
Display(s) | 1x Hisense 42" TV |
Case | DL 380 G5 |
Audio Device(s) | HDMI Out |
Power Supply | 2x 800w Proprietary PSUs |
Mouse | A cheap logitech wireless mouse |
Keyboard | Acer KU-0355 |
Software | Windows 10! |
Benchmark Scores | Ill get around to em soon |
Hey guys, I've been designing a 2D, CLI-based space MMO ( sort of like EVE, meant to give the shit your brains experience as Aurora 4x/Dwarf fortress for those who know what that is) and I've been trying to figure out what are the best datatypes to store object position on a "massive scale" universe?
I use trigonometry to move the ships along a path towards the intended destination. But in doing so, I tend to have really large decimals and even if I round, I lose precision, and the objects
You'd expect in the perfect world that these ships would just snap to their nearest intended coordinate while moving there (without a decimal) and the world is happy and maybe I could store these values as longs instead of doubles.
My attachment
Here I send the battleship at coordinate (0,0) to coordinate (100,50) and takes a straight slope path to get there(trig), but yields this awful result. Sending the other ships to coordinate 100,50 results in numbers that round to (101, 51)
However, I wish for the grid to always snap to the nearest whole number.
Thanks ~ Sal
I use trigonometry to move the ships along a path towards the intended destination. But in doing so, I tend to have really large decimals and even if I round, I lose precision, and the objects
You'd expect in the perfect world that these ships would just snap to their nearest intended coordinate while moving there (without a decimal) and the world is happy and maybe I could store these values as longs instead of doubles.
My attachment
Java:
public class ShipPhysics {
//THIS CLASS GETS CALLED EVERY FRAME, THIS TELLS ALL SHIPS TO UPDATE THEIR PHYSICS IN CASE OF DESTINATION CHANGE!
public static void updateMovement(){
for(int i = 0; i < lists.ships.size(); i++){
ship s = lists.ships.get(i);
double gotoX = s.getDestinationX();
double gotoY = s.getDestinationY();
double speed = s.getSpeed();
double dx;
double dy;
double dir;
dy = Math.abs(gotoY - s.getYPos());
dx = Math.abs(gotoX - s.getXPos());
dir = Math.atan(dy/dx);
//System.out.println(i + " x: " + dx + " y: " + dy + " slope: " + slope);
if(gotoX != s.getXPos() || gotoY != s.getYPos() ){
if(gotoX < s.getXPos()){
s.setXpos(s.getXPos() - (speed * Math.cos(dir)));
}
if(gotoX > s.getXPos()){
s.setXpos(s.getXPos() + (speed * Math.cos(dir)));
}
if(gotoY < s.getYPos()){
s.setYpos(s.getYPos() - (speed * Math.sin(dir)));
}
if(gotoY > s.getYPos()){
s.setYpos(s.getYPos() + (speed * Math.sin(dir)));
}
}
}
}
}
However, I wish for the grid to always snap to the nearest whole number.
Thanks ~ Sal
Last edited: