• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Evil_Greven

Tetris clone in an hour with C++.

149 posts in this topic

quote:
Original post by QzarBaron
I sat thruogh the entire tutorial and finished the code then at the end i get this(BTW i named the project SimpleTris):

SimpleTris error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
SimpleTris fatal error LNK1120: 1 unresolved externals

i really dont know whats wrong is it my fault or the code.



You need to compile to a Win32 executable, not a console. This is a compiler setting.

0

Share this post


Link to post
Share on other sites
quote:
Original post by Evil_Greven
glassJAw,
In a simple program such as this, risks are quite minimal. What would you have done for something such as a ''score'' variable? That''d basically have to be global. You''d be passing it constantly. Sure, it''s good programming to pass stuff, but newbies aren''t always familiar with the different forms of passing, so I try to keep their use minimal.

Then I recommend using accessor functions so you have some level of protection. You''re right the risks are minimal in a program of this scope, but it''s a bad habit to be teaching new programmers (I can attest to that, it was one of my bad habits).

quote:
Also, I don''t use exact Hungarian notation (bleh, n for ints, I prefer i), I use my own variant.

Using i for ints is, in fact, a very popular variant, and it completely misses the point of Hungarian notation. As I said earlier, if you prefix a variable, the prefix should represent the purpose of the variable, not the type. Using i for ints is the worst case of this, as I''ve found variables of type int are the most prone to change. Something like "BYTE iWhatever" just looks dumb, but the only alternative would be to rename every single instance of "iWhatever" in the code.

quote:
Lastly, I would have to change the code significantly in order to set piece types as enum/constants. The program doesn''t really care what *kind* of piece it is, it just moves it around how it needs to. Like I said, this is a very simple program.


You wouldn''t have to change the code much at all to use constants. It does wonders for readability.

quote:
To all beginning game programmers reading this, I wish you luck on your journey; either professional or hobbyist. You''ll need it, with all the frustrations that come up. I won''t say this is the best tutorial in the world, just one of the shorter ones .

Overall, it''s definitely a good tutorial. I just think there''s a few small problems with it that could be corrected fairly easily, and without making it a whole lot longer.
0

Share this post


Link to post
Share on other sites
It''s OK but...
It''s not really C++, I mean, a single object isn''t very OO. You could have made the map an object, a tile an object and the application itself as an object (a singleton, even) containing your global variables.
It''s not very maintainable or resuable - two important elements when it comes to developing any type of software. The block creation code is duplicated. Also, I prefer to not use prototypes, rather use definition as declaration. In both these cases, any updates require changes to two bits of code (although one may be spotted by the compiler).
It''s not "data driven", another useful tool, especially in games programming.
You should really have put a brief section at the start detailing the design of the game (what you''re setting out to do) and thus the program (how it''s done).
Finally, a section at the end listing a few ideas for further development.

Skizz
0

Share this post


Link to post
Share on other sites
well i created an empty project in VS.NET i guess ill try it with Win32 the problem is it creates a bunch of useless stuff that i cant deal with.
0

Share this post


Link to post
Share on other sites
quote:
Original post by Skizz
It's OK but...
It's not really C++, I mean, a single object isn't very OO. You could have made the map an object, a tile an object and the application itself as an object (a singleton, even) containing your global variables.
It's not very maintainable or resuable - two important elements when it comes to developing any type of software. The block creation code is duplicated. Also, I prefer to not use prototypes, rather use definition as declaration. In both these cases, any updates require changes to two bits of code (although one may be spotted by the compiler).
It's not "data driven", another useful tool, especially in games programming.
You should really have put a brief section at the start detailing the design of the game (what you're setting out to do) and thus the program (how it's done).
Finally, a section at the end listing a few ideas for further development.

Skizz


I think you're slightly missing the point of what's being put across here. Sure, there are improvements that could be made in terms of coding style and re-usability, but let's remember that the point of the tutorial was to get a working Tetris clone, with beginners in mind. If that means over-simplifying parts of the code in order to get the point across, then that's all well and good; it gives people an insight into how things can be accomplished and probably makes reading more specific tutorials, easier to read and grasp.

One last thing. Just because C++ supports object orientation doesn't mean that you have to use it. Yes, admittedly there are a large number of benefits to using it. However, it can be a slightly confusing paradigm to use if you're not familiar with it. Whereas the structured approach tends to be much easier to grasp; it doesn't matter how many tutorials you read about objects in a program working in a fashion like a bicycle with wheels and gears, unless you've put it into practice, it won't change the way you develop your own projects.

To OP: IMHO, great tutorial. I've not read all of it yet, but whilst I feel glassJaw makes some valid points, I do think that you've got the message across to beginners, which is the most important thing. Understanding is the foundation to a successful tutorial. No point writing something that the audience you're aiming at, won't understand; it defeats the point.

Glad it's been turned into a 'Sticky' as well. Certainly should help to answer some of the more frequent questions on this board.

-hellz

[edited by - hellz on November 27, 2003 6:09:31 PM]
0

Share this post


Link to post
Share on other sites
quote:


One last thing. Just because C++ supports object orientation doesn''t mean that you have to use it


What he said.
0

Share this post


Link to post
Share on other sites



hi,
thank you so much greven.and a poster was right on the money when he said this tut was aimed at people starting out so all the wise tricks in the world would not mean fart.After i''m done with taking a few steps i''ll look into making all the optimizations...in fact i''ll be in a position to appreciate them more.


class act...without classes ;-p .

b
0

Share this post


Link to post
Share on other sites
quote:
Original post by hellz
One last thing. Just because C++ supports object orientation doesn''t mean that you have to use it.
*static* Roger that! *static*

As I recall, C++ is a multi-paradigmn language. Somebody posted that interview with Bjarne Stroustop. It supports OO, but you don''t have to.

0

Share this post


Link to post
Share on other sites
quote:
Original post by Nervo
quote:
Original post by Anonymous Poster
http://www.gamedev.net/ can use you


aren''t you that "maxd gaming" guy?

If so, then why don''t you post in your real name.


No, thats not me. Thats my idiot friend who thinks spamming is the greatest thing
0

Share this post


Link to post
Share on other sites
sweet tutorial, i just finished it thanks. i''m adding onto the game now, thinking of changing it into a dr mario clone too
0

Share this post


Link to post
Share on other sites
quote:
Original post by maxd gaming
quote:
Original post by Nervo
quote:
Original post by Anonymous Poster
http://www.gamedev.net/ can use you


aren''t you that "maxd gaming" guy?

If so, then why don''t you post in your real name.


No, thats not me. Thats my idiot friend who thinks spamming is the greatest thing


What are you talking about...yes I am Max''d Gaming

Goto www.www.gamedev.net/
0

Share this post


Link to post
Share on other sites
Hmm, just get a black screen...it compiles but its blank!
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.