Advertisement

The Impossible Problem (AKA Need Help)

Started by June 04, 2000 09:41 PM
17 comments, last by valg3 24 years, 3 months ago
One thing: when you find the solution, be sure to post it for everyone to see!

More things to think about:
(you don''t have to answer these, but they may direct you to the source of the bug)

1)Where, and in how many places, do you allocate memory?
2)What about the scope of the GRID array? Is it ever being hidden?
3)Find every instance of the word GRID in your code and make sure that you haven''t mistaken an assignment operator for a comparison operator. For example:

if(GRID[i][j] = 0) DrawBlock();

The = operator will assign the value zero the referenced array entry and the expression will evaluate to true (so a block is drawn).

Chances are it''s something minor and you are going to kick yourself when you find it.
------When thirsty for life, drink whisky. When thirsty for water, add ice.
Here''s my changing function. Its really simple as you can see.

//Using those new coordinates, place the blocks on GRID[][]
GRID[y1][x1] = 1;
GRID[y2][x2] = 1;
GRID[y3][x3] = 1;
GRID[y4][x4] = 1;

I''m using DirectX to blit the images to the screen. Here''s my rendering function:

//////////////////////////////////////////////////////////////////
void Render()
//////////////////////////////////////////////////////////////////
{
if(bTitleScreen)
{
//Blit the titlescreen to the back buffer
lpDDSBack->BltFast(0,0,lpTitle_surf,NULL,DDBLTFAST_WAIT);
}
else
{
//Blit the playing surface to the back buffer
lpDDSBack->BltFast(0,0,lpPlayWindow_surf,NULL,DDBLTFAST_WAIT);

//Blit each block to the back buffer
for(int i = 0; i{
for(int j = 0; j < WIDTH; j++)
{
if(GRID[j] == 1)
lpDDSBack->BltFast(41+j*30,41+i*30,lpBlock_surf,NULL,DDBLTFAST_WAIT);
}
}
}

//flip to the primary surface

lpDDSPrimary->Flip(0,DDFLIP_WAIT);
}
Advertisement
I don't know if you just made a mistake while typing but,



if (GRID[j] == 1)
//blit it to playing area...

should be



if (GRID [j] == 1)
//blt it to playing area...



This should fix it, if it wasn't a typo in the first place.

If that didn't work, I just got the idea that maybe when you're doing the actual blitting with bltfast(), you are making some silly mistake in your calculations (i.e. 41+j*30,41+i*30) and that bltfast is actually blitting a black piece of your bitmap surface. This would make it seem like nothing is being blitted at all.

I also noticed that you aren't using RECT's. Maybe you should, as it may help you to pinpoint the problem.

Good luck,
Martin


Edited by - lpsoftware on June 6, 2000 6:37:08 PM
______________Martin EstevaolpSoftware
Nevermind about that typo thing, it was just the board processing the HTML.

Martin
______________Martin EstevaolpSoftware
silly people
using </i> is the italic tag!<br><br>so you''re telling me that<br>grid[0][0] = 2;<br><br>gives an error!?
___________________________Freeware development:ruinedsoft.com
Isn''t there some sort of code tag so that you can post source code without it being mangled? Also...i don''t quite understand the first line of:

for(int i = 0; i{
for(int j = 0; j < WIDTH; j++)
{
if(GRID[j] == 1)
lpDDSBack->BltFast(41+j*30,41+i*30,lpBlock_surf,NULL,DDBLTFAST_WAIT);
}
}
}

the "for (int i = 0; i{" confuses me. Is that a typo or did you actually write that in? If that''s in your code, it will probably cause a problem.

P h a n t a s m
"Through dreams I control mankind."
--Legend
Phantasm
Advertisement
He definitely did mistype that first line in the loop...he better have
And that code tag is "code" in the greater than and less than signs with the usual "/" to terminate.

iwasbiggs: What do you mean?

"so you''re telling me that
grid[0][0] = 2;

gives an error!? "

Martin
______________Martin EstevaolpSoftware
quote:
[program exits] Really odd,especially becauseit only happens when I fool with changing an array value.


and

quote:
if I ever use one of my functions that change a value in the array to something other than zero, the program blinks in and out once never running.


by the poster made me believe that he couldn't change values

*slaps face*
So, there isn't an error when changing array values, but what happens when you process those array values. Maybe I misread, but they way those two sentences were said led me to believe that the array was the source of the problem. Oh well, so there's a problem in a rendering function.
*playfully smacks valg3 too*

Edited by - iwasbiggs on June 6, 2000 12:13:46 AM
___________________________Freeware development:ruinedsoft.com
Just to make things more readable...

        //Using those new coordinates, place the blocks on GRID[][]GRID[y1][x1] = 1;GRID[y2][x2] = 1;GRID[y3][x3] = 1;GRID[y4][x4] = 1;//////////////////////////////////////////////////////////////////void Render()//////////////////////////////////////////////////////////////////{  if(bTitleScreen)  {    //Blit the titlescreen to the back buffer    lpDDSBack->BltFast(0,0,lpTitle_surf,NULL,DDBLTFAST_WAIT);  }  else  {    //Blit the playing surface to the back buffer    lpDDSBack->BltFast(0,0,lpPlayWindow_surf,NULL,DDBLTFAST_WAIT);    //Blit each block to the back buffer    for(int i = 0; i < HEIGHT; i++)     {      for(int j = 0; j < WIDTH; j++)      {        if(GRID[j] == 1)          lpDDSBack->BltFast(41+j*30,41+i*30,lpBlock_surf,NULL,DDBLTFAST_WAIT);      }    }  }//flip to the primary surfacelpDDSPrimary->Flip(0,DDFLIP_WAIT);}        


valg3, are you able to pinpoint a specific line(s) of code that gives you an error ? You mentioned that the program "blinks in and out once" without doing anything...so there's no GPF or anything, right? It just doesn't do anything. Sounds like some test (e.g. comparison) is failing when the array is initialized to zeroes and the rendering loops are being skipped.

Edited by - Graylien on June 6, 2000 12:26:36 AM
------When thirsty for life, drink whisky. When thirsty for water, add ice.

This topic is closed to new replies.

Advertisement