collapse collapse

* Who's Online

  • Dot Guests: 81
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Board Stats

  • stats Total Members: 88
  • stats Total Posts: 11163
  • stats Total Topics: 1699
  • stats Total Categories: 4
  • stats Total Boards: 76
  • stats Most Online: 248

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - IonDuel

Pages: [1]
Suggestions / People To Be Inspired By
« on: January 17, 2009, 01:23:54 pm »
I think there should be a category for people to inspired by under programming, with subforums of different people such as GyroVorbis to start, And I will post their videos.  And anyone that inspires you guys should defiantly be put in their.

C++ / [Solved]undefined reference to `_WinMain@16'
« on: January 16, 2009, 10:06:47 pm »
Im getting this error.  Its for my engine... You dont want the source...  But you may know a possible cause, thanks.

C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\libmingw32.a(main.o):main.c:(.text+0x104)||undefined reference to `_WinMain@16'|

Ok, solved it by myself again.  The linking was in the wrong order.  Somehow it switched to -lSDLmain -lSDL... -lmingw32.  But -lmingw32 needs to be in the front.  So, -lmingw32 -lSDLmain -lSDL...

OpenGL / SDL Key Checking Issues
« on: January 16, 2009, 06:18:52 pm »
I created this code when I was really tired.  So, its horrible and inefficient im sure.  But if you could please tell me a shorter way to write this, possibly with a for loop.  Then also a way to check keyPresses like in BlitzBasic.  Thank you.

