Jump to content
  • Advertisement
Sign in to follow this  
butchi

java - 360 degree movement example

This topic is 1281 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
Advertisement

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
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!