Sign in to follow this  

java - 360 degree movement example

This topic is 1118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, could anyone be able to make a simple example for me how to implement 360 degree movement in swing?

http://screenshot.cz/8MVTG/

-as you can see at the picture, I'd like to make the same direction of a shape. Is it possible without any framework/engine? thanks.

//or at least, it shouldnt be a full example, just chunk of code. Thanks.

Share this post


Link to post
Share on other sites

You have an object and you want to be able to move it in any direction?

 

It could be usefull if you already have some code, this could be achieved in many ways.

 

The most straight forward approach I can think of is having a facing direction or angle as an object's property that's affected by 2 steering keys, and one move key that moves the object in the facing direction only. Something like a car or a space ship.

 

Another approach could be setting the facing direction to an analog joystick input and moving in that direction as long as the stick is not at the center. Something like Zelda games.

 

And another could be setting the facing direction from the object to a certaing point in the world (a point where you clicked with the mouse) and make the object move at a constant speed until it reaches the point. Something like Diablo games.

Edited by DiegoSLTS

Share this post


Link to post
Share on other sites

This topic is 1118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this