Tetris clone in an hour with C++.

Started by
148 comments, last by jbadams 12 years, 1 month ago
Hey Greven, a thousand thanks for the tutorial! It's fun to learn while actually making the game

But every time I try to compile, I get a

fatal error C1010: unexpected end of file while looking for precompiled header directive

at the end of my main.cpp and bitmapobject.cpp files

Any idea what I can do to fix this? Could it have anything to do with the fact that when I created the project, it gave me a source file named "Falling Blocks Game" (name of my project) but I didn't use it for anything?

Edit: Oops forgot, I am running VC++ .NET

[edited by - Jupiter Hessius on January 27, 2004 5:45:10 PM]
Sometimes people die, and that''s sad, but it''s worse if they don''t die. Ever...because then they''re vampires.
Advertisement
fatal error C1010: unexpected end of file while looking for precompiled header directive

---You're using precompiled headers! Bad human (imho)!

Be sure to have #include "stdafx.h" at the very beginning (before the #pragma once, even) of every file that complains like that, and that should fix it.

Edit: That's if you're using Microsoft's Visual Studio to do the project. I'm not sure who else does precompiled headers, or what they'd want you to include.



"Remember: Silly is a state of Mind, Stupid is a way of Life." -- Dave Butler


[edited by - Indigo Darkwolf on January 27, 2004 5:40:34 PM]

Globals are not evil. Singletons are evil.
Woohoo it works Thanks much!

Haha, that is, it works after I go back and delete extra semicolons I didn''t need, and put it other ones I did need (I just can''t get used to the semicolons at the end of every line yet I guess). And of course, made sure everything was capitalized properly.

But I did need that file at the top. Woohoo, now I can go about doing many great things, such as oh, changing the blocks into penguins!
Sometimes people die, and that''s sad, but it''s worse if they don''t die. Ever...because then they''re vampires.
Penguins scare me.

But yeah, have fun with it; change anything and everything you can, while keeping it running. If you''re not having fun making a game, you should question your motivations for programming games in the first place. Is it because you want a career in game development or is it a hobby? Myself, I''ve not yet decided which route to take.

-Greven
I really Like this tut.

It was easy and really basic.

Now I just need to figure out all the ins and out's of it.

I was wondering Can this game be made into a break out clone game very easly?

Or how about into a pong clone?



[edited by - kingpinzs on February 17, 2004 6:41:14 PM]
For some reson My score part to work. It just reads 3002 and changes to 4 when the up button is pushed then back to 3002. It wont count the times a row disapers. Can any one help?
You can modify it fairly easily. I changed this general structure a bit and made a 2D space shooter out of it. You'll probably want to make another bitmap for the ball (you could even do one with multiple frames to make it look good).

Can you post the code that controls your scoring?

-Greven

[edited by - Evil_Greven on February 18, 2004 12:38:10 PM]
I am not sure how do it yet.

this is what I was thinking
int v_score;    int temp = v_score ;	DrawTile(MAPWIDTH+1,GREY,(9+temp/100000));	if(temp >= 100000)		temp-=(100000*(temp/100000));	DrawTile(MAPWIDTH+2,GREY,(9+temp/10000));	if(temp >= 10000)		temp-=(10000*(temp/10000));	DrawTile(MAPWIDTH+3,GREY,(9+temp/1000));	if(temp >= 1000)		temp-=(1000*(temp/1000));	DrawTile(MAPWIDTH+4,GREY,(9+temp/100));	if(temp >= 100)		temp-=(100*(temp/100));	DrawTile(MAPWIDTH+5,GREY,(9+temp/10));	if(temp >= 10)		temp-=(10*(temp/10));	DrawTile(MAPWIDTH+6,GREY,(9+temp));	



and put the counter in here some were I just dont know were to add it.
void Move(int x, int y){    if(CollisionTest(x, y))    {        if(y == 1)        {            if(sPiece.y<1)            {                //you lose!  new game.                NewGame();            }                       else                                                        {                bool killblock=false;                int i,j;                               //new block time! add this one to the list!                for(i=0; i<4; i++)                    for(j=0; j<4; j++)                        if(sPiece.size[ i ][j] != TILENODRAW)                            Map[sPiece.x+i][sPiece.y+j] = sPiece.size[ i ][j];                //check for cleared row!                for(j=0; j< MAPHEIGHT; j++)                {                    bool filled=true;                    for(i=0; i< MAPWIDTH; i++)                        if(Map[ i ][j] == TILEBLACK)                            filled=false;                    if(filled)                    {                                            RemoveRow(j);                        killblock=true;                                            }                                                        }                if(killblock)                {                    for(i=0; i<4; i++)                        for(j=0; j<4; j++)                            sPiece.size[ i ][j]=TILENODRAW;                }                                NewBlock();            }        }    }    else    {        sPiece.x+=x;        sPiece.y+=y;    }    DrawMap();}

never mind I was amking it to hard. I just needed to declare a globel varible and put it to zero then in the fill loop add 1 to the varible then in my print score loop I just called the gloable varible and it worked.

Evil_Greven

Yes! My game works.
Thanks for the tutorial.

Thorbjørn.

www.tomsborg.no



[edited by - Thorbjorn on February 20, 2004 8:15:39 AM]
Thorbjørn.www.tomsborg.no

This topic is closed to new replies.

Advertisement