void Rotate_Crystal(void)
{
if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 0) )
{
Set_Animation_BOB(&crystal_L, 0);
crystal_L.curr_frame = 1;
}
if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 1) )
{
Set_Animation_BOB(&crystal_L, 1);
crystal_L.curr_frame = 2;
}
}
Rotate only one time
okie, still in tetris clonie.
i got a problem with rotation>
how do u limit the rotation to only one time?
here, everytime control is pressed, the block animates from
1st frame to 3rd frame.
my code>
Use an else statement ...
if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 0)
...
else if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 1) )
...
if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 0)
...
else if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 1) )
...
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
If you notice in your code, the two procedures will execute together if the first if statement evaluates to true.
This is because if your first if statement evaluates to true, then curr_frame is set to equal 1, which is what is required for the second if procedure to evaluate to true.
Therefore anytime the control key is down and the curr_frame is equal to 0, both of the following will execute:
Hope this helps.
------
Shop for the Lowest Price!
Then, Check a Reseller''s Rating Before You Purchase!
This is because if your first if statement evaluates to true, then curr_frame is set to equal 1, which is what is required for the second if procedure to evaluate to true.
Therefore anytime the control key is down and the curr_frame is equal to 0, both of the following will execute:
void Rotate_Crystal(void){ if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 0) ) { Set_Animation_BOB(&crystal_L, 0); // sets curr_frame equal to 1, which is what is required // for next if statement to evaluate to true crystal_L.curr_frame = 1; } if( (KEY_DOWN(VK_CONTROL)) && (crystal_L.curr_frame == 1) ) { Set_Animation_BOB(&crystal_L, 1); crystal_L.curr_frame = 2; }}
Hope this helps.
------
Shop for the Lowest Price!
Then, Check a Reseller''s Rating Before You Purchase!
------Shop for the Lowest Price!Then, Check a Reseller's Rating Before You Purchase!
but for this case oso doesnt seem to work,
it stills starts from 1st frame to 3rd frame.
[edited by - edwinnie on April 24, 2002 6:08:23 AM]
[edited by - edwinnie on April 24, 2002 6:09:07 AM]
it stills starts from 1st frame to 3rd frame.
void Rotate_Crystal(void){ if (KEY_DOWN(VK_CONTROL)){ if (crystal[0].counter_1 == CRYSTAL_L) { if(crystal[0].counter_2 == ROTATE_1) { crystal[2].x = crystal[0].x +30; //translation crystal[2].y = crystal[0].y; Set_Pos_BOB(&crystal[2], crystal[2].x, crystal[2].y ); crystal[3].x = crystal[0].x +60; crystal[3].y = crystal[0].y; Set_Pos_BOB(&crystal[3], crystal[3].x, crystal[3].y); crystal[0].counter_2 = ROTATE_2; } else if(crystal[0].counter_2 == ROTATE_2) { crystal[0].x = crystal[3].x; crystal[0].y = crystal[3].y + 30; Set_Pos_BOB(&crystal[0], crystal[0].x, crystal[0].y); crystal[1].x = crystal[3].x; crystal[1].y = crystal[3].y + 60; Set_Pos_BOB(&crystal[1], crystal[1].x, crystal[1].y); crystal[0].counter_2 = ROTATE_3; } }//end if }//end if}// end rotate_crystal
[edited by - edwinnie on April 24, 2002 6:08:23 AM]
[edited by - edwinnie on April 24, 2002 6:09:07 AM]
Two things:
1. Are you sure that you know what your frames look like? Have you written some debugging code that rotates the objects through their entire animation sequence?
2. How often is RotateCrystal called? Are you getting into this function twice with each key press, or could you be calling this function twice each update?
1. Are you sure that you know what your frames look like? Have you written some debugging code that rotates the objects through their entire animation sequence?
2. How often is RotateCrystal called? Are you getting into this function twice with each key press, or could you be calling this function twice each update?
oh btw, i changed the code if u observe.
there r no animation sequences.
now there is just a shift of coordinates, and repositioning.
the next frame of rotation is correct, i checked 1st b4.
i tried putting a modified one in game_init, and only the
KEY_DOWN(VK_CONTROL) in game_main.
still din work.
the problem is the counter_2, but i am not sure where to put it.
this counter_2 helps to check which rotation to perform.
btw, i couldnt think of any code that can put a more "general"
type of rotation. here the rotation is specific(coordinates shifting). which could be the problem oso.
[edited by - edwinnie on April 24, 2002 9:13:30 AM]
there r no animation sequences.
now there is just a shift of coordinates, and repositioning.
the next frame of rotation is correct, i checked 1st b4.
i tried putting a modified one in game_init, and only the
KEY_DOWN(VK_CONTROL) in game_main.
still din work.
the problem is the counter_2, but i am not sure where to put it.
this counter_2 helps to check which rotation to perform.
btw, i couldnt think of any code that can put a more "general"
type of rotation. here the rotation is specific(coordinates shifting). which could be the problem oso.
[edited by - edwinnie on April 24, 2002 9:13:30 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement