Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

107 Neutral

About lifesuxtr

  • Rank

Personal Information

  • Interests
  1. after one input of movement there is like 0.2 position difference between but after more input difference increases
  2. I am trying to use box2d on nodejs server with libGDX client.What i am trying to apply is authoritative server modal so clients are just sending input data to server, server is running simulation and returning data to clients. Client sends right key pressed input data to server,server calculates applyForce vector, applies force to server side body. Server is sending worlds body data to clients such as linearVelocity,position angular velocity etc with `sendWorldData()` function.After geting data clients equalize this data to client side bodies. Right now i just equalize linear velocity data,if i use setTransform on body for same position, it breaks the simulation and game crashes.I guess just linear velocity is way to go for now. The problem is even though i return the same linearvelocity from server to client,bodies end up on slightly different x,y positions. client is (6.8612046,7.3647866) server is (7.260152142360204,7.807573379341183) I read a lot about this problem and started by trying to fix timestep on server and client. Client timestep: private var fixedTimestepAccumulator = 0f private var MAX_ACCUMULATED_TIME = 1.0f val TIMESTEP = 1 / 60f fun update(delta:Float){ fixedTimestepAccumulator += delta; if(fixedTimestepAccumulator > MAX_ACCUMULATED_TIME) fixedTimestepAccumulator = MAX_ACCUMULATED_TIME; while (fixedTimestepAccumulator >= TIMESTEP) { world.step(TIMESTEP, 6, 2); fixedTimestepAccumulator -= TIMESTEP; } inputUpdate(delta) cameraUpdate(delta) tmr.setView(camera) batch.projectionMatrix.set(camera.combined) } Server update method: var lastUpdate = Date.now()/1000; var fixedTimestepAccumulator = 0; var MAX_ACCUMULATED_TIME = 1; var TIMESTEP = 1/60; function physics_hanlder() { var now = Date.now() / 1000; var delta = now - lastUpdate; lastUpdate = now; fixedTimestepAccumulator = fixedTimestepAccumulator+delta; if(fixedTimestepAccumulator > MAX_ACCUMULATED_TIME) fixedTimestepAccumulator = MAX_ACCUMULATED_TIME; while (fixedTimestepAccumulator >= TIMESTEP) { world.step(TIMESTEP,6,2); sendWorldData() // sends servers body data to clients fixedTimestepAccumulator -= TIMESTEP; } } setInterval(physics_hanlder, 1000/60);
  3. Hi guys working on a login system on a 2d rpg game. Basically we have a state manager,menu state,login state etc... im trying to add JButton and JTextbox to one of this states but i couldnt do that. First this is display class import java.awt.Canvas; import java.awt.Dimension; import javax.swing.JFrame; public class Display {    private JFrame frame;    private Canvas canvas;        private String title;    private int width,height;        public Display(String title,int width,int height){       this.title = title;       this.width=width;       this.height=height;       createDisplay();          }    private void createDisplay(){       frame = new JFrame(title);       frame.setSize(width, height);       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setResizable(false);       frame.setLocationRelativeTo(null);       frame.setVisible(true);       canvas = new Canvas();//initilize.       canvas.setPreferredSize(new Dimension(width,height));       canvas.setMaximumSize(new Dimension(width,height));       canvas.setMinimumSize(new Dimension(width,height));       canvas.setFocusable(false);///!!! key calissin diyee.focusla ilgili.       frame.add(canvas);       frame.pack();    }    public Canvas getCanvas(){ //getter       return canvas;    }    public JFrame getFrame(){       return frame;    }         } This is the login state.I want to add Jbutton and textbox to this state. import java.awt.Graphics; public class LoginState extends State {    private UIManager uiManager;    public LoginState(final Handler handler) {       super(handler);       uiManager = new UIManager(handler);       uiManager.addObject(new UIImageButton(200, 200, 400, 64, Assets.btn_start, new ClickListener() {           @Override          public void onClick() {             handler.getMouseManager().setUIManager(uiManager);             State.setState(handler.getGame().gameState);          }       }));    }        public void tick() {       uiManager.tick();       handler.getMouseManager().setUIManager(uiManager);       State.setState(handler.getGame().LoginState);          }    @Override    public void render(Graphics g) {       uiManager.render(g);    }     } I can add UIImage button which is just a buttonclass with a picture etc butI want to add JButton and Jtextbox to the state for a login register system.i tryed display.getcanvas.add(button) like that but its not working and actually i wonder how people add JButton or Jtextfields to their game states ?  
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!