Jump to content
  • Advertisement
Sign in to follow this  
Satrio Haryo Prakoso

Rotary System in Java

This topic is 1916 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

i didn't know how to post video yet, so if you could spare your time to look the video i would be very gratefull, im in the middle of developing a game and i really want to have a rotary system like in the video the problem is i did'nt know how to make the camera follow the character and rotate like in the video. could you please help me with the programming or algorithm? i'm using eclipse for this development. Thank you for your time

 

the artwork is all complete the problem is int he game engine 

Edited by Satrio

Share this post


Link to post
Share on other sites
Advertisement

To do rotations, you are going to want to look at Java's Graphics2D class.

 

This stack overflow thread shows how to rotate and image with G2D: http://stackoverflow.com/questions/7517688/rotate-a-java-graphics2d-rectangle.

 

One simple way to simulate a camera pan is to just subtract actual X,Y values from the cameras X,Y values.

For example:

sprite's X position = 10

cameras X position = 5

subtract: 10 - 5 = 5

now draw the sprite at 5, rather than 10.

 

Another way is to just render everything like normal to an image, and then change the X and Y position and rotation of that image, and then render the new image to the screen. Depending on how big this image is, this could sacrifice some performance.

 

Can you post some of your graphics code?

Share this post


Link to post
Share on other sites

To do rotations, you are going to want to look at Java's Graphics2D class.

 

This stack overflow thread shows how to rotate and image with G2D: http://stackoverflow.com/questions/7517688/rotate-a-java-graphics2d-rectangle.

 

One simple way to simulate a camera pan is to just subtract actual X,Y values from the cameras X,Y values.

For example:

sprite's X position = 10

cameras X position = 5

subtract: 10 - 5 = 5

now draw the sprite at 5, rather than 10.

 

Another way is to just render everything like normal to an image, and then change the X and Y position and rotation of that image, and then render the new image to the screen. Depending on how big this image is, this could sacrifice some performance.

 

Can you post some of your graphics code?

thanks it realy helped me now i know how to rotate graphics, i know about how the drawing the sprite works, but how do i aply an collision detection on a circle object? sorry if i burden you. i will post my graphics code a few days again its not in my computer in the moment 

Share this post


Link to post
Share on other sites

 

To do rotations, you are going to want to look at Java's Graphics2D class.

 

This stack overflow thread shows how to rotate and image with G2D: http://stackoverflow.com/questions/7517688/rotate-a-java-graphics2d-rectangle.

 

One simple way to simulate a camera pan is to just subtract actual X,Y values from the cameras X,Y values.

For example:

sprite's X position = 10

cameras X position = 5

subtract: 10 - 5 = 5

now draw the sprite at 5, rather than 10.

 

Another way is to just render everything like normal to an image, and then change the X and Y position and rotation of that image, and then render the new image to the screen. Depending on how big this image is, this could sacrifice some performance.

 

Can you post some of your graphics code?

thanks it realy helped me now i know how to rotate graphics, i know about how the drawing the sprite works, but how do i aply an collision detection on a circle object? sorry if i burden you. i will post my graphics code a few days again its not in my computer in the moment 

 

 

the easiest way to detect collission between two circles is to compare the square of the distance between them with the square of the sum of their radii.

 

bool circleTest(float x1, float y1, float radius1, float x2, float y2, float radius2) {
    float dx = x2 - x1;
    float dy = y2 - y1;
    float radii = radius1 + radius2;
    if ( ( dx * dx ) + ( dy * dy ) < radii * radii ) {
        return true;
    } else {
        return false;
    }
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!