Hello thar

Hey guys, new here. Im a year 11 student and im interested in creating games. Right now i have a good knowledge on how to model, animate and texture things in blender3d. Unfortunately, after looking at what subjects i should do in my final year of high school - the subjects which will determine where i go and what i can study, it turns out i never did enough of the art (the creative type classes) to get me into the graphics part of game making. in past years i figured art was easy and that i could benefit better from things like maths/sciences. Hopefully with a good Enter score (thats what we use in Australia, Melbourne. its a score out of 100 - your marks from your top 3 results + english exam results get added up to give you your enter score. - or something like that heh) i may be able to make it into what i want.

I know programming is a whole different world and isn't all fun and, well, games. its hard work and i guess it cant always be a thrilling job. I have previously done programming in Game Maker Language but that was pretty basic stuff. I wanted to have a go at C++ since i will most likely end up going to university to study t and work with it in the future.

its day 2 and im up to ยท Functions (I) on the tutorials page. right now its fairly easy to follow - ive been making my own small programs covering every new thing i learn in each section at the end of each section so that has helped me grasp most of the tutorial. Ive yet to create a small program which includes things learnt in Control Structures though. (the if's, else's, loop's etc).

Here is a handfull of my programs. i would like some feedback on them, telling me if im doing it right, how i can improve, etc!



Hello World program
1
2
3
4
5
6
7
8
9
10
11
12
// First program ^_^

#include <iostream>
using namespace std;


int main ()
{
  cout << "Hello World!" << endl;  
  system("PAUSE");
  return 0;
}


Using Comments
1
2
3
4
5
6
7
8
9
10
11
12
13
/* a comment in which 
i can put more then one linez */

#include <iostream>
using namespace std;


int main () //all c++ progras start here
{
  cout << "Hello World!" << endl;  //say hello 
  system("PAUSE"); //pause the process
  return 0; //says that the statements completed successfully.
}


Assigning and Displaying Variables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Showing how to declare and calculate variables.
also shows how to display them and multiple other things with one cout */

#include <iostream>//declerations
using namespace std;

int main ()//the program starts here
{

 int a,b,n,e,f,result;//declare the variables
 a=1;		// assign values to each variable
 b=3;
 n=2;
 e=50;
 f=n+e;
 
 result=(a+b)-f;

  cout << a << "+" << b //print out everything needed, linking up variables and words with <<.
	  << "-" << f << endl 
	  << endl 
	  << "Equals" << result << endl; //there is no need for a new line at 'endl'.
  system("PAUSE");//pause the program so we can read it.
  return 0; //return 0 to show that it worked.
}//end statement 


Give value to Variable on declare
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Showing another way to declare and calculate variables.
also shows how to display them and multiple other things with one cout */

#include <iostream>//declerations
using namespace std;

int main ()//the program starts here
{
/*!!!!!!!!!!!!Old method of declaring variables and assigning values
  int a,b,n,e,f,result;
 a=1;		
 b=3;
 n=2;
 e=50;
 f=n+e;
 */
 //!!!!!!!!!!!This has the same effect;


	int a(1),b(3),n(2),e(50),f(n+e),result;
	
	 result=(a+b)-f; //we dont know what result will be on the declare stage, so we assign a value to it after.

  cout << a << "+" << b //print out everything needed, linking up variables and words with <<.
	  << "-" << f << endl 
	  << endl 
	  << "Equals" << result << endl; //there is no need for a new line at 'endl'.
  system("PAUSE");//pause the program so we can read it.
  return 0; //return 0 to show that it worked.
}//end statement 


Strings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>//declerations
#include <string>

using namespace std;


int main()//the start of every program
{
	string astring ("Hello thar" ". how are ya?"); //strings are created and assigned words just like int's are.

	cout << astring << endl; //and also use the same method to print out on screen

	astring = "Hey!"; //and again, like numbers, they can be changed after being declared.

	cout << astring;

	system("PAUSE"); //pause the program so we can see whats happened
	return 0; //return 0 to show that everything went a-ok.
}//end statement 


Using #define
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>//declorations
#include <string>

using namespace std;
/* when you define something, everything is 
replaced with the things you defined for whatever you defined

#define name_of_the_word_to_replace with_this
*/

//examples:
#define hw "\n\nHello World!"
#define newline '\n'
#define doubleline "\n\nThis is a string \
writen in two lines in code. woot."
#define wordson2lines "\n\nThis is \n a new line"
#define mixture "\n\n\nThis code \
uses ever \n little \a \t thing. Even a beep sound :D"

/* a constant can never be changed. it can however be used to add to other variables etc */





int main()
{
	const int a(5);
	int b(5);
	cout << hw << newline << hw << newline << doubleline << newline << wordson2lines << newline << mixture << newline << a << newline << newline << newline;
	b = a - b;
	cout << "trying to change the constant gives error. \n you can however use it to add to other stuffs." << newline << b << newline;
	system("PAUSE");
	return 0;
}



Operators
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>//declorations
#include <string>//need string coz we're using strings.
using namespace std;



const int a(2); //a constant value, will never change.

int main()
{
	int b(a-2),c(a+b),d; //declare the variables.
	string teststring (" "); //creat the 'teststring' string with nothing in it.

	cout << "a:" << a << endl << "b:" << b << endl << "c:" << c << endl; //display all variables

	system("PAUSE");//and pause.

	teststring = (a>b) ? "A is bigger than B" : "A is not bigger than B"; /* using the conditional operator
																		  we ask is a is bigger than b. if
																		  it is, we get 
																		  teststring = "A is bigger than B"
																		  if it isnt we get
																		  testsring = "A is not bigger than B"
																		  */
	cout << teststring << endl; //display the result
	
	system("PAUSE");//pause the system so we can read what happened
	return 0; //return 0 to show that the program completed without any problem.


}//end the statement. 



Small Program. Mixture of things. Pretend you have X amount of money and need to purchase something that costs Y. this program asks for how much money you have and the cost of the thing needing purchase. it then tells you if you can buy it, and if you can how much change you'll get, and if you cant it tells you you cannot buy it and will tell you how much you need to be able to purchase. do not include the dollar sign
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>//declorations
#include <string>//need string coz we're using strings.
#include <sstream>

using namespace std;



int main()
{
	float a,b,c; //declare the variables.
	string teststring;
	cout << "How much money do you have?\n";
	getline(cin,teststring);
	stringstream(teststring) >> a;
	cout << "So you have " << teststring << " dollars? Ok, How much will your item cost?\n";
	cin >> b;

	c = a - b;
	 
	string affordable = (c>0) ? "You can purchase it and will receive this much change:\n" : "You cannot afford it. You need this much more money:\n";

	c = (c>0) ? c=c : c*-1;

	cout << affordable << c << endl << endl;
	
	system("PAUSE");//pause the system so we can read what happened
	return 0; //return 0 to show that the program completed without any problem.


}//end the statement. 






Thanks for reading!
Last edited on
With just a quick glance it looks like you are off to a pretty good start.

Have you made any games with the Blender game engine? (Anything significant requires a fair amount of Python coding, and it isn't particulary obvious. The Game Engine forums are very good places to get started.
http://blenderartists.org/forum/forumdisplay.php?f=34

You will also find a lot of useful game stuff in the Python & Plugins forum (which was the gamer's hangout before the game forums were created)
http://blenderartists.org/forum/forumdisplay.php?f=11

If you want to do simple gaming in C++ or Python I suggest you check out SDL. It is a very simple and clean, yet powerful graphics library. Check out my post here for more:
http://www.cplusplus.com/forum/general/3763/page1.html#msg16211

When you get more comfortable with C++ you can start looking around at other libraries. Good gaming places
http://www.gamedev.net/
http://nehe.gamedev.net/

Don't let prospective employers see you using system("PAUSE").
http://www.cplusplus.com/forum/beginner/1988/

Hope this helps!
Wow you definitely have a good future :D! I'm 12...I barely started learning a few days ago. Maybe we can be programming buddies? :3

Edit: I thought you said you were 11...=\
Last edited on
Thanks for the replies guys.

Duoas;

the world of programming, from where i stood, appeared huge (and i guess, now that i started learning, it hasnt changed all that much :P ). i had no idea at all what i had to learn in python to do what i wanted in blender game engine. no idea how to get the pythin scripts to work with my game, etc etc. so no, i havnt looked into the blender game engine, and i think i will finish learning C++ before i move onto anything else (i take it other languages are similar to c++ so it wont be a huge challange).

thanks for the links though, i will check them out if i have some time later on.

as for the system("PAUSE"); i read your little rant on the forum and will try and find another way around the problem. i dont want to fall into bad habits :)

Jello715;
Sorry. starting at 12? Wow. im very late hey
Topic archived. No new replies allowed.