Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualBrother Bob

Posted 22 July 2013 - 12:19 PM

For the old 2D art games to implement this there would be sprites for all possible directions. For instance, if you move to the right, the current ship picture would be swapped with a picture of a ship facing right.  If the ship moved up, the character would be swapped with a picture of a ship facing up. 

You have some decisions to make now.  Since you are using a flat plane and pasting the image of a ship on to it, you are technically using the old 2D art style.  Unless your ship is mirrored along it's length, the same way a rocket is, then you are going to have some problems.  If you rotate around the z-axis then your ship will be upside down when you change between left and right, at least for one direction anyways.  If you rotate about the 'y'-axis to change from left to right, you will have to make sure back-face culling is off so it won't be invisible when it's backwards.  Also by this method, the ship will appear to shrink, then disappear, then grow back to it's original size if you have a transition between left and right. This would look the same as if you have a picture of a ship drawn on two sides of a piece of paper, then you hold it in front of your face and rotate it. 

This is more suited to 3D models but would work for a stylized 2D game as well, for instance, "Super Paper Mario"

 

To start off with, you might want to just come up with some hard-coded directions.  If the ship is naturally facing right at the start, then ship angle would be 0.0 when it is flying right.  Now to face left, assuming back-face culling is disabled, the ship angle angle would be 180 along the 'Y' axis.  glRotatef(180.0, 0.0, 1.0, 0.0); 

If you want a smooth transition between these two values you can use key-frame blending  http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter06.html

 

blendedPosition = (1.0 - weight) * keyFrameA + weight * keyFrameB;

 

In your case, it would look something like the following...

 

currentRotation = (1.0 - time) * rotationStart + time * rotationFinish

 

The first component grows smaller as time goes from 0.0 to 1.0 , The second component grows larger as time goes from 0.0 to 1.0

 

CurrentRotation will start off as 0.0, if it was facing right, then increment every frame all the way to 180.0, and it will be facing left.

This will become substantially more complex when characters are continuously changing direction part way through the interpolation, now you'd have to save currentRotation and use this as the new rotationStart, then restart 'time' at zero.

 

You should post how you would like to proceed.


#4marcClintDion

Posted 22 July 2013 - 03:11 AM

There is far too much arrogance and out right abuse by site moderators, they are teaching other people to behave this way.  The posts I've made will all be shorty removed and replaced with this notice.  Game development is not the only thing being taught here, bad behavior is being taught as well.


#3marcClintDion

Posted 22 July 2013 - 03:10 AM

There is far too much arrogance and out right abuse by site moderators, they are teaching other people to behave this way.  The posts I've made will all be shorty removed and replaced with this notice.  Game development is not the only thing being taught here, bad behavior is being taught as well.


#2marcClintDion

Posted 23 June 2013 - 12:17 AM

For the old 2D art games to implement this there would be sprites for all possible directions.   For instance, if you move to the right, the current ship picture would be swapped with a picture of a ship facing right.  If the ship moved up, the character would be swapped with a picture of a ship facing up. 

You have some decisions to make now.  Since you are using a flat plane and pasting the image of a ship on to it, you are technically using the old 2D art style.  Unless your ship is mirrored along it's length, the same way a rocket is, then you are going to have some problems.  If you rotate around the z-axis then your ship will be upside down when you change between left and right, at least for one direction anyways.  If you rotate about the 'y'-axis to change from left to right, you will have to make sure back-face culling is off so it won't be invisible when it's backwards.  Also by this method, the ship will appear to shrink, then disappear, then grow back to it's original size if you have a transition between left and right.   This would look the same as if you have a picture of a ship drawn on two sides of a piece of paper, then you hold it in front of your face and rotate it. 

This is more suited to 3D models but would work for a stylized 2D game as well, for instance, "Super Paper Mario"

 

To start off with, you might want to just come up with some hard-coded directions.  If the ship is naturally facing right at the start, then ship angle would be 0.0 when it is flying right.  Now to face left, assuming back-face culling is disabled, the ship angle angle would be 180 along the 'Y' axis.  glRotatef(180.0, 0.0, 1.0, 0.0); 

If you want a smooth transition between these two values you can use key-frame blending  http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter06.html

 

blendedPosition = (1.0 - weight) * keyFrameA + weight * keyFrameB;

 

In your case, it would look something like the following...

 

currentRotation = (1.0 - time) * rotationStart + time * rotationFinish

 

The first component grows smaller as time goes from 0.0 to 1.0 , The second component grows larger as time goes from 0.0 to 1.0

 

CurrentRotation will start off as 0.0, if it was facing right, then increment every frame all the way to 180.0, and it will be facing left.

This will become substantially more complex when characters are continuously changing direction part way through the interpolation, now you'd have to save currentRotation and use this as the new rotationStart, then restart 'time' at zero.

 

You should post how you would like to proceed.


#1marcClintDion

Posted 23 June 2013 - 12:17 AM

For the old 2D art games to implement this there would be sprites for all possible directions.   For instance, if you move to the right, the current ship picture would be swapped with a picture of a ship facing right.  If the ship moved up, the character would be swapped with a picture of a ship facing up. 

You have some decisions to make now.  Since you are using a flat plane and pasting the image of a ship on to it, you are technically using the old 2D art style.  Unless your ship is mirrored along it's length, the same way a rocket is, then you are going to have some problems.  If you rotate around the z-axis then your ship will be upside down when you change between left and right, at least for one direction anyways.  If you rotate about the 'y'-axis to change from left to right, you will have to make sure back-face culling is off so it won't be invisible when it's backwards.  Also by this method, the ship will appear to shrink, then disappear, then grow back to it's original size if you have a transition between left and right.   This would look the same as if you have a picture of a ship drawn on two sides of a piece of paper, then you hold it in front of your face and rotate it. 

This is more suited to 3D models but would work for a stylized 2D game as well, for instance, "Super Paper Mario",

 

To start off with, you might want to just come up with some hard-coded directions.  If the ship is naturally facing right at the start, then ship angle would be 0.0 when it is flying right.  Now to face left, assuming back-face culling is disabled, the ship angle angle would be 180 along the 'Y' axis.  glRotatef(180.0, 0.0, 1.0, 0.0); 

If you want a smooth transition between these two values you can use key-frame blending  http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter06.html

 

blendedPosition = (1.0 - weight) * keyFrameA + weight * keyFrameB;

 

In your case, it would look something like the following...

 

currentRotation = (1.0 - time) * rotationStart + time * rotationFinish

 

The first component grows smaller as time goes from 0.0 to 1.0 , The second component grows larger as time goes from 0.0 to 1.0

 

CurrentRotation will start off as 0.0, if it was facing right, then increment every frame all the way to 180.0, and it will be facing left.

This will become substantially more complex when characters are continuously changing direction part way through the interpolation, now you'd have to save currentRotation and use this as the new rotationStart, then restart 'time' at zero.

 

You should post how you would like to proceed.


PARTNERS