Page 1 of 2

need ideas

Posted: Thu Oct 22, 2009 7:49 pm
by killercoder
I need some new ideas for a program to try coding as a beginner in the c++ language, I ask this because I cant think of anything to code. I would like simple ideas because I am fairly new to programming with c++ and I have been having a hard time to try to code something that will test my abilities so far.

p.s. Thank you very much for any and all ideas they are greatly appreciated :)

Re: need ideas

Posted: Thu Oct 22, 2009 7:59 pm
by Trask
I recommend going through some tutorials, not sure how 'beginner' you really are, but I do know that learning some new feats of the language always gave me ideas of things to try as I would better understand or have an idea on how something was made to begin with.

Re: need ideas

Posted: Fri Oct 23, 2009 7:29 am
by Pennywise
A good one can be a program that asks for your age, and says whether your a child, adult or whatever using if and else statements (or switch statements).

Re: need ideas

Posted: Fri Oct 23, 2009 3:52 pm
by killercoder
Yea that is a good idea :)

I think I am going to try that :p

Re: need ideas

Posted: Fri Oct 23, 2009 5:12 pm
by Pickzell
Building off of Pennywise's idea:

Base your programs off of real life.

I currently don't have a compiler so don't hate me if there are errors.

Code: Select all

//This gives you good advice
#include <iostream>

using namespace std;

unsigned short int grade;

int main()
{

   cout << "Enter your grade!";
   cin >> grade;

   //I don't like switch statements :p
   if( grade > 100 )
      cout << "Lying gets you nowhere";
   else if( grade >= 90 && grade <= 100 )
      cout << "You're better than me";
   else if( grade >= 80 && grade < 90 )
      cout << "What does the B stand for?";
   else if( grade >= 70 && grade < 80 )
      cout << "It means average, believe it or not";
   else if( grade >= 60 && grade < 70 )
      cout << "Remember, it's your teacher's fault.";
   else if( grade >= 50 && grade < 60 )
      cout << "It stands for fantastic. Srsly.";
   else
      cout << "Stop drinking on school nights.";

cin.get();
return 0;
}

Re: need ideas

Posted: Sat Oct 24, 2009 5:56 am
by K-Bal
You can also dive into game programming, write a "Guess the Number" game ;)

Re: need ideas

Posted: Sat Oct 24, 2009 10:49 am
by zeid
A good tutorial regime for someone looking to be a games programmer might be something like:

Absolute beginner
  • Basic data types; int, bool, float, double, char
  • Arrays and Strings.
  • Input and Output.
  • Selection.
  • Iteration.
  • Methods/Functions.
Don't just do these things one way either try and see how many different ways you can go about things. With selection learn if statements, if else statements, switch statements and ?:;. With iteration learn all the differen't kinds of loops. Once you learn how to use methods go back to iteration and learn how you can accomplish the same things with reccursion. These are for the most the foundations of all programming languages, if you explore them in-depth you will find yourself becomming very familiar with your chosen language.

Test your skills
  • Make a simple command console based game. Use letters/characters to represent the objects in the game. Try making it 'realtime'
Congratulations; you are now a games programmer... In that you made a game :D

AdvancedNote there is no intermediate
  • Object-oriented programming (there is alot more to cover here).
  • Pointers.
  • Multi-threading.
Expect to feel a little lost when it comes to this stuff you will likely have an 'oh now I get it' sometime and suddenly the world wont be such a scary place. OOP, pointers and multithreading all need different mind sets, multithreading can be skipped if you want.
The OOP (object oriented programming) stuff is important to get right, as a lot of data-structures and programming paradigms are either dependant on OOP, or are typically expressed in OOP. Seeing as you are using C++ you will be needing to know about pointers. Pointers link in to OOP for things like linked-lists. Which is an abstract data-type. which brings me too...

Abstract Data Types/Data-Structures
I'm not going to say all the ones you should learn, because it depends on your goals. But this is where you are starting to lookup proven structures that people have made. There is alot to cover here, and it can be a bit dry so I don't reccommend tackling it on it's own. I suggest coupling it with some graphics/games programming. If you do that you might even find some examples of where these data-structures are used, such as with binary trees etc.

Graphics
By the time you are up to graphics you will be a pretty accomplished programmer, I would say learn about this at the same time as ADTs. Choose a graphics API, I reccommend OpenGL personally, look up about matrices calculations, translation, rotation, scaling, pushing and poping, as these are how the maths works behind the scenes (its actually important knowing whats going on behind the scenes with these particular things). Obviously you will also need to learn how to create an OpenGL window, etc. Which brings me to the point of Windows Programming, you don't need to learn how to program OS based code, actually it's very important you don't get caught up with it. I remember when I was getting into OpenGL I almost ended up learning windows programming because I tried to find out what ever obscure windows call did when setting up a window. There's alot of code and you really only need to know how a window handles messages.

Test your skills
  • Make a simple game. Something basic, like a simple asteroids game. Anything you do in openGL can be done in either 2d or 3d, I reccommend making 2d but in actuality you could just as easily make a simple 3d game if you have a good understanding of 3d.
Game related maths and paradigms