Code: [Select]
void IDEngine::setKeys(bool state){
        case SDLK_ESCAPE:
keys[SDLK_ESCAPE] = state;
        case SDLK_F1:
keys[SDLK_F1] = state;
        case SDLK_F2:
keys[SDLK_F2] = state;
        case SDLK_F3:
keys[SDLK_F3] = state;
        case SDLK_F4:
keys[SDLK_F4] = state;
        case SDLK_F5:
keys[SDLK_F5] = state;
        case SDLK_F6:
keys[SDLK_F6] = state;
        case SDLK_F7:
keys[SDLK_F7] = state;
        case SDLK_F8:
keys[SDLK_F8] = state;
        case SDLK_F9:
keys[SDLK_F9] = state;
        case SDLK_F10:
keys[SDLK_F10] = state;
        case SDLK_F11:
keys[SDLK_F11] = state;
        case SDLK_F12:
keys[SDLK_F12] = state;
        case SDLK_F13:
keys[SDLK_F13] = state;
        case SDLK_F14:
keys[SDLK_F14] = state;
        case SDLK_F15:
keys[SDLK_F15] = state;
        case SDLK_1:
keys[SDLK_1] = state;
        case SDLK_2:
keys[SDLK_2] = state;
        case SDLK_3:
keys[SDLK_3] = state;
        case SDLK_4:
keys[SDLK_4] = state;
case SDLK_5:
keys[SDLK_5] = state;
        case SDLK_6:
keys[SDLK_6] = state;
        case SDLK_7:
keys[SDLK_7] = state;
        case SDLK_8:
keys[SDLK_8] = state;
        case SDLK_9:
keys[SDLK_9] = state;
        case SDLK_0:
keys[SDLK_0] = state;
keys[SDLK_MINUS] = state;
keys[SDLK_EQUALS] = state;
keys[SDLK_BACKSPACE] = state;
        case SDLK_TAB:
keys[SDLK_TAB] = state;
        case SDLK_q:
keys[SDLK_q] = state;
        case SDLK_w:
keys[SDLK_w] = state;
        case SDLK_e:
keys[SDLK_e] = state;
        case SDLK_r:
keys[SDLK_r] = state;
        case SDLK_t:
keys[SDLK_t] = state;
        case SDLK_y:
keys[SDLK_y] = state;
        case SDLK_u:
keys[SDLK_u] = state;
        case SDLK_i:
keys[SDLK_i] = state;
        case SDLK_o:
keys[SDLK_o] = state;
        case SDLK_p:
keys[SDLK_p] = state;
keys[SDLK_LEFTBRACKET] = state;
keys[SDLK_RIGHTBRACKET] = state;
keys[SDLK_SLASH] = state;
keys[SDLK_CAPSLOCK] = state;
case SDLK_a:
keys[SDLK_a] = state;
case SDLK_s:
keys[SDLK_s] = state;
case SDLK_d:
keys[SDLK_d] = state;
case SDLK_f:
keys[SDLK_f] = state;
case SDLK_g:
keys[SDLK_g] = state;
case SDLK_h:
keys[SDLK_h] = state;
case SDLK_j:
keys[SDLK_j] = state;
case SDLK_k:
keys[SDLK_k] = state;
case SDLK_l:
keys[SDLK_l] = state;
keys[SDLK_SEMICOLON] = state;
keys[SDLK_QUOTE] = state;
keys[SDLK_RETURN] = state;
keys[SDLK_LSHIFT] = state;
case SDLK_z:
keys[SDLK_z] = state;
case SDLK_x:
keys[SDLK_x] = state;
case SDLK_c:
keys[SDLK_c] = state;
case SDLK_v:
keys[SDLK_v] = state;
case SDLK_b:
keys[SDLK_b] = state;
case SDLK_n:
keys[SDLK_n] = state;
case SDLK_m:
keys[SDLK_m] = state;
keys[SDLK_COMMA] = state;
keys[SDLK_PERIOD] = state;
keys[SDLK_BACKSLASH] = state;
keys[SDLK_RSHIFT] = state;
keys[SDLK_LCTRL] = state;
keys[SDLK_LALT] = state;
keys[SDLK_SPACE] = state;
keys[SDLK_RCTRL] = state;
keys[SDLK_RALT] = state;
case SDLK_UP:
keys[SDLK_UP] = state;
keys[SDLK_LEFT] = state;
keys[SDLK_RIGHT] = state;
keys[SDLK_DOWN] = state;

Project Advertisment / IonDuel Engine
« on: January 14, 2009, 09:49:39 pm »
I am now officially creating a simple 2d and 3d game engine for use by anybody personally and commercially (with permission).  It uses SDL and SDL-OpenGL.  It will use code similar to this:
Code: [Select]
#include "IDEngine.h"

IDEngine engine(800, 600, 32, false, true, false);
ISoundManager sndMan;
IMusic music("Data/7.mp3");
IFont font("Data/arial.ttf", 28);
IColor col(255, 0, 0);

int main(int argc, char *argv[]){
if(engine.isKeyDown(SDLK_ESCAPE) || engine.isButtonDown(9)){

engine.startDraw(0, 100, 100);
engine.writeString(font, col, 10, 10, "Hello there!");
return 0;

Simple yet effective.  So far I have IColor, IDEngine, IFont, IImage, IMusic, IRect, ISoundManager, ISprite, ITimer.  For input, there is currently keyboard and joystick.  If you have any suggestions I will take them into deep consideration.

Working on:
Nothing... Please give me some ideas...

General Talk / My Site
« on: January 03, 2009, 11:39:40 pm »
I finally got my site up!  With the help of adamsna of coarse!  Its exciting!  Tell me what you think?

General Talk / Good piano-ing
« on: January 02, 2009, 08:39:52 pm »
I love this song, Just thought I would share.  (Yes, it is from .hack//SIGN)

Challenges / 99 Bottles Of Beer
« on: January 02, 2009, 08:11:05 pm »
This is a site with a 99 Bottles Of Beer program written in about every programming language possible.

General Talk / Beware!
« on: January 02, 2009, 12:02:02 pm »
Hey, I just got this email, announcing someones love interest towards me.  Though I don't doubt it in all my studhood.  There seems to be a catch somewhere.  Here is the email:
From :Miss Lovett Kone.
Abidjan, Ivory Coast
Dearest One,
Please permit me to inform you of my desire of going into a relationship with you. This to the best of my knowledge will establish an everlasting relationship between me and your family. I am Lovett Kone the only daughter of the late Mr. Kone John, a devoted Christian who went on helping people but later was disappointed by his close relatives and business friends.
My father was a very wealthy cocoa merchant here in Abidjan ; the economic capital city of Ivory Coast . My father was poisoned to death by his business associates on one of their outings on a business trip. My mother as well died when I was a baby. Since then, my father took me so special before his unfortunate death that made me a complete orphan today without mother, without father and without brothers or sisters. Before the death of my father on March 2005 in a private hospital here in Abidjan he secretly called me on his bed side and told me that he has the sum of ($8,500,000) which he deposited in a suspense account in one of the prime bank here in Abidjan Cote d'Ivoire that he used my name as his only daughter in depositing the money as the next of Kin/heir.
He also explained to me that it was because of this money that he was poisoned by his business associates. He then advised that I should seek for a foreign partner in a country of my choice where I will transfer the fund into for investment project. I am honorably seeking your assistance in the following ways.
(1) To serve as My guardian and foreign trustee to enable the Bank transfer the money to you on my behalf for investment abroad, since I am only 22 years old.
(2) To make arrangement for me to come over to your country to further my education and to secure a resident permit in your country.
Furthermore, you indicate your options towards assisting me as I believe that this transaction would be concluded within the shortest period so that I will come over to your country. Upon your interest and anticipating assisting me, I look forward to you with the interest of helping me. I am assuring you of a hundred percent risk free in the course of transferring this fund for I have every legal document concerning the deposition of the money.
Thanks and God bless.
 Miss Lovett Kone.

Power up the Internet with Yahoo! Toolbar.

No virus found in this incoming message.
Checked by AVG -
Version: 8.0.176 / Virus Database: 270.10.1/1870 - Release Date: 12/31/2008 8:44 AM

Suggestions / New Forums
« on: January 02, 2009, 11:44:45 am »
Hey, So, in this topic shall be posted new forum requests.  I will start with requesting the Esoteric Programming Languages, then with subforums brainfuck and LOLCODE.  KTHXBYE

Suggestions / Instant Updates
« on: January 01, 2009, 11:06:55 pm »
It would probably be insanely hard, I dont know.  But it would be really cool if you could instantly update the "Show unread posts since last visit."  To say "Show unread posts since last visit. (10)" or however many, and 0 if none.  And you wouldn't need to refresh.  Just an idea.

Humor / Penis and Vagina song
« on: January 01, 2009, 07:47:48 pm »


Project Advertisment / 3D Artists
« on: December 31, 2008, 11:05:35 am »
Hey, Are there any 3D artists on the forum?  This isn't really a recruit (yet).  Im mainly just curious.

C++ / SOLVED: VC++ Win32 problem
« on: December 30, 2008, 08:27:21 pm »
Hey, Im trying to make a window.  My code is right (It works in Dev-C++).  But it keeps bring up this error log:
------ Build started: Project: DirectXEngine, Configuration: Debug Win32 ------
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C2146: syntax error : missing ';' before identifier 'Buffer'
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Build log was saved at "file://c:\Documents and Settings\Jameson\My Documents\Visual Studio 2008\Projects\DirectXEngine\DirectXEngine\Debug\BuildLog.htm"
DirectXEngine - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I dont want to change that "winnt.h" file.  But maybe it is linked wrong.

General Talk / Re: [1] First Assembly Program
« on: December 28, 2008, 10:27:37 pm »
In 1 minutes and 15 seconds I answered my own question.  Im sure thats pretty record breaking lol.  That would be a fun game show!  You have to ask a question and answer it before anyone else does!  Lol.

Tutorials / Irrlicht Tutorial 1 - A Screen
« on: December 28, 2008, 02:25:14 pm »
So you want to learn Irrlicht?  Start off by downloading and extracting the Irrlicht files from the Irrlicht download page here:  Then copy the files in the "lib" folder for Irrlicht into the "lib" folder for your IDE(Dev-C++, VC, Codeblocks, etc.)  Then do the same for the "include" folders.  Now, go into the "bin" folder in your Irrlicht stuff and next into your OS / compiler named folder.  That will bring you to a bunch of examples and some DLL files.  Copy Irrlicht.dll and irrKlang.dll into you C:\WINDOWS\system32 and IDEs "bin" folders.  Now you should be set to program in irrlicht.

NOTE: Dev-C++ does work with Irrlicht, but it does some weird things.  If you are using Dev-C++ remember that if it is acting very slow.

And now for the code to make yourself a blank window.

Code: [Select]
#include <irrlicht.h>                                         //Include the irrlicht header file

#pragma comment(lib, "Irrlicht.lib")                          //Include the Irrlicht library

using namespace std;                                          //Use the standard namespace

using namespace irr;                                          //Use the irr namespace

using namespace core;                                         //Use the core namespace
using namespace scene;                                        //Use the scene namespace
using namespace video;                                        //Use the video namespace
using namespace io;                                           //Use the io namespace
using namespace gui;                                          //Use the gui namespace

IrrlichtDevice *device;                                       //Init the device that handles irrlicht
IVideoDriver *driver;                                         //Init the video driver
ISceneManager *smgr;                                          //Init the scene manager
IGUIEnvironment *guienv;                                      //Init the gui environment

int main(){                                                   //Main function start
device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(800, 600), 32, false, false, false, 0);//Make a window with Direct3D9 graphics that is 800 wide and 600 high.  Not fullscreen.

driver = device->getVideoDriver();                        //Get the video driver from the device
smgr = device->getSceneManager();                         //Get the scene manager from the device
guienv = device->getGUIEnvironment();                     //Get the gui environment from the device

while(device->run()){                                     //While the program is running
if(device->isWindowActive()){                         //If the window is in focus
driver->beginScene(true, true, 0);                //Start drawing the scene with a black background
smgr->drawAll();                              //Draw everything in the scene manager
driver->draw2DRectangle(SColor(0, 255, 0, 0), rect<s32>(10, 10, 10, 50));

guienv->drawAll();                            //Draw everything in the gui environment
driver->endScene();                               //End drawing the scene
}                                                     //End the if
}                                                         //End the while loop
return 0;                                                 //Return a zero to keep the program happy
}                                                             //End the main function

Thanks for reading!

C++ / Marbles (Class Tutorial)
« on: December 27, 2008, 11:47:04 am »
Ok, so we will need to have two source files this time.  The Main.cpp file will hold our main function and the MarbleClass.cpp will hold our MarbleClass class.

Code: [Select]
#include <iostream>                                    //The usual in out library
#include <string>                                      //The string library

#include "MarbleClass.cpp"                             //Include the MarbleClass class for use

using namespace std;                                   //Standard namespace

bool running = true;                                   //Start the program running

string newColor = "";                                  //New color that is input
int newSize = 1;                                       //New size that is input

MarbleClass marble;                                    //Start up your class, it will use default settings until we set it
int marbleCount = 1;                                   //How many marbles you have

int main(int argc, char *argv[]){                      //Main function
while(running){                                    //While the program is running
cout << "Pick a new color: ";                  //Prompt for new color
cin >> newColor;                               //Gather new color

cout << "Pick a new size: ";                   //Prompt for new size
cin >> newSize;                                //Gather new size

marble.set(newColor, newSize);                 //Make a new marble

cout << "Your marble is " << marble.getColor() << " and is size " << marble.getSize() << ".\n";//This just says what your marble currently is in color and size
}                                                  //End while
return 0;                                          //You need to return an int
}                                                      //End of the main function

And MarbleClass.cpp
Code: [Select]
#include <iostream>                                    //The usual in out library
#include <string>                                      //The string library

using namespace std;                                   //Standard namespace

class MarbleClass{                                     //Start up the MarbleClass class
public:                                                //Public members, anything can access these

MarbleClass(string newColor = "black", int newSize = 1){//This is called when the class is made  It is known as a constructor and must have the same name as the class that it... constructs. The default value for newColor is "black" and the default value for newSize is 1
color = newColor;                              //Set the color to the new color
size = newSize;                                //Sets the size to the size you specified
}                                                  //End the init function

void set(string newColor, int newSize){            //This function will set the variables
color = newColor;                              //Set the color to the new color
size = newSize;                                //Sets the size to the size you specified
}                                                  //Ends the set() function

string getColor(){                                 //This function will get the color of the marble
return color;                                  //This returns the color
}                                                  //End the getColor() function

int getSize(){                                     //This function will get the size of the marble
return size;                                   //This returns the size
}                                                  //End the getSize()

private:                                               //Private members, only the class its self can access these
string color;                                      //Store the color name
int size;                                          //Store the size
};                                                     //End the class  (DONT FOREGET THE SEMICOLON, IT ENDS THE CLASS)

As you run the program it will ask your for a new color (type in text) and for a new size (type in a number).  Pretty simple.  Try adding another marble, and change the values of both of them.

Thanks for reading.

C++ / Guessing Game Tutorial
« on: December 27, 2008, 12:42:34 am »
Here is a simple guessing game, explained as well as I could.

And voila!
Code: [Select]
#include <iostream>                            //Include the in out stream stuff
#include <time.h>                              //Include the time library

using namespace std;                           //Use the standard namespace

bool running = true;                           //Start off the game running
int number;                                    //The number that you are trying to guess
int guess;                                     //To store your guesses
int guessCount;                                //How many guesses it take

int main(int argc, char *argv[]){              //The main function
srand(time(NULL));                         //Make sure the random is actually random
number = rand() % 100 + 1;                 //The number = a random number from 1 to 100

while(running){                            //Main loop start
cout << "I dare you to guess: ";       //Ask the question
cin >> guess;                          //Get the response
guessCount++;                          //Increment the guess counts by 1

if(guess == number){                   //if you guess the number
cout << "You win after " << guessCount << " tries!\n";//"You win!"
running = false;                   //End the game
}else if(guess > number){              //If you guessed too high
cout << "Too high...\n";           //"Too high..."
}else if(guess < number){              //If you guessed too low
cout << "Too low...\n";            //"Too low..."
}                                      //End if
}                                          //End main loop
cout << "Press any key to exit...\n";      //Prompting for any key
getchar();                                 //A better way to wait for a key
getchar();                                 //It only seems to work if you have two...
return 0;                                  //Return an int to make the program happy
}                                              //End the main function

Sorry about the weird formating again... Stupid issues...

Thanks, Jameson.

C++ / TicTacToe Tutorial
« on: December 26, 2008, 11:24:00 pm »
Ok, the comments should explain everything.  If someone could tell me how to clear the screen without using a system call that would be much appreciated!

Here it is!
Code: [Select]
#include <iostream>                              //Include the In and Out stuff
#include <string>                                //Include the string datatype

using namespace std;                             //Use the standard namespace

bool running = true;                             //Start the game running

int gameState = 1;                               //Keep track of the game state

int turn = 1;                                    //Keep track of whos turn it is
int choice[10];                                  //The array of the ownership of the squares
int input;                                       //This will store the number input

int main(int argc, char *argv[]){                //Start the main function
system("color B");                           //Make it all light blue
while(running){                              //Start the main loop
system("cls");                           //Clear the screen

if(gameState == 1){                      //If in the menu
cout << "Press \"1\" to play and \"0\" at any time to quit: ";//Tell people what is what
cin >> input;                        //Get the input
if(input == 1){                      //If input was 1
gameState = 2;                   //go to the game
}else if(input == 0){                //else if input was 0
running = false;                 //Stop the game
}                                    //End if
}else if(gameState == 2){
cout << "Player " << turn << "'s turn.\n";//Verify whos turn it is

for(int i = 1; i <= 9; i++){         //For loop that runs through each box
cout << choice[i];               //Write who owns the current box
if(i == 3 || i == 6 || i == 9){  //If it is at the 3rd, 6th, or 9th box
cout << "\n";                //Start a new line
}else{                           //Otherwise
cout << "|";                 //Draw a line
}                                //End if
}                                    //End for loop

cout << "Pick a spot: ";             //Ask for the spot
cin >> input;                        //Put the answer into the variable "input"
for(int i = 1; i <= 9; i++){         //Start the for loop to check for input
if(input == i && choice[i] == 0){//if input = the box number and if the box is empty
choice[i] = turn;            //change the box to the play that chose it
}                                //End the if
}                                    //End the for loop
if(input == 0){                      //If you clicked 0
running = false;                 //End the game
}                                    //End that if

if(turn == 1){                       //If its player 1s turn
turn = 2;                        //Change to player 2
}else if(turn == 2){                 //If its player 2s turn
turn = 1;                        //Change to player 1
}                                    //End if

//The follow will check each line to see if somebody won
//Feel free to copy and paste instead of typing all this out...
if(choice[1] == choice[2] && choice[2] == choice[3] && choice[1] != 0){
cout << "Player " << choice[1] << " wins!\n"; running = false;
}else if(choice[4] == choice[5] && choice[5] == choice[6] && choice[4] != 0){
cout << "Player " << choice[4] << " wins!\n"; running = false;
}else if(choice[7] == choice[8] && choice[8] == choice[9] && choice[7] != 0){
cout << "Player " << choice[7] << " wins!\n"; running = false;
}else if(choice[1] == choice[4] && choice[4] == choice[7] && choice[1] != 0){
cout << "Player " << choice[1] << " wins!\n"; running = false;
}else if(choice[2] == choice[5] && choice[5] == choice[8] && choice[2] != 0){
cout << "Player " << choice[2] << " wins!\n"; running = false;
}else if(choice[3] == choice[6] && choice[6] == choice[9] && choice[3] != 0){
cout << "Player " << choice[3] << " wins!\n"; running = false;
}else if(choice[1] == choice[5] && choice[5] == choice[9] && choice[1] != 0){
cout << "Player " << choice[1] << " wins!\n"; running = false;
}else if(choice[3] == choice[5] && choice[5] == choice[7] && choice[3] != 0){
cout << "Player " << choice[3] << " wins!\n"; running = false;
}                                        //End the if statement
}                                            //End the main loop

cout << "Press any number to quit: ";        //Prompt the user to exit
input = 0;                                   //Set input to 0
while(input == 0){                           //Wait for any key
cin >> input;                            //Check for input
}                                            //End while loop
return 0;                                    //Return 0, make the program happy
}                                                //End of main function

Everything will be aligned better in your IDE.

Thanks!  Jameson.

Introductions / IonDuel
« on: December 26, 2008, 08:45:54 pm »
Hello again to everyone!

Im back!  I used to be in the old forum, a high contributer if you will.  And now that the forum is stable I've decided to come back!

So, about me... I've been programming since I was about 7, which would be in 1999.  7 + (currentYear - 1999) = my age.  Which as of July 2, 2008 is 15.  I use Microsoft Visual C++ Express 2008, I would recommend it as well.  Dev-C++ can sometimes have issues, but it is also fairly good.

I started programming and game devving with Game Maker.  Which also helped me with my reading at the time.  Then I later moved into Visual Basic 6 from a disk that my uncle gave me.  Then when I was 13, our class had to interview someone from the industry that we were researching.  I of course chose programming, so the person I interviewed showed me a bit of c++ and explained why it was more important and better then VB.  So, I started learning C++.  It took a while before I started using the SDL library, then I backtracked to the Allegro game library, and now I currently use the IrrLicht 3d engine.

Im fluent in C++, C#, BASIC, TI-BASIC, Java, HTML, XHTML, VB5 / 6.  As well as some the libraries listed about in C++ (SDL, Allegro, IrrLicht).

Feel free to ask questions, and thanks for reading!

-Jameson (IonDuel)

C++ / Intro To C++ Tutorial
« on: December 26, 2008, 01:56:35 pm »
So, you want to learn C++.  There a few things you need to do before your making the next hit blockbuster game.  Like downloading your IDE(Integrated Development Environment) and learning the basics.  I plan to teach those things here.

---------------Table Of Contents----------------
1. Download Dev-C++
2. "Hello World!" Your first program
3. Data types
4. Building a main loop and if / else statements
5. For loops to generate lots of numbers, in order!
6. The end.

1. Download Dev-C++

I find Dev-C++ is the easiest compiler to use, well out of the ones I've tried (and I've tried quite a few).

You can download the newest version from here.
Scroll down the where it says Downloads in big bold letters.  Then pick your download of chose, I suggest getting the current Dev-C++ with Mingw/GCC binary package.

Now, install that.  While I wait, I will grab a drink.

Ok, back.  Now to move on to making your very first C++ program.

2. "Hello World!" Your first program

Your first program.  Heres an overview of what it does.  You start it, see a black box (The command console).  Inside that it says "Hello World!".  Click any button and it will shut down.

Now how to achieve this.  Start a new project by going File->New->Project in Dev-C++.  A list of the currently installed templates is being viewed.  Client "Empty Project" and type in a name.  Something like "Hello World"  or "Hello World project".  Then make sure "C++ Project" is filled in.  Click "Ok" and save it to a new directory, again with the name "Hello World" or such, so you know where it is.  (SIDE NOTE: I suggest making a new folder called "Files" or "Apps" or "Projects", for organization sake).

Almost down the coding.  But first, as your probably aware.  We have no files in our project.  To fix this problem, click File->New->Source file.  And "Yes" you want to add it to the project.  Save this to the same directory as your project file (.dev) with the name of "Main.cpp" or whatever you want really.

Now into the code!  You should rewrite this into your own project, but copy and pasting will work.

Code: [Select]
#include <iostream>           //Include In and Out streams

using namespace std;          //Standard namespace, prevent lots of writing.

int main(){                   //The program will start executing code here
    cout << "Hello world!\n"; //Print "Hello World!" to the screen, and then move the the next line.
    system("PAUSE");          //Wait for the a key input and display "Press any key to continue...";
    return 0;                 //We need to return an integer.  So here it is!
}                             //Ending the int main(){

Hopefully I explained that well enough.  All of the "//"'s after each line is a comment, so programmers can track whats happening.  The compiler just skips them.

And onward my friends!  To lesson 3!

3. Data types

Ok, we will start this off be creating a new project.  And again add a "Main.cpp" source file to your project.

This time.  We will create variable that will hold a number and a variable that will hold words.  The variables that hold numbers can be declared as "int", "float", "double", etc.  And to hold a word, we declare "char *".  This will make more sense when we get to the code.

Speaking of getting to the code, let me explain it.  What we will do in the tutorial is declare an int and a char.  Then we will ask for a our age using the cin function.  Then we will ask for our name.  Then once we have our information, we will display it.  Again using the cout function.

The code is as follows:

Code: [Select]
#include <iostream>           //Include In and Out streams

using namespace std;          //Standard namespace, prevent lots of writing.

int Age;                      //Declaring the Age integer (NEW)
char Name[10];                   //Declaring the Name char (it can be 10 characters long) (NEW)

int main(){                   //The program will start executing code here
    cout << "How old are you? : "; //Prompt for your age (NEW)
    cin >> Age;               //Save the input to the Age integer (NEW)
    cout << "What is your name? : "; //Prompt for your name (NEW)
    cin >> Name;              //Save the input to the Name char (NEW)
    cout << Name << " you are " << Age << " years old.\n"; //Print The Name input, " you are " the Age input, " years old." (NEW)
    system("PAUSE");          //Wait for the a key input and display "Press any key to continue...";
    return 0;                 //We need to return an integer.  So here it is!
}                             //Ending the int main(){

Should be easy to follow so far.  But it only runs once.  The quits.  How about we make it go forever? Into chapter 4 you must search!

4. Building a main loop and if / else statements

This builds almost completely off of the last tutorial.  The only difference is a variable and a while loop.  A while loop makes it so, whenever the equation inside is true, it will do whatever is inside the while loop.  For example (don't type this into your code.):
Code: [Select]
while(1){                //This runs forever.
     cout << "Still running!";

bool Running = true;
while(Running){                //This runs until Running equals false, we will use this.
    cout << "Running is still true!";

But before we get into it.  You saw bool in the past code.  Bool?  You ask.  It stands for Boolean, its a data type that can be true or false.  Which is perfect for our new program.  And for the code.  Make sure to make a new project, and add the "Main.cpp" file.

Code: [Select]
#include <iostream>           //Include In and Out streams

using namespace std;          //Standard namespace, prevent lots of writing.

int Age;                      //Declaring the Age integer
char Name[10];                //Declaring the Name char (it can be 10 characters long)

bool Running = true;          //Make the bool Running start off true (NEW)

int main(){                   //The program will start executing code here
    while(Running){           //Start our main loop (NEW)
        Age = 0;              //Reset the Age and (NEW)
        Name = " ";           //Name variable (NEW)
        cout << "How old are you? : "; //Prompt for your age
        cin >> Age;               //Save the input to the Age integer
        cout << "What is your name? : "; //Prompt for your name
        cin >> Name;              //Save the input to the Name char
        cout << Name << " you are " << Age << " years old.\n"; //Print The Name input, " you are " the Age input, " years old."
        if(Age == 666 || Name == "asdf"){   //If your age is 666 OR (||) your name is asdf... (NEW)
            Running = false;                //We end the program. (NEW)
        }else{                     //Check what to do, if the if statement was false (NEW)
            cout << "Im still running!";   //Just to remind us (NEW)
        }                     //End the if statement (NEW)
        system("PAUSE");          //Wait for the a key input and display "Press any key to continue...";
    }                         //End our main loop (NEW)
    return 0;                 //We need to return an integer.  So here it is!
}                             //Ending the int main(){

Yes!  The program loops through!  Now lets make a list of numbers from 1 to 100 without typing them!  Impossible?  I think not!

5. For loops to generate lots of numbers, in order!

A for loop follows this formula (again, don't add this little bit of code here).

Code: [Select]
for(start point; when to stop; how much to increment){

The start point is just a variable that will be incrementing (or decrementing) until it reaches the when to stop point.  New project... Blah blah blah.

Time for the fifth and probably final lesson in this tutorial!

Code: [Select]
#include <iostream>           //Include In and Out streams

using namespace std;          //Standard namespace, prevent lots of writing.

int main(){                   //The program will start executing code here
    for(int CurrentNumber = 0; CurrentNumber <= 100; CurrentNumber++){  //CurrentNumber will grow by one each time we finish this loop. Until we get to 100 of coarse. (NEW)
        cout << "Current Number is... " << CurrentNumber << "\n";   //Print out Current Number is... Then the number we are on (NEW)
    }                         //End our for loop (NEW)
    system("PAUSE");          //Wait for the a key input and display "Press any key to continue...";
    return 0;                 //We need to return an integer.  So here it is!
}                             //Ending the int main(){

And thats how to make from 0 to 100 without typing anything.  This could be used in a more advanced way, such as a tile engine.  Read this code, no need to write it.  (It won't work.)

Code: [Select]
for(int x = 0; x <= 50; x++){
    for(int y = 0; y <= 50; y++){
        DrawTile(x * 32, y * 32, grasstile);  //Loop through your x's and y's and draw a tile at each location 32 pixels away from eachother.

6. The end.

First I want to say thank you for reading!  This has been fun for me, and I hope when you gain the abilities to teach others you have a good time doing it as well.  Keep learning, I will keep posting!  If you have any questions, please feel free to ask them!


Pages: [1]


* Search

* Recent Posts

Image Comparison by Shishka
[May 15, 2017, 01:18:02 pm]

Re: srchub - free source code hosting by Nathan
[December 14, 2015, 11:37:02 pm]

Re: srchub - free source code hosting by Celestialkey
[November 27, 2015, 08:51:42 am]

Updates by Nathan
[October 30, 2015, 08:27:36 pm]

Re: Client-Server Messaging by Nathan
[October 25, 2015, 05:48:57 pm]