How much c++
Moderator: Coders of Rage
How much c++
I've been reading and learning c++ for a little while now, thanks to Sam's c++ in 21 days. I was just wondering what is the minimal amount of information necessary for making a graphical game. Not some MMORPG, just something like pong or space invaders. I was also wondering what to use for the graphics, Sdl, opengl, or can I just do it in c++.
Thank you in advance.
Thank you in advance.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: How much c++
You need to have some sort of graphics API that allows you to do stuff with video (by talking to the graphics cards/hardware of the computer for you).
DirectX, OpenGL, Direct3D, Allegro, and SDL are all have graphics APIs that let you do this.
For a beginner, I would personally recommend using SDL. You probably don't need too much C++ to get started. At least make sure that you understand things like pointers and basic object oriented programming concepts.
DirectX, OpenGL, Direct3D, Allegro, and SDL are all have graphics APIs that let you do this.
For a beginner, I would personally recommend using SDL. You probably don't need too much C++ to get started. At least make sure that you understand things like pointers and basic object oriented programming concepts.
Re: How much c++
Ok, Thanks man.
By the way I love your game, and the series. I've always loved computers, but your series helped me into programming. Can't wait to play Elysian shadows! Keep it up!
By the way I love your game, and the series. I've always loved computers, but your series helped me into programming. Can't wait to play Elysian shadows! Keep it up!
When One learns to Love, One must bear the risk of Hatred.
- programmerinprogress
- Chaos Rift Devotee
- Posts: 632
- Joined: Wed Oct 29, 2008 7:31 am
- Current Project: some crazy stuff, i'll tell soon :-)
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++!
- Location: The UK
- Contact:
Re: How much c++
Another important think you need to be able to do is to understand how to Program
I know this may sound a little stupid, but think about it, it's all fine and well being able to memorise what a variable is, or what a pointer is, but you have to know how to apply these principles and how to use in them in your code.
e.g. you might find yourself writing your first SDL application, and you want it to print random colours to draw random-coloured boxes to the screen or something like that.
It would be of great benefit if you understand how to come up with the appropriate algorithms.
Going back to the coloured box example, you should be able to say to yourself "well I need to use a random number generator to generate 3 sets of integers to create the random colour, I might want to handle some input using this control structure etc", as long as you're able to apply what you have learnt, then you are ready ( well you're ready if you have what gyro said as well )
There's only one thing I can think of to sum up my point and that is Inquisitive mind thats what you need to program, if you've got that, you can pick the rest up along the way, being able to come up with things is useless if you don't want to come up with them!
Good luck, and I hope to see what you come up with in the nenear future, i'll be watching
I know this may sound a little stupid, but think about it, it's all fine and well being able to memorise what a variable is, or what a pointer is, but you have to know how to apply these principles and how to use in them in your code.
e.g. you might find yourself writing your first SDL application, and you want it to print random colours to draw random-coloured boxes to the screen or something like that.
It would be of great benefit if you understand how to come up with the appropriate algorithms.
Going back to the coloured box example, you should be able to say to yourself "well I need to use a random number generator to generate 3 sets of integers to create the random colour, I might want to handle some input using this control structure etc", as long as you're able to apply what you have learnt, then you are ready ( well you're ready if you have what gyro said as well )
There's only one thing I can think of to sum up my point and that is Inquisitive mind thats what you need to program, if you've got that, you can pick the rest up along the way, being able to come up with things is useless if you don't want to come up with them!
Good luck, and I hope to see what you come up with in the nenear future, i'll be watching
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
Re: How much c++
I understand what you mean, all the knowledge means nothing if you don't know how to put it to use.
As I said before i'm reading sam's book, and in here it talks about "prototypes" such as:
void myfunction();
int main()
{
some st00f blaaah
return 0;
}
void myfunction()
{
blaaaahh more stuff
}
Now why would I need to use the prototype there? I don't know if I'm being clear, but I don't understand the use, and the book isn't really explaining.
As I said before i'm reading sam's book, and in here it talks about "prototypes" such as:
void myfunction();
int main()
{
some st00f blaaah
return 0;
}
void myfunction()
{
blaaaahh more stuff
}
Now why would I need to use the prototype there? I don't know if I'm being clear, but I don't understand the use, and the book isn't really explaining.
When One learns to Love, One must bear the risk of Hatred.
Re: How much c++
You need to have a prototype there because it is located after the main function. You could either put the whole function before main or you have to prototype it so the compiler can find it. Try not prototyping and you will get an compiler error.jtst1 wrote:I understand what you mean, all the knowledge means nothing if you don't know how to put it to use.
As I said before i'm reading sam's book, and in here it talks about "prototypes" such as:
void myfunction();
int main()
{
some st00f blaaah
return 0;
}
void myfunction()
{
blaaaahh more stuff
}
Now why would I need to use the prototype there? I don't know if I'm being clear, but I don't understand the use, and the book isn't really explaining.
Re: How much c++
Ah thank you. It makes sense.
When One learns to Love, One must bear the risk of Hatred.
- programmerinprogress
- Chaos Rift Devotee
- Posts: 632
- Joined: Wed Oct 29, 2008 7:31 am
- Current Project: some crazy stuff, i'll tell soon :-)
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++!
- Location: The UK
- Contact:
Re: How much c++
Prototyping is very important, because the compiler doesn't know that a function exists, unless you explcity mention that it does before the main() function.
Everything in C++ has a purpose, it's karma dude
Everything in C++ has a purpose, it's karma dude
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
Re: How much c++
That through me off for a while when I first started, I was used to blitz basic, and you could put your functions anywhere and it would work, and I always put my functions after my main loop... I had a lot of errors in my first few programs....herby490 wrote:You need to have a prototype there because it is located after the main function. You could either put the whole function before main or you have to prototype it so the compiler can find it. Try not prototyping and you will get an compiler error.jtst1 wrote:I understand what you mean, all the knowledge means nothing if you don't know how to put it to use.
As I said before i'm reading sam's book, and in here it talks about "prototypes" such as:
void myfunction();
int main()
{
some st00f blaaah
return 0;
}
void myfunction()
{
blaaaahh more stuff
}
Now why would I need to use the prototype there? I don't know if I'm being clear, but I don't understand the use, and the book isn't really explaining.
Re: How much c++
Ah ok. Lol at ^^ post above.
Sorry for the long list of questions, but I've been trying to use the knowledge that i've aquired, and I've run into a snag.
I wanted to have a function that was a float,double,int,long, so that when the user entered in a number and it was doubled, even if it was a decimal and - it would still work. Now that I think about it there really is no point for a long or double... considereing the number is between 1-500. So onto the question, I had "firstNumber" entered where the ???? are, but it only output the original number, so I was wondering if I put the wrong thing there. I thought it would be that because the function would replace the old value with the new.
Sorry for the long list of questions, but I've been trying to use the knowledge that i've aquired, and I've run into a snag.
Code: Select all
#include <iostream.h>
int firstDub (int);
long firstDub (long);
float firstDub (float);
double firstDub (double);
int main()
{
int firstNumber;
int doubledInt;
long doubledLong;
float doubledFloat;
double doubledDouble;
cout << "Please enter a number between 1-500: ";
cin >> firstNumber;
if (firstNumber > 500)
{
cout << "THATS TOO HAI!\n";
else;
doubledInt = firstDub(firstNumber);
doubledFloat = firstDub(firstNumber);
doubledLong = firstDub(firstNumber);
doubledDouble = firstDub(firstNumber);
cout << "The first number you entered: " << firstNumber << "\n";
cout << "The first number doubled: " << ??? << "\n";
}
}
int firstDub(int x)
{
return 2 * x;
}
long firstDub(long x)
{
return 2 * x;
}
float firstDub(float x)
{
return 2 * x;
}
double firstDub(double x)
{
return 2 * x;
}
When One learns to Love, One must bear the risk of Hatred.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: How much c++
You didn't change the value of firstNumber. You stored the doubled value of firstNumber into like, doubleInt and stuff. That's what you have to output.
Also:
"else;"
is the same as:
"else {}"
It does nothing. You can remove it, if that's what you meant to write.
Also:
"else;"
is the same as:
"else {}"
It does nothing. You can remove it, if that's what you meant to write.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: How much c++
Ok I made a few changes to your code. First use <iostream> instead of <iostream.h> iostream.h is old. You do not need the float, int, or long because is you enter one of those to a double it will automatically convert it. Here is the new code
Sorry for the poor explanation.
Code: Select all
#include <iostream>
#include <windows.h>
using namespace std;
int firstDub (int);
long firstDub (long);
float firstDub (float);
double firstDub (double);
int main()
{
int firstNumber;
//int doubledInt;
//long doubledLong;
//float doubledFloat;
double doubledDouble;
cout << "Please enter a number between 1-500: ";
cin >> firstNumber;
if (firstNumber > 500)
{
cout << "THATS TOO HAI!\n";
}
else
{
//doubledInt = firstDub(firstNumber);
//doubledFloat = firstDub(firstNumber);
//doubledLong = firstDub(firstNumber);
doubledDouble = firstDub(firstNumber);
cout << "The first number you entered: " << firstNumber << "\n";
cout << "The first number doubled: " << doubledDouble << "\n";
}
Sleep(2000);
return 0;
}
/*int firstDub(int x)
{
return 2 * x;
}
long firstDub(long x)
{
return 2 * x;
}
float firstDub(float x)
{
return 2 * x;
}*/
double firstDub(double x)
{
return 2 * x;
}
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: How much c++
You forgot to add using namespace std
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: How much c++
Yeah I added it in the code i guess i forgot to tell him to add it.MarauderIIC wrote:You forgot to add using namespace std
Re: How much c++
A few questions. When i try to use <iostream> codeblocks gives me an error. Second is namespace std for cout and cin. Never mind I just had to delete the functions i didnt use. But the usingnamespace std, do you put that instead of the <.h>herby490 wrote:Ok I made a few changes to your code. First use <iostream> instead of <iostream.h> iostream.h is old. You do not need the float, int, or long because is you enter one of those to a double it will automatically convert it. Here is the new codeSorry for the poor explanation.Code: Select all
#include <iostream> #include <windows.h> using namespace std; int firstDub (int); long firstDub (long); float firstDub (float); double firstDub (double); int main() { int firstNumber; //int doubledInt; //long doubledLong; //float doubledFloat; double doubledDouble; cout << "Please enter a number between 1-500: "; cin >> firstNumber; if (firstNumber > 500) { cout << "THATS TOO HAI!\n"; } else { //doubledInt = firstDub(firstNumber); //doubledFloat = firstDub(firstNumber); //doubledLong = firstDub(firstNumber); doubledDouble = firstDub(firstNumber); cout << "The first number you entered: " << firstNumber << "\n"; cout << "The first number doubled: " << doubledDouble << "\n"; } Sleep(2000); return 0; } /*int firstDub(int x) { return 2 * x; } long firstDub(long x) { return 2 * x; } float firstDub(float x) { return 2 * x; }*/ double firstDub(double x) { return 2 * x; }
Last edited by jtst1 on Tue May 05, 2009 8:18 pm, edited 1 time in total.
When One learns to Love, One must bear the risk of Hatred.