Vectors! Very important... if you are smart enough to have gotten this far then you can probably make up alot of ways of going about solving problems like collision detection, etc. That said it helps to look up how other people do it, as there is no point in re-inventing the wheel and I assure you people have done things in better ways then you ;). You should look into singletons (this should probably happen after you have a solid understanding of OOP and pointers). Model View Controller is a must to learn if you plan on making any big projects. Don't be afraid to read up on these kinds of things during the Advanced Stage of learning as it puts into perspective alot of the usefullness of OOP. That said, you probably shouldn't attempt this kind of programming that early, just understand the concepts behind it to make OOP feel more useful.

Test your skills
  • Make a game engine and remake your simple game within the engine or a similar simple game. DONT get caught up in this, you will likely dump the engine afterwards, this is just so that you understand how these differen't paradigms work and how a big project could be put together.
Congratulations; you are now an openGL games programmer... In that you made a game with openGL :D

By this time you are ready to dump your engine and use someone elses, look into the technologies behind things such as scripting. Realistically it's usually impractical to use your own engine unless you are making a simple project.

Advanced challenge if you want to get into 3d
Make a simple 3d model loader (MD2 is reccommended).
Expand your model loader to allow for keyframe animation.

Expert Games Maths
  • Quaternions vs Euler rotation
  • Inverse kinematics/bone animation
Learn what quaternions are and how to use them...

Expert Graphics
  • Shaders.
Learn how to write your own shaders if you are really into graphics programming.

Expect to take years before you are truelly accomplished. If you have gotten to the stage where you are using someone elses game engine and have dumped your own then you are of about the average level of someone leaving uni that did a games degree I would think. The beginner topics wont take you nearly as long as the rest to explore which is good :). A final word of advice, obviously don't get ahead of yourself this list is a listing for someone who would want to become a proffessional level games programmer. This list isn't comprehensive, it eludes to alot of the stuff you should start to learn and expects you to research what areas.

Re: need ideas

Posted: Sat Oct 24, 2009 4:11 pm
by killercoder
This is what I have made so far :)

Code: Select all

#include <iostream>
#include <stdlib.h>
#include <string>
#include <math.h>

using namespace std;

int main(int argc, char *argv[])
{
    cout << "what would you like your name to be?" << endl;
    string name;
    cin >> name;
    cout << "hello nice to meet you " << name << endl;
    system ("PAUSE");
    cout << "what is your favorite number " << name << endl;
    int x;
    cin >> x;
    cout << "Your favorite number is " << x << endl;
    system ("PAUSE");
    return 0;
}

Re: need ideas

Posted: Sat Oct 24, 2009 5:37 pm
by davidthefat
txt based calculator

Re: need ideas

Posted: Sun Oct 25, 2009 3:02 am
by Pennywise
Remember to start small and work your way up. If you start game development to early, you may lose interest in programming overall.

Re: need ideas

Posted: Sun Oct 25, 2009 1:29 pm
by dandymcgee
killercoder wrote:This is what I have made so far :)

Code: Select all

#include <iostream>
#include <stdlib.h>
#include <string>
#include <math.h>

using namespace std;

int main(int argc, char *argv[])
{
    cout << "what would you like your name to be?" << endl;
    string name;
    cin >> name;
    cout << "hello nice to meet you " << name << endl;
    system ("PAUSE");
    cout << "what is your favorite number " << name << endl;
    int x;
    cin >> x;
    cout << "Your favorite number is " << x << endl;
    system ("PAUSE");
    return 0;
}
Please do not get into the habit of using "system("PAUSE");" in your program to wait for a keystroke.
Using cin.get(); or similar is a thousand times more efficient.
Read More

Re: need ideas

Posted: Sun Oct 25, 2009 2:17 pm
by killercoder
Ohh thank you very much for the advice ill break that bad habit :)

Re: need ideas

Posted: Sun Oct 25, 2009 2:30 pm
by dandymcgee
killercoder wrote:Ohh thank you very much for the advice ill break that bad habit :)
Also, not sure why you're including math.h, you only need this for functions like sqrt(), sin(), etc.
Oh and you don't need stdlib.h anymore either (cin.get() is defined in iostream). ;)

Good start, keep playing with it.

Re: need ideas

Posted: Sun Oct 25, 2009 2:45 pm
by killercoder

Code: Select all

#include <iostream>
#include <stdlib.h>
#include <string>
#include <conio.h>

using namespace std;

int main(int argc, char *argv[])
{
    int x;
    int c = x + 5;
    string name;
    int answer1;
    cout << "what would you like your name to be?" << endl;
    cout << ">"; cin >> name;
    cout << "hello nice to meet you " << name << endl;
    system ("PAUSE");
    cout << "what is your favorite number " << name << endl;
    cout << ">"; cin >> x;
    cout << "Your favorite number is " << x << endl;
    system ("PAUSE");
    cout << "what is your favourite number +5?" << endl;
    cout << ">"; cin >> c;
    if( c != x+5 )
      cout << "Wrong@@@@" << endl;
    else if( c = x+5 )
      cout << "Correct!!" << endl;
}
I can't seem to figure out whats wrong with this code :(. it wont pause after you give you answer to last question....

P.S. It's a nooby mistake I bet lol.

Re: need ideas

Posted: Sun Oct 25, 2009 3:19 pm
by andrew
You didn't assign a value to x before you started using it.