Ive written a tetris clone one of my first reall programs. While I used a tutorial to get the basic outline and functions I didnt use there code. After several days of learning GDI calls I finaly managed to get the block on screen and falling down. I was pretty estatic. A few switched variable fixes later I had it up and running pretty well i thought. That was untill I answed the phone and was chatting letting the program run. My collision detection isnt the greatest, took a few revisions to get it right but i thought i had it working great. ( and i did as i later discoverd) when i saw all the blocks just clump up at the top and it not starting a new game. I thought for shure it was my detection wasnt returning true when the blocks moved meaning to start a new game. After an hour or so in the debugger I found it wasnt my collision at all. It was the newgame call.
thats my new game function. it gets called on initalazion and when collision returns true during the movement function.Code:void NewGame() { start_time = GetTickCount(); GAMESTARTED = false; int y = 0, x = 0 ; //startout the map for(;x<MAPWIDTH;x++) { for(;y<MAPHEIGHT+1;y++) { if(y==MAPHEIGHT) Map[x][y] = TILEGREY; else Map[x][y] = TILEBLACK; } }
What ended up causeing the error is where i declare y and x as 0.
if i change it to..
it works. I have no idea why from everything ive learned that should be the exact same save for where its done. Newgame is only called on initalize and a true on collision during move. So its not run though part way at any other time and even if it were the loops would be run any way. I cant figure out how thats any diffrent and why its causeing problems. Can any one else explain it?Code://startout the map for(int x = 0;x<MAPWIDTH;x++) { for(int y = 0;y<MAPHEIGHT+1;y++)
Thanks
~Meloshski



LinkBack URL
About LinkBacks


