void Show_Crystal(void)
{
if (player_state == PLAYER_STATE_SLEEP)
{
//check for collision with playarea crystals
for (int i=0; i<COLS; i++)
{
for (int j=0; j<ROWS; j++)
{
if(playarea[i][j].state == PLAYAREA_STATE_OFF)
{
//query each cell
for(int index=0; index<MAX_CRYSTALS; index++)
{
if( (crystal[index].x == playarea[i][j].x) && (crystal[index].y == playarea[i][j].y) )
{
//crystal[index].state = CRYSTAL_STATE_OFF;
Destroy_BOB(&crystal[index]);
Show_BOB(&playarea[i][j]);
//playarea[j].state = PLAYAREA_STATE_ON;
</font>
}
}<font color="gray">//end for
</font>
}<font color="gray">//end if
</font>
}<font color="gray">//end for
</font>
}<font color="gray">//end for
</font>
<font color="gray">//player_state = PLAYER_STATE_ALIVE;
</font>
<font color="gray">//Clone_Next_Crystal();
</font>
}<font color="gray">//end if
</font>
}<font color="gray">//end show_crystal
</font>
</pre></DIV><!–ENDSCRIPT–>
if this line>
>>> Show_BOB(&playarea<i>[j]);
is not present,
>>> Destroy_BOB(&crystal[index]);
occurs as expected and clone bob disappears.
if both lines are present, the playarea
shows the correct bobs in place of clone bob.
but if this line>
>>> crystal[index].state = CRYSTAL_STATE_OFF;
is added, togther with
>>> Destroy_BOB(&crystal[index]);
>>> Show_BOB(&playarea[j]);
the playarea''s bobs din "SHOW"
and if this line>
>>> playarea[j].state = PLAYAREA_STATE_ON;
is added togther with
>>> Destroy_BOB(&crystal[index]);
>>> Show_BOB(&playarea[j]);
the clone bob "flies up".
next i kinda assume that this line>
>>> crystal[index].state = CRYSTAL_STATE_OFF;
is not needed as the clone would be destroyed
anyway.
but this line is needed>
>>> playarea[j].state = PLAYAREA_STATE_ON;
as which bobs in the playarea are actualli
"SHOWN". </i>
werid conceptual problem
okie, still makin the tetris clonie..
there is somethin that i dun understand...
if u can explain it, i will be very much appreciated.
ok,this code deals with the aftermath of colliding tetris blocks, that is, what happens after a block hits another block.
i got a 2d array hidden in the playarea.
everytime collision occurs,the clone bob
is destroyed, and the playarea''s bobs
which are under the clone bob, will "SHOW".
ok i just found out that from the collision code,
the clone flies up is because of crystal[0].y -= 30; blah blah
void Crystal_Collision(void) {//check collision with crystals for (int i=0; i<COLS; i++) { for (int j=0; j<ROWS; j++) { if(playarea[i][j].state == PLAYAREA_STATE_ON) { for(int index=0; index<MAX_CRYSTALS; index++) { if(Collision_Test(crystal[index].x, crystal[index].y, crystal[index].width, crystal[index].height, playarea[i][j].x, playarea[i][j].y, playarea[i][j].width, playarea[i][j].height)) { crystal[0].y -= 30; crystal[1].y -= 30; crystal[2].y -= 30; crystal[3].y -= 30; player_state = PLAYER_STATE_SLEEP; } //end if } //end for }// end if }//end for }//end for}//end crystal_collision
the clone flies up is because of crystal[0].y -= 30; blah blah
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement