Finishing touches on my tetris game.

  • Thread starter finchie_88
  • Start date
  • Tags
    Game
In summary, the conversation discusses a game of Tetris being developed in C++ using the Dev-C++ IDE and Windows API. The main issue being faced is that when the blocks hit the bottom of the window or other blocks, they disappear. The code snippet provided shows a collision function and variables being used. The poster eventually discovers and fixes the problem, apologizing for the irrelevant thread.
  • #1
finchie_88
Hello everyone. I have got quite far with a game of tetris that I am making (I'm writting in C++, and on windows, using Dev-C++ IDE and windows API). I am just touching it up, and then it will be done. One of the problems which I am having, is that when the blocks hit the bottom of the window (or they hit the blocks that should have hit the bottom of the window), the blocks disappear, so after a while, you get areas where the blocks just disappear as they come down. I think that it is something to do with my collision function, but can't spot the error.
I will explain the variables below.
Code:
    int newx=sPiece.x+nx;
    int newy=sPiece.y+ny;

    int i,j,x,y;

    for(i=0; i< 4; i++)
        for(j=0; j< 4; j++)
            if(sPiece.size[ i ][j] != TILENODRAW)
                if((newx + i) < 0 || (newx + i) > (MAPWIDTH - 1) ||
                    (newy + j) < 0 || (newy + j) > (MAPHEIGHT - 1))
                    return 1;

    for(x=0; x< MAPWIDTH; x++)
        for(y=0; y< MAPHEIGHT; y++)
            if(x >= newx && x < newx + 4)
                if(y >= newy && y < newy +4)
                    if(Map[x][y] != TILEBLACK)
                        if(sPiece.size[x - newx][y - newy] != TILENODRAW)
                            return 1;
    return 0;
MAPHEIGHT and MAPWIDTH are pretty obvious, they are constant integers. sPiece is a structure containing (integers) x & y (these refer to the current position). nx, and ny are the distances in the x and y-axis respectively that the blocks have moved. Things like TILEBLACK and TILENODRAW are defined in a header file, and refer to a bitmap that I am using. There are a few other improvements I would like to make, but I think I can sort those out on my own, if I can't - I'll be back!
 
Technology news on Phys.org
  • #2
It's clear that this is one of a number of functions, and the error may well be somewhere else.

It's unclear what exactly this snippet of code is supposed to do. (And as a bonus, writing a clear explanation may well help you find the bug.)
 
  • #3
Ok, well, when the did game run, the blocks fell like they were suppose to, but when they hit the "floor", or they hit other blocks which were already on the "floor", they disappear from sight. Obviously, this is was a little bit of a problem. I did think that it might be to do with the collision test function when I originally posted, although, I have just found the problem, and rectified it, sorry about this - Now I look like a real fool.:blushing:

Note to moderators - This thread is not really relavent, feel free to delete.
 

FAQ: Finishing touches on my tetris game.

1. What is the purpose of adding finishing touches to a Tetris game?

The purpose of adding finishing touches to a Tetris game is to improve the overall user experience and make the game more visually appealing. This can include adding sound effects, animations, and additional features to enhance the gameplay.

2. How can finishing touches improve the functionality of a Tetris game?

Finishing touches can improve the functionality of a Tetris game by fixing any bugs or glitches, optimizing the game for different devices, and implementing user feedback to make the game more user-friendly and enjoyable.

3. What are some common finishing touches that are added to a Tetris game?

Some common finishing touches that are added to a Tetris game include different game modes, customizable options, high score tracking, and social media integration. These features can enhance the gameplay and make the game more engaging for players.

4. Why is it important for a scientist to pay attention to the finishing touches on a Tetris game?

As a scientist, it is important to pay attention to the finishing touches on a Tetris game because they can significantly impact the success and reception of the game. By carefully adding and refining finishing touches, the game can reach a wider audience and potentially lead to further research and advancements in game design.

5. How can finishing touches on a Tetris game make it stand out from other similar games?

Finishing touches on a Tetris game can make it stand out from other similar games by adding unique and innovative features, improving the graphics and sound quality, and creating a more immersive and enjoyable gaming experience. These touches can make the game more memorable and distinguishable from others in the market.

Back
Top