C++ Beginner


Ploe

Still Fresh
Joined
Sep 18, 2006
Messages
17
Age
36
Location
West Yorkshire
Website
unquietdesperation.co.uk
Hi, I've downloaded the SDK from GPH and now I'm trying to find a good resource for learning C++. I'm familair with Visual Basic but C++ is overwhelming, there is so much going on. It's dead exciting. Where should I start? I'm really looking forward about diving into C++, I just need something to ease me into it.
 
Beginning
If you are just starting out with C++, then completely forget about programming for the PSP for the moment. It will only add an extra layer of complexity that will stop you from learning the language and the main concepts of programming.

Learn the fundamentals first, these include:
- Variables
- Conditional Statements
- Loops
- Functions
- Return values
- Parameter passing

Gamedev have a C++ workshop that has been going for a while now that you still might be able to catch up. 'Thinking like a Computer scientist' is also considered a good free ebook but nothing will substitute a good 'real' book on paper. At this point, you be mostly working with text in a 'console' (ie command prompt).

Targets: simple applications such as a Line based text editor that reads and writes to a file, Tic Tac Toe, a Text Adventure (with a command parser), Hangman, etc.

Workshop: http://www.gamedev.net/community/for...sp?forum_id=76
Thinking like a computer Scientist (C++ version): http://www.andamooka.org/reader.pl?section=thinkcpp
C Plus Plus Site: http://www.cplusplus.com/doc/tutorial/
Beginning C++ Game Programming: http://www.amazon.co.uk/gp/product/1592002...39&v=glance

Middle
After this you can move onto more language specific areas such as the macros, pointers, references, const, header/source organisation. Also you can start looking at graphical libraries such as SDL and OpenGL, both of which are cross platform and work on the PSP. This means that you can work on the PC and with some minor changes to the code, recompile and it should work on the PSP as well.

Targets: Graphical games such as Tetris, Breakout, snake, Mario clone, a small FPS level.

Thinking In C++ Vol 1: http://www.mindview.net/Books/TICPP/...ngInCPP2e.html
SDL tutorials: http://lazyfooproductions.com/SDL_tutorials/index.php
OpenGL tutorials: http://nehe.gamedev.net/

Advanced
Finally, you can jump into Object Orientation programming and the finer areas of the language (although you can do this at any point really). Thinking in C++ Vol 2 is probably the best free ebook in this area. There are also a selection of PDFs on the five principles of OOP.

Targets: Anything you want, think big and go for it.

Thinking in C++ Vol 2: http://www.mindview.net/Books/TICPP/...ngInCPP2e.html
Five Principles in OOP:
http://www.objectmentor.com/resources/articles/srp
http://www.objectmentor.com/resources/articles/lsp.pdf
http://www.objectmentor.com/resources/articles/isp.pdf
http://www.objectmentor.com/resources/articles/dip.pdf
http://www.objectmentor.com/resources/articles/ocp.pdf

Working on games? At the bottom line, there is little difference in approach to designing a Word Processor and a Game. They both require careful thought and preparation before starting otherwise you end up with very hacky and messy code base which will hinder your project's progress. At present, some of the Lua projects going on here (no offence to anyone, I know you guys are still learning) are falling in that trap, I myself have done so several times in the past as well. However, there several areas that will help you greatly in designing and building a game. One of them is Finite State Machines (FSM). This has been used for the game's structure, AI, item behaviour etc. The other skill is Abstraction which you will pick up with experience. It is basically taking an object and form it in code, from 'base' componments. Eg:

What is a bullet? It has an position in space (X, Y ,Z value), graphical representation and a velocity.

Some other bits and pieces of information
Keep up your math skills at a good level, especially areas such as Trigonometry, Algebra and Vector math. They are invaluable in programming especially game programmming. Later on, you will need to have some knowledge of matrix math when dealing with 3D scenes.

Here are some FAQs for the C++ language, Matrix math and vectors although you wont need them for a while yet:

C++ FAQ lite: http://www.parashift.com/c++-faq-lite/
Matrix Math FAQ: http://www.gamedev.net/reference/art...rticle1691.asp
Vector Math FAQ: http://www.j3d.org/matrix_faq/vectfaq_latest.html

This link is especially important for learning how to organize your files correctly in C/C++
http://www.gamedev.net/reference/articles/article1798.asp

Wiki for Games Development in general
http://gpwiki.org/

Doing a platform/jump and run game? Take a look at jnrdev
http://jnrdev.72dpiarmy.com/

Want to write a Game Engine? I recommend at least reading through these articles first and if you can, the book Game Coding Complete
http://www.gamedev.net/reference/programmi...res/enginuity1/
http://www.gamedev.net/reference/programmi...res/enginuity2/
http://www.gamedev.net/reference/programmi...res/enginuity3/
http://www.gamedev.net/reference/programmi...res/enginuity4/
http://www.gamedev.net/reference/programmi...res/enginuity5/

Learn the Standard Template Library (STL) or/and Boost. They have a number of template classes that are extremely useful such as vectors, lists and smart pointers. Abuse them.

Books
Here are a list of good books to read although they will be at an advance level so keep the list as future reference:
- Code Complete: http://www.amazon.co.uk/gp/product/0735619...ay&v=glance
- Rapid Development: http://www.amazon.co.uk/gp/product/0072850...ay&v=glance
- Pragmatic Programmer: http://www.amazon.co.uk/gp/product/0201616...ay&v=glance
- Game Coding Complete (Fantastic book, MUST READ): http://www.amazon.co.uk/gp/product/1932111...ks&v=glance
- Effective C++: http://www.amazon.co.uk/gp/product/0321334...ks&v=glance
- Design Patterns: Elements Of Reusable Object Orientated Software: http://www.amazon.co.uk/gp/product/0201633...ks&v=glance

There is a ton more information that I can pass on but I think this should keep you going for a while and you will pick up the rest as you go along.
 
When I try compile and run a sample application such as 'Hello World' the window opens for a brief second and cuts right off.

This is irritating as I'm copying the syntax near perfect! Do I have to change the settings at all? I'm starting to get really bloody annoyed.
 
(if the "return 0" thing didn't work)

I think your problem is the program is opening the window, executing, and then closing the window.

Before "return 0;" type "cin.get();" this makes the program want info from the user, so the program won't close until you enter something (so after you read "Hello World" or whatever output you have to type something (e.g. "k", "124455eae", or anything you want) and press [ENTER]. This will allow the program to finish and the window will then close.

I hope this fixes it.




EDIT>> I forgot to put in a ' ; ', Silly me. :rolleyes:
 
Fool proof Hellow worldy for windows:
Code:
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char** argv)
{
  printf("Hellow, my World.\n");
  
  system("pause");
  return 0;
}
 
Back
Top