Jump to content

  • Log In with Google      Sign In   
  • Create Account


Tetris clone in an hour with C++.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
149 replies to this topic

#101 Jupiter Hessius   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 January 2004 - 10:37 AM

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]

Sponsor:

#102 Indigo Darkwolf   Members   -  Reputation: 174

Like
Likes
Like

Posted 27 January 2004 - 10:39 AM

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]

#103 Jupiter Hessius   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 January 2004 - 12:01 PM

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!

#104 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 16 February 2004 - 04:55 AM

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

#105 kingpinzs   Members   -  Reputation: 109

Like
Likes
Like

Posted 17 February 2004 - 10:25 AM

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]

#106 kingpinzs   Members   -  Reputation: 109

Like
Likes
Like

Posted 17 February 2004 - 02:34 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?

#107 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 18 February 2004 - 05:36 AM

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]

#108 kingpinzs   Members   -  Reputation: 109

Like
Likes
Like

Posted 18 February 2004 - 07:40 AM

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();
}



#109 kingpinzs   Members   -  Reputation: 109

Like
Likes
Like

Posted 18 February 2004 - 09:34 AM

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.



#110 Thorbjorn   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 February 2004 - 09:04 PM

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]

#111 MarpleSoft   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 February 2004 - 07:46 PM

hmm i had to fix a few errors i had, but i after i did i got no errors, great job with the tutorial, i'm looking foward to making graphics and sound for this game.

[edited by - MarpleSoft on February 22, 2004 4:39:53 PM]

#112 TsukasaZero   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 February 2004 - 06:59 AM

Awesome tutorial man, but in Dev C/C++ I get 2 warnings and 1 error. The error occurs on line 277 (starting the definition of the RotateBlock() function) and it says "parse error before ''{'' token".

I tried everything, copy and pasting the functions before it, the function itself, but the same thing always comes up. Help?

#113 ShadowMaster088   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 February 2004 - 01:26 AM

I don''t think I will ever be able to do it because the only think I can is to write scenarios for the games. We will start with programing this year at school so I should get better soon. It''s kinda'' hard to learn it because there aren''t many guides in Bulgaria.

#114 Skalol   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 February 2004 - 09:03 PM

Hi!
Thanks for that tutorial! The zip file seems not to be downloadable, so i slowly work with the first post.

Sorry, i edited my post 'cause i've made a big mistake. Now it compiles..

Lolo from france.

[edited by - Skalol on February 27, 2004 4:28:33 AM]

#115 georgia   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 February 2004 - 07:03 PM

I didnt try this code yet... I am sure that it will help me a lot!!!!! If I have any problems I will get back to u

Georgia

#116 Elfs1der   Members   -  Reputation: 102

Like
Likes
Like

Posted 29 February 2004 - 03:49 AM

I get an illegal operation for some reason right when it starts up, no errors or anything when it compiles

#117 Goosey   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 March 2004 - 05:16 PM

I am getting two errors:

tetrisClone error LNK2019: unresolved external symbol "void __cdecl DrawTile(int,int,enum TILECOLOR)" (?DrawTile@@YAXHHW4TILECOLOR@@@Z) referenced in function "void __cdecl DrawMap(void)" (?DrawMap@@YAXXZ)

tetrisClone fatal error LNK1120: 1 unresolved externals


I don''t know what this error is about. I''ve been comparing my code to the post''s source for the last hour.. Please someone help me :|

AIM: DarkGoosey
ICQ: 14128911
MSN: DarkGoosey@hotmail.com
Email: td1@sssnet.com

#118 georgia   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 March 2004 - 09:42 PM

Hey I just tried it and it runs perfectly!!!
Thanks Evil_Greven... Now I have to work on changes!!! I hope I will manage to do it!!

Georgia

#119 SimonTreloar   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 March 2004 - 07:24 AM

This tutorial was fantastic!

I''ve been looking everywhere for a Tetris clone that I could follow through the code and work it out bit by bit.

I''ve only just started C++ programming but a lot of this makes sense to me and your commenting really helps.

Thanks for making this available to everyone!! For people like me, it''s a godsend!

#120 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 05 March 2004 - 01:08 PM

If these suggestions don''t help, please post your code.

TsukasaZero,

Double-check the code where the RotateBlock() function is, and also just above it for mistakes.

Elfs1der,

That''s rather odd. You should double-check the two bitmapobject files for mistakes, it might be the problem.

Goosey,

Make sure the call to DrawTile() in function DrawMap() is correctly copied. If it is, make sure you have the DrawTile() function declared correctly at the top like the rest of them.

-Greven




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS