• 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.
Sign in to follow this  
Followers 0
Sugavanas

Game from Scratch ? C++

20 posts in this topic

Guys, I am back and now I have started learning C++ and know to create codes( But still on basics [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] ) . Can any one of you give me a code for making a game ( like tic tac toe) from scratch in C++. Please also explain it so i could understand it.
0

Share this post


Link to post
Share on other sites
[quote name='Sugavanas' timestamp='1355624564' post='5011136']
But still on basics
[/quote]

If you are still on basics, you can't make a game.
Learn the language first.
2

Share this post


Link to post
Share on other sites
That depends. A [url="http://www.cplusplus.com/forum/beginner/58540/"]random number guessing game is just a few lines of code[/url] and doesn't require intricate knowledge of a programming language.
2

Share this post


Link to post
Share on other sites
[quote name='GameCreator' timestamp='1355636004' post='5011178']
That depends. A [url="http://www.cplusplus.com/forum/beginner/58540/"]random number guessing game is just a few lines of code[/url] and doesn't require intricate knowledge of a programming language.
[/quote]

GameCreator has a valid point. My suggestion is to start small. Take GameCreator's advice and create a random number game. After you finish that, take a stab at another little game. You need to build up your skills (which is often overlooked by new programmers).

[quote name='lride' timestamp='1355631162' post='5011165']
[quote name='Sugavanas' timestamp='1355624564' post='5011136']
But still on basics
[/quote]

If you are still on basics, you can't make a game.
Learn the language first.
[/quote]
This is the hard, but very real truth. You can't create a game in a language if you do not know the language. Learn your basics and learn them well.

EDIT: I figured I would answer your original question as well. If you look online quite a few companies have released the source code to their games. Id Software's Doom 3 comes to mind. You can find the source code [url="https://github.com/TTimo/doom3.gpl"]here[/url]. With that being said, be prepared to have it handed to you. The level of coding that goes into games is extremely high. With that being said, however, studying other peoples code is an important part of learning to program. Edited by ByteTroll
0

Share this post


Link to post
Share on other sites
[quote name='ByteTroll' timestamp='1355650660' post='5011213']
The level of coding that goes into games is extremely high. With that being said, however, studying other peoples code is an important part of learning to program.
[/quote]

I very much agree that studying code is an important factor, but I don't believe it's applicable yet to the OP.
At this stage a good understanding of the language is a priority, especially so with C++ as there are so many ways to write functioning but terribly written C++ code. Source code for finished games might not always reflect the best practices, or might just do some things in a terribly hack-ish way because of time constraints or because something needed to be fixed quickly (I haven't looked at the source code for Doom myself, so I couldn't say whether this applies here).


Getting code for complete games just handed to you is not going to be all too helpful right now, it mostly encourages copy-paste behaviour and unless every technique/pattern/whatever used in the code is thoroughly documented, you probably won't understand the reason why the developer chose to use a certain technique at a certain location, or what the technique is even supposed to do.

The important thing now is to understand how to use the basic paradigms provided by C++ correctly at an elementary level, and how to properly implement problem solutions with these. Learn about the basic OOP principles, learn about what kind of functionality C++ provides to support OOP, learn about what kind of useful stuff the C++ standard library provides, etc. and work your way up starting from a very simple 'hello world' application while applying the concepts you've learned and using the data structures (eg. lists, maps, vectors, queues, stacks, etc.) and functionality you've read about.

Once you have some knowledge of object-oriented design and the tools your language provides it'll become clearer to you how to implement a simple game such as tic-tac-toe yourself.
1

Share this post


Link to post
Share on other sites
Copy pasting doesnt work in game programming (or programming for that matter), learn your language well then consider game programming, even using an engine like ogre / panda3d would require you to understand your language. Think of it like this, what you are trying to do is make a movie on your own but in French and you can only understand basic french words, despite having all the equipment and resources you cant speak French very well.

Learn the language then move onto the movie,.. I mean game
0

Share this post


Link to post
Share on other sites
And my suggestion, is to to practice with C++ for at least a year. Once you've coded a few stuff, then go to programming games. I know this is harsh, but it's correct.

You'd need to practice with boolean expressions a lot. Statements like if(!(var && !var2) && (!var3 || var4)). Edited by farmdve
0

Share this post


Link to post
Share on other sites
Learning a language is important but what is even more so is that you understand different programming principles. Functions, variables, comparisons, operators, containers, loops etc.

I suggest starting with writing small programs that do different things, not just games. Find different ways to manipulate data. Find and solve your own small problems. Try to implement a basic sorting algorithm, that sort of stuff.

When it comes to simple games that doesn't require anything fancy I generally divide the code in to three parts. Input, read user input and handle it accordingly. Update, update the game state accordingly to the game rules. Drawing, draw everything to the screen.

If I want to put together a simple game I just need to figure out how to represent the game state and then fill in these three functions.
1

Share this post


Link to post
Share on other sites
[quote name='ultramailman' timestamp='1355625500' post='5011139']
To write your own game from scratch, use this:

[CODE]
int main(void)
{
return 0;
}
[/CODE]

Now you will have to add your own code to it, and turn it into a game.
[/quote]

I'm Sorry but this comment made me grin from Ear to Ear lol! As all the others said it's best to start small and move forward. my very first game was a text based CYOA ( Choose Your Own Adventure) , which eventually gave way to a text based RPG, which eventually gave way to a basic platformer, and etc. etc. and I definitely think looking at someone else's code and dissecting it can help but there are some principles you won't understand until you play with them yourself like the game loop . and how to best set up a basic game progress. any how goodluck! Edited by JonathanJ1990
0

Share this post


Link to post
Share on other sites
start with javascript if you want to learn quick.
otherwise most of time would be spend on fixing syntax errors in c++
0

Share this post


Link to post
Share on other sites
I really feel like as a beginner vanilla C is going to be more intuitive and straightforward than trying to learn C++ out the door.

I know I'm probably sounding facetious, but frankly, C versus C++ provides scant, almost zero advantage one way or another as either way whether you write C++ or not you're going to be compiling C at the end of the day, and is all up to whether or not you think you need the concept of distinct objects that are protected from access from one another and things like generic code or compile-time code generation, or operator overloading to make a decent program.

Give C a try if you're on the basics, and see if you pick it up faster than C++. If you *need* some feature of C++ at some point later for any reason, then by all means, use C++ if it suits you at that point.

I also laughed uproariously at ultramailman's post. Edited by darkhaven3
0

Share this post


Link to post
Share on other sites
[quote name='darkhaven3' timestamp='1355834264' post='5012017']
I really feel like as a beginner vanilla C is going to be more intuitive and straightforward than trying to learn C++ out the door.
[/quote]

Honestly, I feel if the OP is learning C++, let them learn C++ without telling them they need to learn regular old C. They're both Turing-complete languages, each with pros and cons. I personally find C++ to be more intuitive than C, but if someone is learning C then I'm not going to suggest switching because of my personal taste. (sorry [img]http://public.gamedev.net//public/style_emoticons/default/wacko.png[/img] I just feel like discussions of which language is better, especially with C/C++, are totally pointless and especially don't help a beginner)

But if you want to learn to program a game like tic-tac-toe, there are a number of tutorials out on the web, and many books you could get that would help you along. I don't know where your skills are, but try searching around the net for beginner c++ lessons, or checking out your local library for books on programming or c++ if you can't afford to buy one. But like everyone else has been saying, be careful about not copy-pasting, or you won't learn anything! When you do find a tutorial or a book or whatever, play around with the code and see what happens; try and make it better, or try and make it do something different. This way you aren't just copy-pasting, you're actually figuring out what the stuff you're typing in actually does. I hope that helps! [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='Riphath' timestamp='1355836081' post='5012026']They're both Turing-complete languages, each with pros and cons.[/quote]
Absolutely. I might find that using generic programming or templates is by and large leaving the door open for bad programming practice, but I appreciate and accept that you will probably feel that my usage of structs and function pointers is archaic and meaningless. I don't mean to make it sound like I'm saying "C is better than C++" or even "C++ sucks", I am simply sharing my feelings that as a beginner I found the idea of just writing a function and being able to call it a much simpler process than having to worry about whether or not other objects should be allowed to see it.

Of course that is completely arbitrary and up to subjective evaluation by anyone at any point, and by no means do I mean to represent my opinion as fact. I apologize.

[quote]I personally find C++ to be more intuitive than C, but if someone is learning C then I'm not going to suggest switching because of my personal taste. (sorry [img]http://public.gamedev.net//public/style_emoticons/default/wacko.png[/img] I just feel like discussions of which language is better, especially with C/C++, are totally pointless and especially don't help a beginner)[/quote]

Like I said, I meant what I said in an absolutely subjective manner and I did not mean to present my opinion as anything but. I've just always seen C as a more attractive option for game programming as a personal preference, and I am sure I'm not the only person who might feel that way is all.
0

Share this post


Link to post
Share on other sites
[quote name='darkhaven3' timestamp='1355834264' post='5012017']
Give C a try if you're on the basics, and see if you pick it up faster than C++. If you *need* some feature of C++ at some point later for any reason, then by all means, use C++ if it suits you at that point.
[/quote]

actually i think i can learn c++ fast
0

Share this post


Link to post
Share on other sites
[quote name='darkhaven3' timestamp='1355838876' post='5012040']
Of course that is completely arbitrary and up to subjective evaluation by anyone at any point, and by no means do I mean to represent my opinion as fact. I apologize.
[/quote]

It's ok! This is a forum, after all. You're allowed to express your opinion. [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] It's just my opinion that if you talk about which language is best for beginners to start with to no end, you'll never stop being a beginner unless you actually start just programming!
0

Share this post


Link to post
Share on other sites
[quote name='darkhaven3' timestamp='1355834264' post='5012017']
I really feel like as a beginner vanilla C is going to be more intuitive and straightforward than trying to learn C++ out the door.
[/quote]I think both suck for a beginner, but if you must use one of them, you should use C++.

As long as you are just dealing with your own code, you don't have to use any of C++'s advanced features, and can adopt them at your own pace. The most important thing for the beginner is that C++ lets you get away with [b]never doing manual memory allocation[/b] if you just use std::vector, std::string, references, etc. everywhere. No news, no deletes, no pointers. You don't have to understand templates (or even classes, really) to use vector as a replacement of array, just like you don't have to understand streams in order to write "std::cout << ".

In C you can't do anything without first learning memory management inside and out, and even then you will constantly be tripping up and mired in debugging something.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0