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

#41 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 01 December 2003 - 09:32 AM

<a href = "www.www.gamedev.net/"> Click Here </a>

Sponsor:

#42 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 01 December 2003 - 09:33 AM

[url = "www.www.gamedev.net"] Click Here? [/url]

#43 aftermath   Banned   -  Reputation: 100

Like
Likes
Like

Posted 01 December 2003 - 11:43 AM

RTFM n00b

#44 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 01 December 2003 - 04:16 PM

Hmm, just get a black screen...it compiles but its blank!

#45 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 01 December 2003 - 09:59 PM

That''s because it requires that you make the graphics (a single bitmap file named blocks.bmp) for it yourself. To see how, look at the very bottom of the original post.

-Greven

#46 Goldsacs   Members   -  Reputation: 122

Like
Likes
Like

Posted 02 December 2003 - 12:07 AM

Whoa Evil_Greven... good tutorial ;-)

____________________________________
It''s got to be good if its nuclear
http://www.nuclearfirework.com

#47 IFooBar   Members   -  Reputation: 906

Like
Likes
Like

Posted 03 December 2003 - 07:55 PM

quote:
Original post by Evil_Greven
That''s because it requires that you make the graphics (a single bitmap file named blocks.bmp) for it yourself. To see how, look at the very bottom of the original post.

-Greven


Or go here and scroll to the bottom

#48 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 07 December 2003 - 09:23 PM

Hey i get some errors when i try to comple it
:::
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\sniper_tris\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\sniper_tris\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include"

In file included from main.cpp:13:
bitmapobject.h:4:9: warning: #pragma once is obsolete
bitmapobject.h:7:10: #include expects "FILENAME" or <FILENAME>
main.cpp: In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)'':
main.cpp:165: `struct _WNDCLASSEXA'' has no member named `nostyle''

make.exe: *** [main.o] Error 1

Execution terminated

My microsoft visual C++ skewed up so i just used dev-C++ and thats da error i get.
In visual C++ when i try to build it / complile it says
0 errors 0 warnings but than when i go to run it it says
wateva da name of da.exe hasnt been complied do u wish to complie it i click yes and it says cannot exxcutute wateva da name of da.exe in this case its sniper_tris .
yeh heres a link to what i have done in the source form
http://www.roksta.com/help_sniper.zip
THANX


#49 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 07 December 2003 - 09:25 PM

sory mistake made it is
http://www.roksta.com/helpsniper.zip
thats wat i done and i think it should be working/complieng but its not :''( .
THANX :D

#50 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 08 December 2003 - 04:26 AM

URL still doesn''t work, I''m afraid.

I noticed this error:
main.cpp:165: `struct _WNDCLASSEXA'' has no member named `nostyle''

Did you copy from the unedited post? The forums automatically change ''style'' to ''nostyle'' (HTML formatting I guess, or something).

I''m guessing you have a line like this:

//class style
wcx.nostyle = CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;


Change ''nostyle'' to ''style'' and that will fix the error.

Also, this error (or as it a warning?):
bitmapobject.h:7:10: #include expects "FILENAME" or

You should doublecheck the #include for bitmapobject to make sure it is correct, if it is an error.

-Greven

#51 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 08 December 2003 - 11:33 AM

k thanx i am trying it now
and i know for sure that it works now i just tried it
www.roksta.com/helpsniper.zip

#52 Sniper_snes   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 December 2003 - 11:52 AM

k i duno wat happened i now get 13 errors

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\sniper_tris\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\sniper_tris\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include"

In file included from main.cpp:13:
bitmapobject.h:4:9: warning: #pragma once is obsolete
bitmapobject.h:7:10: #include expects "FILENAME" or
In file included from main.cpp:13:
bitmapobject.h:10: parse error before `{'' token

bitmapobject.h:26: parse error before `public''

bitmapobject.h:31: destructors must be member functions
bitmapobject.h:34: parse error before `.'' token

bitmapobject.h:49: `operator HDC__*()'' must be a nonstatic member function
bitmapobject.h:49: `operator HDC__*()'' must take exactly one argument
bitmapobject.h:50: parse error before `}'' token

main.cpp:70: ''BitMapObject'' is used as a type, but is not defined as a type.
main.cpp:73: ''BitMapObject'' is used as a type, but is not defined as a type.

main.cpp: In function `LRESULT TheWindowProc(HWND__*, unsigned int, unsigned
int, long int)'':
main.cpp:134: `bmoMap'' undeclared (first use this function)
main.cpp:134: (Each undeclared identifier is reported only once for each
function it appears in.)

main.cpp: In function `bool GameInit()'':
main.cpp:279: `bmoBlocks'' undeclared (first use this function)

make.exe: *** [main.o] Error 1

Execution terminated

what i done is at
www.roksta.com/helpsniper.zip
I wana see this complie suscessfully
Thanx

#53 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 08 December 2003 - 12:53 PM

