   noob code, no idea where going wrong, dx8/9
  Ok basically this is the code for a very simple dx8/9 breakout clone, very simple as in all the collisions are 90 degrees etc, just a small starter project.I posted on the forum earlier to get an idea about how to clear up the bricks once a collision had occured. Now i cant even get them to disappear and was wondering if some of you fine people could go into debug mode in your heads and just point out where i''m going wrong. And yes i know my code is a little bit of a mess...sorry.Here goes:void GameMain(){ //Keyboard and device stateUCHAR keystate[256];m_keyboard->GetDeviceState(sizeof(UCHAR[256]),(LPVOID)&keystate);   switch(game_state)   { case GAME_STATE_TITLE_SCREEN: {    DisplayTitle(); game_state = GAME_STATE_TITLE_SCREEN;  if (keystate[DIK_SPACE] & 0x80){game_state = GAME_STATE_GAME_INIT;} } break;  case GAME_STATE_GAME_INIT:  {game_score = 0; bats_left = 3; DisplayScore(); //Setup ball ballx = -4; bally = -4;  for (int bg = 0; bg<32; bg++){green_blocks[bg] = true;}for (int bb = 0; bb<32; bb++){blue_blocks[bb] = true;}for (int br = 0; br<32; br++){red_blocks[br] = true;}// Initialize all to ''true'' to indicate the blocks are not destroyedDisplaySquare();game_state = GAME_STATE_GAME_RUN; } break;  case GAME_STATE_GAME_RUN:  { //Bat collision //check locations  Update_Ball();  DisplaySquare();//is bally at baty if (bally <= -11.5) { if ((ballx > (batx + 1)) || (ballx < (batx -1))) {//life lost    bats_left -= 1;  // subtract one from bats//if no bats left, game over, go to End Screen.if (bats_left < 1){game_state = GAME_STATE_END_SCREEN;}//ball resetballx = -4;bally = -4; } else {speeddiry = -speeddiry;   } }   //bat did hit ball - hurray  //Ball & Block collision//idea use bally vs blocky just like for bat, then ballx vs blocksxbool hit_one = false;//check when ball in green,blue and red zone, y co-ordsif ((bally > 4.0) && (bally < 8.0)) //if ball in bounds check x{//check when ball in green, blue and red zone x co-ordsif ((ballx <= 16.0) && (ballx >= -16.0)) //if ball in bounds check further{//Start code for collision mechanism//Green blocksif ((bally > 4.0) && (bally < 5.0)){int floater1 = (ballx * 1000);int i = ((floater1 / 1000)  + 16);if ((i >= 0) && (i < 32)){if (green_blocks == true){green_blocks = false;hit_one = true;speeddiry = -speeddiry;}else{speeddiry = speeddiry;}}}else if ((bally > 5.0) && (bally < 6.0)){int floater2 = (ballx * 1000);int j = ((floater2 / 1000) + 16);if ((j >= 0) && (j < 32)){if (blue_blocks[j] == true){blue_blocks[j] = false;hit_one = true;speeddiry = -speeddiry;}else{speeddiry = speeddiry;}}}else if ((bally > 6.0) && (ballx < 7.0)){int floater3 = (ballx * 1000);int l = ((floater3 / 1000) + 16);if ((l >= 0) && (l < 32)){if (red_blocks[l] == true){red_blocks[l] = false;hit_one = true;speeddiry = -speeddiry;}else{speeddiry = speeddiry;}}}else if ((bally >= 7.0) && (ballx < 8.0)){int floater4 = (ballx * 1000);int m = ((floater4 / 1000) + 16);if ((m >= 0) && (m < 32)){if (red_blocks[m] == true){red_blocks[m] = false;hit_one = true;speeddiry = -speeddiry;}else{speeddiry = speeddiry;}}}}}    DisplaySquare();    //Move Bat if (keystate[DIK_LEFT] & 0x80)if (batx > -20){batx-=0.07f;batx-=0.07f;batx-=0.07f;//for speed}    if (keystate[DIK_RIGHT] & 0x80)   if (batx < 20) {batx+=0.07f;batx+=0.07f;batx+=0.07f; } if (keystate[DIK_ESCAPE] & 0x80) {    PostQuitMessage(0); } //if (blocks_hit > 95)//{//game_state = GAME_STATE_GAME_RESET;   //}   if (keystate[DIK_P] & 0x80) {    game_state = GAME_STATE_GAME_PAUSE; }  }  break;  case GAME_STATE_GAME_RESET: {  //may need to redraw here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1    game_score += 500;    DisplayScore();    game_state = GAME_STATE_GAME_INIT; }   break;  case GAME_STATE_GAME_PAUSE:  {if (keystate[DIK_SPACE] & 0x80){game_state = GAME_STATE_GAME_RUN;} }   break;  case GAME_STATE_WIN_SCREEN:  {  DisplayVictory();   //SET STUFF UP HERE!!!! game_state = GAME_STATE_WIN_SCREEN; if (keystate[DIK_SPACE] & 0x80){game_state = GAME_STATE_TITLE_SCREEN;}  } break;  case GAME_STATE_END_SCREEN:  {  DisplayEnd();   //SET STUFF UP HERE!!!! game_state = GAME_STATE_END_SCREEN;  if (keystate[DIK_SPACE] & 0x80){game_state = GAME_STATE_TITLE_SCREEN;}  }  break;   }}</pre>Also the main display code that keeps being called.<pre>void DisplaySquare(void){   D3DXMATRIX matWorld; //First line simply blankets the screen with a colour of our choice  D3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );   D3DDevice->BeginScene();//lets device know we are about to begin renderingD3DDevice->SetVertexShader(D3D8T_CUSTOMVERTEX);D3DDevice->SetStreamSource(0,D3DVertexBuffer,sizeof(batvertex));D3DXMatrixTranslation(&matWorld,0.0f,0.0f,-35.0f);//***********************************************************************//**The following line controls teh location on the screen of bat//*****************************************************************D3DXMatrixTranslation(&matWorld,batx,baty,0.0f);D3DDevice->SetTransform( D3DTS_WORLD, &matWorld );D3DDevice->SetTexture(0,D3DTextureBat1); //Incorporate the textureD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2); //***********************************************************************//**The following line controls teh location on the screen of ball//*****************************************************************D3DXMatrixTranslation(&matWorld,ballx,bally,0.0f);D3DDevice->SetTransform( D3DTS_WORLD, &matWorld );D3DDevice->SetTexture(0,D3DTextureBall); //Incorporate the textureD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2); //Red Blocksfor (int i = 0; i<32;i=i++){if (red_blocks = true){D3DXMatrixTranslation(&matWorld,-16.0 + i ,+7.0f,0.0f);D3DDevice->SetTransform( D3DTS_WORLD, &matWorld );D3DDevice->SetTexture(0,D3DTextureRBrick); //Incorporate the textureD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2); }}//Blue Blocksfor (int k = 0; k<32;k=k++)   {if (blue_blocks[k] = true){D3DXMatrixTranslation(&matWorld,-16.0 + k ,+6.0f,0.0f);D3DDevice->SetTransform( D3DTS_WORLD, &matWorld );D3DDevice->SetTexture(0,D3DTextureBBrick); //Incorporate the textureD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2); }}// Render the block only if it''s not destroyedfor (int l = 0; l<32;l++)   {if (green_blocks[l] = true){D3DXMatrixTranslation(&matWorld,-16.0 + l ,+5.0f,0.0f);D3DDevice->SetTransform( D3DTS_WORLD, &matWorld );D3DDevice->SetTexture(0,D3DTextureGBrick); //Incorporate the textureD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2); }}D3DDevice->EndScene();//Lets device know rendering has finished.    D3DDevice->SetTexture(0,NULL);//Switch the texture "off"    //The next line of code flips the contents of the back buffer to the screen.   D3DDevice->Present( NULL, NULL, NULL, NULL );//Show what we have drawn}</pre>Also i''m trying to create a simple score card for the top right of the screen,obviously this doesnt work and i havent put in any of the code for it yet, but i would like a suggestion on how to get something as simple as "Score = 100" on the screen, because all my normal c sprintf and all that doesnt work a jot in direct3d.  </i>  </pre> 
  i''m really going to have to learn how to format these posts properly... ;  [ source ] /*code*/ and [ /source ] without the spaces   Sharp Basic - Coming summer 2004!Sign Up For Sharp Basic Beta Testing!!!;  ok lets try again /*void GameMain(){ //Keyboard and device stateUCHAR keystate[256];m_keyboard->GetDeviceState(sizeof(UCHAR[256]),(LPVOID)&keystate);   switch(game_state)   { case GAME_STATE_TITLE_SCREEN: {    DisplayTitle(); game_state = GAME_STATE_TITLE_SCREEN;  if (keystate[DIK_SPACE] & 0x80){game_state = GAME_STATE_GAME_INIT;} } break;  case GAME_STATE_GAME_INIT:  {game_score = 0; bats_left = 3; DisplayScore(); //Setup ball ballx = -4; bally = -4;  for (int bg = 0; bg<32; bg++){green_blocks[bg] = true;}for (int bb = 0; bb<32; bb++){blue_blocks[bb] = true;}for (int br = 0; br<32; br++){red_blocks[br] = true;}// Initialize all to ''true'' to indicate the blocks are not destroyedDisplaySquare();game_state = GAME_STATE_GAME_RUN; } break;  case GAME_STATE_GAME_RUN:  { //Bat collision //check locations  Update_Ball();  DisplaySquare();//is bally at baty if (bally <= -11.5) { if ((ballx > (batx + 1)) || (ballx < (batx -1))) {//life lost    bats_left -= 1;  // subtract one from bats//if no bats left, game over, go to End Screen.if (bats_left < 1){game_state = GAME_STATE_END_SCREEN;}//ball resetballx = -4;bally = -4; } else {speeddiry = -speeddiry;   } }   //bat did hit ball - hurray  //Ball & Block collision//idea use bally vs blocky just like for bat, then ballx vs blocksxbool hit_one = false;//check when ball in green,blue and red zone, y co-ordsif ((bally > 4.0) && (bally < 8.0)) //if ball in bounds check x{//check when ball in green, blue and red zone x co-ordsif ((ballx <= 16.0) && (ballx >= -16.0)) //if ball in bounds check further{//Start code for collision mechanism//Green blocksif ((bally > 4.0) && (bally < 5.0)){int floater1 = (ballx * 1000);int i = ((floater1 / 1000)  + 16);if ((i >= 0) && (i < 32)){if (green_blocks == true)<br>{<br>green_blocks = false;<br>hit_one = true;<br>speeddiry = -speeddiry;<br>}<br>else<br>{<br>speeddiry = speeddiry;<br>}<br>}<br>}<br>else if ((bally &gt; 5.0) && (bally &lt; 6.0))<br>{<br>int floater2 = (ballx * 1000);<br>int j = ((floater2 / 1000) + 16);<br>if ((j &gt;= 0) && (j &lt; 32))<br>{<br>if (blue_blocks[j] == true)<br>{<br>blue_blocks[j] = false;<br>hit_one = true;<br>speeddiry = -speeddiry;<br>}<br>else<br>{<br>speeddiry = speeddiry;<br>}<br>}<br>}<br>else if ((bally &gt; 6.0) && (ballx &lt; 7.0))<br>{<br>int floater3 = (ballx * 1000);<br>int l = ((floater3 / 1000) + 16);<br>if ((l &gt;= 0) && (l &lt; 32))<br>{<br>if (red_blocks[l] == true)<br>{<br>red_blocks[l] = false;<br>hit_one = true;<br>speeddiry = -speeddiry;<br>}<br>else<br>{<br>speeddiry = speeddiry;<br>}<br>}<br>}<br>else if ((bally &gt;= 7.0) && (ballx &lt; 8.0))<br>{<br>int floater4 = (ballx * 1000);<br>int m = ((floater4 / 1000) + 16);<br>if ((m &gt;= 0) && (m &lt; 32))<br>{<br>if (red_blocks[m] == true)<br>{<br>red_blocks[m] = false;<br>hit_one = true;<br>speeddiry = -speeddiry;<br>}<br>else<br>{<br>speeddiry = speeddiry;<br>}<br>}<br>}<br>}<br>}<br><br>    DisplaySquare();<br><br>    //Move Bat<br> if (keystate[DIK_LEFT] & 0x80)<br>if (batx &gt; -20)<br>{<br>batx-=0.07f;<br>batx-=0.07f;<br>batx-=0.07f;<br>//for speed<br>}<br>    if (keystate[DIK_RIGHT] & 0x80)  <br> if (batx &lt; 20)<br> {<br>batx+=0.07f;<br>batx+=0.07f;<br>batx+=0.07f;<br> }<br> if (keystate[DIK_ESCAPE] & 0x80)<br> {<br>    PostQuitMessage(0);<br> }<br><br> //if (blocks_hit &gt; 95)<br>//{<br>//game_state = GAME_STATE_GAME_RESET;  <br> //}  <br> if (keystate[DIK_P] & 0x80)<br> {<br>    game_state = GAME_STATE_GAME_PAUSE;<br> }<br>  }<br>  break;<br> <br> case GAME_STATE_GAME_RESET:<br> {<br>  //may need to redraw here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1<br>    game_score += 500;<br>    DisplayScore();<br>    game_state = GAME_STATE_GAME_INIT;<br> } <br>  break;<br> <br> case GAME_STATE_GAME_PAUSE:<br>  {<br>if (keystate[DIK_SPACE] & 0x80)<br>{<br>game_state = GAME_STATE_GAME_RUN;<br>}<br> } <br>  break;<br><br>  case GAME_STATE_WIN_SCREEN:<br>  {<br>  DisplayVictory();<br>   //SET STUFF UP HERE!!!!<br><br> game_state = GAME_STATE_WIN_SCREEN; <br><br>if (keystate[DIK_SPACE] & 0x80)<br>{<br>game_state = GAME_STATE_TITLE_SCREEN;<br>}<br>  }<br> break;<br><br>  case GAME_STATE_END_SCREEN:<br>  {<br>  DisplayEnd();<br>   //SET STUFF UP HERE!!!!<br><br> game_state = GAME_STATE_END_SCREEN;  <br><br>if (keystate[DIK_SPACE] & 0x80)<br>{<br>game_state = GAME_STATE_TITLE_SCREEN;<br>}<br>  }<br>  break;<br>   }<br>}<br><br><br>//OK MAIN RENDER CODE NOW<br><br>void DisplaySquare(void)<br>{<br>   D3DXMATRIX matWorld;<br> //First line simply blankets the screen with a colour of our choice<br>  D3DDevice-&gt;Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );<br>   D3DDevice-&gt;BeginScene();//lets device know we are about to begin rendering<br><br>D3DDevice-&gt;SetVertexShader(D3D8T_CUSTOMVERTEX);<br>D3DDevice-&gt;SetStreamSource(0,D3DVertexBuffer,sizeof(batvertex));<br>D3DXMatrixTranslation(&matWorld,0.0f,0.0f,-35.0f);<br>//***********************************************************************<br>//**The following line controls teh location on the screen of bat<br>//*****************************************************************<br>D3DXMatrixTranslation(&matWorld,batx,baty,0.0f);<br>D3DDevice-&gt;SetTransform( D3DTS_WORLD, &matWorld );<br>D3DDevice-&gt;SetTexture(0,D3DTextureBat1); //Incorporate the texture<br>D3DDevice-&gt;DrawPrimitive(D3DPT_TRIANGLELIST,0,2); <br><br>//***********************************************************************<br>//**The following line controls teh location on the screen of ball<br>//*****************************************************************<br>D3DXMatrixTranslation(&matWorld,ballx,bally,0.0f);<br>D3DDevice-&gt;SetTransform( D3DTS_WORLD, &matWorld );<br>D3DDevice-&gt;SetTexture(0,D3DTextureBall); //Incorporate the texture<br>D3DDevice-&gt;DrawPrimitive(D3DPT_TRIANGLELIST,0,2); <br><br>//Red Blocks<br>for (int i = 0; i&lt;32;i=i++)<br>{<br>if (red_blocks = true)<br>{<br>D3DXMatrixTranslation(&matWorld,-16.0 + i ,+7.0f,0.0f);<br>D3DDevice-&gt;SetTransform( D3DTS_WORLD, &matWorld );<br>D3DDevice-&gt;SetTexture(0,D3DTextureRBrick); //Incorporate the texture<br>D3DDevice-&gt;DrawPrimitive(D3DPT_TRIANGLELIST,0,2); <br>}<br>}<br><br>//Blue Blocks<br><br>for (int k = 0; k&lt;32;k=k++)   <br>{<br>if (blue_blocks[k] = true)<br>{<br>D3DXMatrixTranslation(&matWorld,-16.0 + k ,+6.0f,0.0f);<br>D3DDevice-&gt;SetTransform( D3DTS_WORLD, &matWorld );<br>D3DDevice-&gt;SetTexture(0,D3DTextureBBrick); //Incorporate the texture<br>D3DDevice-&gt;DrawPrimitive(D3DPT_TRIANGLELIST,0,2); <br>}<br>}<br><br>// Render the block only if it''s not destroyed<br>for (int l = 0; l&lt;32;l++)   <br>{<br>if (green_blocks[l] = true)<br>{<br>D3DXMatrixTranslation(&matWorld,-16.0 + l ,+5.0f,0.0f);<br>D3DDevice-&gt;SetTransform( D3DTS_WORLD, &matWorld );<br>D3DDevice-&gt;SetTexture(0,D3DTextureGBrick); //Incorporate the texture<br>D3DDevice-&gt;DrawPrimitive(D3DPT_TRIANGLELIST,0,2); <br>}<br>}<br><br><br>D3DDevice-&gt;EndScene();//Lets device know rendering has finished.<br>    D3DDevice-&gt;SetTexture(0,NULL);//Switch the texture "off"<br>    <br>//The next line of code flips the contents of the back buffer to the screen.<br>   D3DDevice-&gt;Present( NULL, NULL, NULL, NULL );//Show what we have drawn<br>}<br><br>*/</font><br></pre><!–ENDSCRIPT–><br><br>Right in case you didnt already guess, the coloured blocks are a boolean array, and if the bal movement code is needed, i''m happy to supply that as well but its pretty simple its mainly angles 90 degrees at a set speed.<br><br>*fingers crossed its right this time*   ;  This is how I interpreted it:"Help it doesn''t work what''s wrong?"This isn''t really a DirectX question. It is a game logic question. You know how to render, that is DirectX. Knowing what to render is part of the game. I very much doubt anyone is going to look through all of your code without any idea of where to start. 