Tag Info

Hot answers tagged

2

You probably have object leaks. Objects that are still referenced somewhere in an array or list, creating more and more objects for the garbage collector to process as the game advances. Or more and more AI objects that are off-screen but still active and processing on every frames.


1

I suggest moving the target slowly rather than the angle. Try this: Vector2 Target; // Interp is a value between 0 and 1. When 0, the target never moves. // When 1, the target moves instantaneously. Intermediate values cause the target // to move at different rates. void UpdateTarget(float interp) { Target = interp * Mouse.Position + (1 - interp) * ...


1

I think any linear function would be fine for this. You can keep two variables one for your spaceship's current angle spaceshipAngle = Math.PI*k, and one for the current angle that the user inputs with his cursor cursorAngle = Math.PI*p. And what you do is if (Math.Abs(Math.PI*k, Math.PI*p) < Math.PI) { if (Math.PI*k < Math.PI*p) k += ...


1

You could update the position over time: currentPos = currentPos + Math.signum(currentPos - touchedPos) * wayPerTime * deltaTime; wayPerTimestep is your velocity. deltaTime is the time passed since the last update. currentPos is the current position of your player (might be x, y or both as vector). touchedPos is the position the player has clicked on the ...


1

You can use InputAdapter class and methods touchDown(int screenX, int screenY, int pointer, int button) Called when the screen was touched or a mouse button was pressed. boolean touchDragged(int screenX, int screenY, int pointer) Called when a finger or the mouse was dragged. boolean touchUp(int screenX, int screenY, int pointer, int button) Called when a ...


1

I guess the reason why you were choosing this architecture was to keep the computation costs and computation effort low on the server, allowing it to be lightweight. (Another advantage of this approach is that the usually low upstream of the clients are relieved by a server acting as a broadcasting intermediator.) Of course the downfall is that it now ...


1

OpenGL performance will outperform Swing quite heavily once you start doing something a little more advanced. I dont have hard numbers to back my claim, but I have experience. I too started out with pure Java2D, with BufferStrategy and the works. And it was ok for Pong, Snake, Tetris, and so on. But once venturing beyond in graphical effects (blending, ...


1

In this line ball.applyLinearImpulse(new Vector2(0f, 5000f), ball.getPosition(), true); I think the point where you put force it relative to object position, so you put impule in ball.getPosition() + ball.getPosition() Try to use public void applyForceToCenter(Vector2 force, boolean wake) or ball.applyLinearImpulse(new Vector2(0f, 5000f), new ...



Only top voted, non community-wiki answers of a minimum length are eligible