Well, I get 36 errors, heh.

in BitMapObject.h:
Change:

//we need this for windows stuff.
#include

to:

//we need this for windows stuff.
#include <windows.h>


In BitMapObject.cpp:
Add:

#include "bitmapobject.h"

at the top of the file.

This fixes basically all the errors. However, you did not copy the NewBlock() function into your program. Refer to the original post for that, as it is somewhat lengthy.
It is listed in main.cpp between DrawMap() and RotateBlock().

That should fix it. Also, though, I noticed that in the file you have for download, you still have:

//class style
wcx.nostyle = CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;

when it should be:

//class style
wcx.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;


-Greven


[Edited by - Evil_Greven on July 13, 2004 12:53:22 AM]

#54 Sniper_snes   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 December 2003 - 05:43 PM

i did all that but i still get 12 errors

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\sniper_tris\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\sniper_tris\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include"

In file included from main.cpp:13:
bitmapobject.h:4:9: warning: #pragma once is obsolete
In file included from main.cpp:13:
bitmapobject.h:10: parse error before `{'' token

bitmapobject.h:26: parse error before `public''

bitmapobject.h:31: destructors must be member functions
bitmapobject.h:34: parse error before `.'' token

bitmapobject.h:49: `operator HDC__*()'' must be a nonstatic member function
bitmapobject.h:49: `operator HDC__*()'' must take exactly one argument
bitmapobject.h:50: parse error before `}'' token

main.cpp:70: ''BitMapObject'' is used as a type, but is not defined as a type.
main.cpp:73: ''BitMapObject'' is used as a type, but is not defined as a type.
main.cpp: In function `LRESULT TheWindowProc(HWND__*, unsigned int, unsigned
int, long int)'':

main.cpp:134: `bmoMap'' undeclared (first use this function)
main.cpp:134: (Each undeclared identifier is reported only once for each
function it appears in.)

main.cpp: In function `bool GameInit()'':
main.cpp:279: `bmoBlocks'' undeclared (first use this function)

make.exe: *** [main.o] Error 1

Execution terminated

yeh and i updated www.roksta.com/helpsniper.zip to what i am up to .
thanx heaps for the help so far ..
i cant wait 2 play my first game
sniper_snes


#55 Sniper_snes   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 December 2003 - 05:43 PM

i did all that but i still get 12 errors

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\sniper_tris\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\sniper_tris\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include"

In file included from main.cpp:13:
bitmapobject.h:4:9: warning: #pragma once is obsolete
In file included from main.cpp:13:
bitmapobject.h:10: parse error before `{' token

bitmapobject.h:26: parse error before `public'

bitmapobject.h:31: destructors must be member functions
bitmapobject.h:34: parse error before `.' token

bitmapobject.h:49: `operator HDC__*()' must be a nonstatic member function
bitmapobject.h:49: `operator HDC__*()' must take exactly one argument
bitmapobject.h:50: parse error before `}' token

main.cpp:70: 'BitMapObject' is used as a type, but is not defined as a type.
main.cpp:73: 'BitMapObject' is used as a type, but is not defined as a type.
main.cpp: In function `LRESULT TheWindowProc(HWND__*, unsigned int, unsigned
int, long int)':

main.cpp:134: `bmoMap' undeclared (first use this function)
main.cpp:134: (Each undeclared identifier is reported only once for each
function it appears in.)

main.cpp: In function `bool GameInit()':
main.cpp:279: `bmoBlocks' undeclared (first use this function)

make.exe: *** [main.o] Error 1

Execution terminated

yeh and i updated www.roksta.com/helpsniper.zip to what i am up to .
thanx heaps for the help so far ..
i cant wait 2 play my first game
sniper_snes




[edited by - sniper_snes on December 8, 2003 12:49:17 AM]

#56 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 08 December 2003 - 07:14 PM

Are you sure you uploaded the updated files?

I''m looking at the ''updated'' files. None of the errors above have I seen fixed.

Fixing the errors that I pointed out above gives me a working version. Either you didn''t update the files in the zip or you didn''t fix any of the errors...

-Greven

#57 Sniper_snes   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 December 2003 - 08:49 PM

DAMIT i did it all over again and uploaded it to
www.roksta.com/helpsniper.zip
i am now using visual C++ instead of Dev C++ and i know get 30 errors :''(
here they are
:::::::::::::
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
c:\dev-cpp\sniper_tris\bitmapobject.h(10) : error C2447: missing function header (old-style formal list?)
c:\dev-cpp\sniper_tris\main.cpp(70) : error C2079: ''bmoMap'' uses undefined class ''BitMapObject''
c:\dev-cpp\sniper_tris\main.cpp(73) : error C2079: ''Blocks'' uses undefined class ''BitMapObject''
c:\dev-cpp\sniper_tris\main.cpp(136) : error C2664: ''BitBlt'' : cannot convert parameter 6 from ''int'' to ''struct HDC__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\dev-cpp\sniper_tris\main.cpp(275) : error C2228: left of ''.Create'' must have class/struct/union type
c:\dev-cpp\sniper_tris\main.cpp(276) : error C2664: ''FillRect'' : cannot convert parameter 1 from ''int'' to ''struct HDC__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\dev-cpp\sniper_tris\main.cpp(279) : error C2228: left of ''.Load'' must have class/struct/union type
c:\dev-cpp\sniper_tris\main.cpp(334) : error C2664: ''BitBlt'' : cannot convert parameter 1 from ''int'' to ''struct HDC__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\dev-cpp\sniper_tris\main.cpp(345) : error C2664: ''BitBlt'' : cannot convert parameter 1 from ''int'' to ''struct HDC__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
bitmapobject.cpp
c:\dev-cpp\sniper_tris\bitmapobject.h(10) : error C2447: missing function header (old-style formal list?)
c:\dev-cpp\sniper_tris\bitmapobject.cpp(2) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.cpp(4) : error C2065: ''hdcMemory'' : undeclared identifier
c:\dev-cpp\sniper_tris\bitmapobject.cpp(5) : error C2065: ''hbmNewBitMap'' : undeclared identifier
c:\dev-cpp\sniper_tris\bitmapobject.cpp(6) : error C2065: ''hbmOldBitMap'' : undeclared identifier
c:\dev-cpp\sniper_tris\bitmapobject.cpp(7) : error C2065: ''iWidth'' : undeclared identifier
c:\dev-cpp\sniper_tris\bitmapobject.cpp(8) : error C2065: ''iHeight'' : undeclared identifier
c:\dev-cpp\sniper_tris\bitmapobject.cpp(9) : warning C4508: ''BitMapObject'' : function should return a value; ''void'' return type assumed
c:\dev-cpp\sniper_tris\bitmapobject.cpp(11) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.cpp(12) : error C2084: function ''int __cdecl BitMapObject(void)'' already has a body
c:\dev-cpp\sniper_tris\bitmapobject.cpp(15) : error C2065: ''Destroy'' : undeclared identifier
c:\dev-cpp\sniper_tris\bitmapobject.cpp(18) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.cpp(25) : error C2440: ''='' : cannot convert from ''struct HDC__ *'' to ''int''
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\dev-cpp\sniper_tris\bitmapobject.cpp(28) : error C2440: ''='' : cannot convert from ''struct HBITMAP__ *'' to ''int''
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\dev-cpp\sniper_tris\bitmapobject.cpp(42) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.cpp(49) : error C2440: ''='' : cannot convert from ''struct HDC__ *'' to ''int''
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\dev-cpp\sniper_tris\bitmapobject.cpp(52) : error C2440: ''='' : cannot convert from ''struct HBITMAP__ *'' to ''int''
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\dev-cpp\sniper_tris\bitmapobject.cpp(62) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.cpp(63) : error C2373: ''Destroy'' : redefinition; different type modifiers
c:\dev-cpp\sniper_tris\bitmapobject.cpp(81) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.cpp(87) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.cpp(93) : error C2027: use of undefined type ''BitMapObject''
c:\dev-cpp\sniper_tris\bitmapobject.h(9) : see declaration of ''BitMapObject''
Error executing cl.exe.

main.exe - 30 error(s), 1 warning(s)

i fixed everything u said 2 but stil cant figure this out
could u send the working source code to sniper@roksta.com
thanx

#58 Sniper_snes   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 December 2003 - 10:05 PM

thanx but theres still that no style error but i fixed that and brang it down 2 four errors

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\sniper_tris\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\sniper_tris\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include"

In file included from main.cpp:13:
bitmapobject.h:4:9: warning: #pragma once is obsolete

g++.exe -c bitmapobject.cpp -o bitmapobject.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include"

In file included from bitmapobject.cpp:1:
bitmapobject.h:4:9: warning: #pragma once is obsolete
bitmapobject.cpp:11: redefinition of `BitMapObject::BitMapObject()''
bitmapobject.cpp:3: `BitMapObject::BitMapObject()'' previously defined here
bitmapobject.cpp:11: no `BitMapObject::BitMapObject()'' member function declared
in class `BitMapObject''
bitmapobject.cpp:12: confused by earlier errors, bailing out

make.exe: *** [bitmapobject.o] Error 1

Execution terminated



#59 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 10 December 2003 - 11:40 AM

where can i get "bitmapobject.h"??

please,i am a hUgE newB

#60 Evil_Greven   Members   -  Reputation: 410

Like
Likes
Like

Posted 10 December 2003 - 01:02 PM

Sniper, did the files I sent work?


Anonymous Poster,
The bitmapobject.h is listed in the original post, though since I built the tutorial as I went, it is created where it is first needed, which is slightly down from the beginning of the file.

-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