sfuo 111 Practically a Master Poster

The values that get passed into that function will be pixel coordinates then the functions would call gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] -y), 1.0, 1.0, viewport); where 1.0 and 1.0 is the size I chose of the selection region.


Not sure if you know anything about selecting objects in OpenGL but I managed to make this from looking around at websites and using the Red and Blue books.

This is the code I have for selection.

//in my windows message area
case WM_LBUTTONDOWN:
	MouseFunc(SF_LEFT_BUTTON, SF_DOWN, LOWORD(lParam), HIWORD(lParam));
	break;

//functions
void MouseFunc( int button, int state, int x, int y )
{
	if( button == SF_LEFT_BUTTON && state == SF_UP )
		leftMouseDown = false;

	if( button == SF_RIGHT_BUTTON && state == SF_UP )
		rightMouseDown = false;

	if( button == SF_LEFT_BUTTON && state == SF_DOWN )
		leftMouseDown = true;

	if( !leftMouseDown || rightMouseDown )
		return;

	GLuint BUFSIZE = 512;
	GLuint selectBuf[BUFSIZE];
	GLint hits;
	GLint viewport[4];

	glGetIntegerv(GL_VIEWPORT, viewport);

	glSelectBuffer(BUFSIZE, selectBuf);

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();

		glRenderMode(GL_SELECT);
		glInitNames();
		glPushName(0);

		glLoadIdentity();

		gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] -y), 1.0, 1.0, viewport);

		ORTHO_WIDTH = ORTHO_HEIGHT*((GLdouble)WINDOW_WIDTH/(GLdouble)WINDOW_HEIGHT);

		glOrtho(0, ORTHO_WIDTH, 0, ORTHO_HEIGHT, -1, 20);

		glMatrixMode(GL_MODELVIEW);

		glPushMatrix();

			//DrawFunc(GL_SELECT);

			hits = glRenderMode(GL_RENDER);

		glPopMatrix();

		glMatrixMode(GL_PROJECTION);

	glPopMatrix();

	glMatrixMode(GL_MODELVIEW);

	glFlush();

	objectSelected = ProcessHits(hits, selectBuf);
	if( objectSelected >= 0 )
		cout << "selected object: " << objectSelected << endl;
}

GLint ProcessHits(GLint hits, GLuint buffer[])
{
	if( hits == 0 )
		return -1;

	GLuint lowestDepth = buffer[1];
	GLint selectedObject = buffer[3];

	for( sui i = 1; i < hits; i++ )
	{
		if(buffer[(i*4)+1] < lowestDepth)
		{
			lowestDepth …
sfuo 111 Practically a Master Poster

Just need to make a text file called textin.txt with your words and put it in the same directory as your .exe file.

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    string line; //to hold the lines read from textin.txt
    ifstream in("textin.txt");
    ofstream out("textout.txt");
    while ( getline(in, line) )
        out << line << ", " << line.length() << endl; //output the word and the length of the word
    out.close(); //after the loop close both files
    in.close();
    return 0;
}
sfuo 111 Practically a Master Poster

Oh alright then it was that its missing the C++ folder under include because I remember trying to find that and to get it I had to download MinGW. I'm still kind of confused about that.

sfuo 111 Practically a Master Poster

Yeah it is annoying because the new version of C::B doesn't come with MinGW. Just go to the MinGW website and download the latest version and drop it in your C::B directory.

sfuo 111 Practically a Master Poster

Nothing you posted there shows the name of your window handle or any other information I need.

I have never used .NET so I'm not sure if you can use GetClientRect(hWnd, windowRect); where hWnd is the handle for the window and windowRect is a RECT structure that will hold the left top right and bottom coordinates of the window.

sfuo 111 Practically a Master Poster

Say your drawing space is 500 by 500 pixels. You want your coordinate system to be 10 by 10. So you would take 500 (x pixels) and divide it by 10 (x units) and that means that for every 1 unit you have 50 pixels on the x axis. Do the same thing for the y axis.

Then you can make a function that takes in your unit coordinates and transfers them into pixels.

void Drawing(int x1, int y1, int x2, int y2, DRAWINGTYPE graphicsObject, PENTYPE pen)
{
	graphicsObject.DrawLine( pen, (drawAreaWidth/myUnitsWidth)*x1, (drawAreaHeight/myUnitsHeight)*y1, (drawAreaWidth/myUnitsWidth)*x2, (drawAreaHeight/myUnitsHeight)*y2 );
}

If you were to make your graphicsObject and pen variables global then you wouldn't have to pass them into the function.

DRAWINGTYPE and PENTYPE are placeholders for whatever they are actually called since I have no clue what they are.

sfuo 111 Practically a Master Poster

It's small because its using pixel coordinates. If you want to use a custom coordinate system you will have to get the size of the drawing area (in pixels) then you pick how many units you want across the drawing area and then in your drawing function you convert your units back into pixels so it can draw to scale.

sfuo 111 Practically a Master Poster

Isn't that drawing from the point (395,150) to (250, 150)?

I've never used this before but if you were to make a 3, 4 ,5 triangle you could probably just go

graphicsObject->DrawLine( coloredPen, 200, 150, 200, 190 );
graphicsObject->DrawLine( coloredPen, 200, 190, 230, 190 );
graphicsObject->DrawLine( coloredPen, 230, 190, 200, 150 );
sfuo 111 Practically a Master Poster

So far I have only seen GL_PROJECTION and GL_MODELVIEW being used but I looked up the function and you can have GL_TEXTURE and GL_COLOR as parameters. No idea what the others do but OpenGL has documentation online so for the most part you can just google the function name.

sfuo 111 Practically a Master Poster

In gluPerspective() the 60 is the angle of viewing if you think about your eyes you have a limited field of vision I'm not 100% sure what angle we can see at but most examples that use perspective use 60 (from what I've seen at least). For the type casting I'm pretty sure I tried it without casting it as a GLsizei and I got a warning so I just cast it to the right type.

I'm not too sure what glutInit() does but if there is an open source version of glut (freeglut) that you can check to see what goes on in that function but it will just be a general initialization that acts based on your OS (GLUT is multi-platform). As for my Init() function I use this to set up all the OpenGL state variables (ie depth alpha lighting materials) and maybe assign some objects values when I'm testing since it gets called right at the start.

sfuo 111 Practically a Master Poster

This sets up the viewport (part of the window that will get rendered onto)
You can have more than one viewport but for this we are using one.

glViewport(0, 0, (GLsizei) WINDOW_WIDTH, (GLsizei) WINDOW_HEIGHT);

This sets up the perspective and near far distances (anything drawn 1 to 20 units from the camera will be seen, anything else is not drawn. The camera is also positioned.

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(60, (GLfloat) WINDOW_WIDTH/ (GLfloat) WINDOW_HEIGHT, 1, 20);

glTranslatef(0, 0, -10); //move camera back 10 units from the origin (0, 0, 0)

This part now effects the world that you draw.

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, 0); //moves the objects by what you set it to
sfuo 111 Practically a Master Poster

The alutInit() thing is a useless line because its for ALUT the sound equivalent of GLUT so I didn't mean to include that.

An easy way to think of it is that the GL_PROJECTION matrix is the "camera" and GL_MODELVIEW is the "world" for what you are doing you can move either thing around but if you were going to make a game you would want your camera to move around in the world not the world move around your camera. This is a really basic description of it but its how I thought of it until I played with it more and figured out how stuff works.

The viewport is the portion of the screen that is going to get rendered onto. So this one renders from 0, 0 (the bottom left) to 800, 600 or whatever it gets changed to by the Reshape function.

One thing you might have noticed about GLUT is that it hogs your CPU usage with all its overhead so if you really like using OpenGL I suggest after a while you move on to a WinAPI structure instead of the GLUT one. I would suggest NeHe's but I really hate his tutorials because they are super old and are pretty confusing because of the lack of telling you what is going on.

sfuo 111 Practically a Master Poster

I would test this code out but I do not have glut on this computer.

The main issue that you have is that you are not setting up your view port projection matrix and model matrix.

#include <windows.h>

#include <gl/gl.h>
#include <gl/glut.h>
#include <math.h>

typedef struct
{
	float x;
	float y;
} CIRCLE;

CIRCLE circle;

int WINDOW_HEIGHT = 800, WINDOW_WIDTH = 600;

void init()
{
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glShadeModel(GL_SMOOTH);

	glEnable(GL_DEPTH_TEST);
}

void DrawCircle()
{
	glViewport(0, 0, (GLsizei) WINDOW_WIDTH, (GLsizei) WINDOW_HEIGHT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	
	gluPerspective(60, (GLfloat) WINDOW_WIDTH/ (GLfloat) WINDOW_HEIGHT, 1, 20);
	
	glTranslatef(0, 0, -10);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//objects
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glPushMatrix();
		glTranslatef( 0.0, 0.0, 0.0 );
		int k = 5, r = 5, h = 5;
		glBegin(GL_LINES);
			for (int i = 0; i < 180; i++)
			{
				circle.x = r*cos(i) - h;
				circle.y = r*sin(i) + k;

				glVertex3f((circle.x +k), (circle.y - h), 0);

				circle.x = r*cos(i + 0.1) - h;
				circle.y = r*sin(i + 0.1) + k;

				glVertex3f((circle.x +k), (circle.y - h), 0);
			}
		glEnd();
	glPopMatrix();
	glutSwapBuffers();
}

void Reshape(int w, int h)
{
	WINDOW_WIDTH = w;
	WINDOW_HEIGHT = h;
}

int main(int argc, char *argv[])
{
	alutInit(NULL, 0);
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(800, 600);
	glutCreateWindow("Simple Circle");
	
	init();
	
	glutDisplayFunc(DrawCircle);
	glutReshapeFunc(Reshape);
	glutMainLoop();
	
    return 0;
}
ticktock commented: Very very helpful :D +1
sfuo 111 Practically a Master Poster

I found an old project of mine that uses GLUT. I'll grab out the stuff that you need just gimme a few min.

sfuo 111 Practically a Master Poster

I stopped using GLUT a while ago but I'm pretty sure you have to set up the projection matrix and all that still.

void DrawCircle(void)
{
	glViewport(0, 0, (GLsizei) WINDOW_WIDTH, (GLsizei) WINDOW_HEIGHT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	gluPerspective(60, (GLfloat) WINDOW_WIDTH/ (GLfloat) WINDOW_HEIGHT, 0.1, 60.0);
	
	glTranslatef(0.0, 0.0, -10); //move camera back 10 units (so you can see what you are drawing)

	glMatrixMode(GL_MODELVIEW);

	glLoadIdentity();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();
		glPushMatrix();
			int k = 5, r = 5, h = 5;
    			glBegin(GL_LINES);
    		
				for (int i = 0; i < 180; i++)
				{
					circle.x = r*cos(i) - h;
					circle.y = r*sin(i) + k;
	
					glVertex3f((circle.x +k), (circle.y - h), 0);

					circle.x = r*cos(i + 0.1) - h;
					circle.y = r*sin(i + 0.1) + k;

					glVertex3f((circle.x +k), (circle.y - h), 0);
				}
    			glEnd();
		glPopMatrix();
	glPopMatrix();
}

Try this out and if it doesn't work I'll look into it a bit more since I pulled this outta one of my OpenGL projects that don't use GLUT.

sfuo 111 Practically a Master Poster

Pretty much what happens is that two's reference gets stored into opp when it gets passed into the function Fight() and when you modify opp it directly changes two because points to the place in memory where two is located. If you were to not pass by reference (pass by value) instead of taking storing the reference of two it now just stores the value and whatever you do to that value will not effect the original variable (in this case two).

In the case we have opp pretty much becomes two and anything you do to it will change two directly.

I know I typed a bunch of stuff that could probably be summarized in a few lines but I hope this clears it up a bit.

sfuo 111 Practically a Master Poster

I wrote out your code a bit cleaner and included a constructor to remove some of the clutter in main(). I also added a few comments saying briefly what is going on but for the most part I kept what you had.

#include <iostream>

using namespace std;

class Player
{
	string name;
	int hp, dmg, playerNum;

	public:

	Player(){}; //default constructor
	Player( int, int, int ); //make a constructor so you can assign health dmg and playerNum right away

	void SetName();
	void GetName();

	void GetStats();

	void Fight( Player& ); //take in the reference of the Player so you can modify their hp
};

Player::Player( int health, int damage, int num )
{
	hp = health;
	dmg = damage;
	playerNum = num;
}

void Player::SetName()
{
	cout << "Please enter Player " << playerNum << "'s username:\t";
	cin >> name;
	cout << endl;
}

void Player::GetName()
{
	cout << "Player " << playerNum << " is:\t" << name << endl;
	cin.get();
}

void Player::GetStats()
{
	cout << "Player " << playerNum << "'s stats are:" << endl;
	cout << "HP: " << hp << " DMG: " << dmg << endl << endl;
}

void Player::Fight( Player &opp )
{
	opp.hp -= dmg;
	cout << "Player " << playerNum << " is attacking player " << opp.playerNum << endl;
	cout << "Player " << playerNum << " delt " << dmg << " damage!" << endl << endl;
}

int main()
{
	Player one(50, 10, 1), two(100, 5, 2); //hp, dmg, …
sfuo 111 Practically a Master Poster

When you say two different objects same class do you mean

myClass obj1;
myClass obj2;

or are they both built off the same class with inheritance?

If you have some code showing what you have tried that would be helpful.

sfuo 111 Practically a Master Poster

Lots of your code did nothing because it was incorrect. I would just use floats because if there are no decimals in the result (ie 5+5 = 10) it will output 10 not 10.0. I used class operators in this but if you want to keep with with pass by reference look at the bottom of this post.

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

class Calculator {
	float total;

	public:
	Calculator( float in )
	{
		total = in;
	}

	void operator+( float in )
	{
		total += in;
	}

	void operator-( float in )
	{
		total -= in;
	}

	void operator*( float in )
	{
		total *= in;
	}

	void operator/( float in )
	{
		total /= in;
	}

	float GetTotal()
	{
		return total;
	}
};

int main()
{
	Calculator calc;
	float input;
	char op;

	cout << "Hello, this is a running total calculator. You can add \"+\", subtract \"-\", " << endl;
	cout << "multiply \"*\", and divide \"/\". To work this calculator you enter a number " << endl;
	cout << "then press [Enter]. You then you enter the operand, \"+,-,*,/\" and [Enter]." <<endl;
	cout << "continue this process until you have enter your last number. To get the total, " << endl;
	cout << "press \"=\". The functions will work like this: 8+2-4*6/3=12 NOT 8+2-4*6/3=2." <<endl;
	cout << "To quit the program, enter \"Q\". Have fun." << endl;

	cout << ">";
	cin >> input;

	Calculator calc( input ); //sets the inital value of the calculator

	cout …
sfuo 111 Practically a Master Poster

Not 100% sure why you are using an array to store your character since you are only using 1. Also when you make an array char answer[1]; that means that it has a size of 1 and it starts at 0 so you would use it like if( answer[0] == 'y' ) .

Also you have answer being declared multiple times through your code when you only have to do it once as long as it is being used in a scope (not sure if this is the right word) lower than the one it was declared in.

For example

int main()
{
	char a = 'a'; //a is defined in all of the main() function but no where outside of it

	if( a == 'a' )
	{
		char b = 'b'; //b is only defined within this scope
	}

	if( a != b ) //b is not defined in this scope
	{
		char a; //a is already defined so this should give an error
		a = 'b';
	}

	return 0;
}
Clinton Portis commented: good clarification +6
sfuo 111 Practically a Master Poster

Just noticed that you aren't using OpenGL sorry, I had no idea what XNA was until I looked it up just now.

sfuo 111 Practically a Master Poster

For the camera I would move the camera to the right x y z position and then rotate it to look at the rubik's cube.

The way I calculated that is

GLfloat _r = 10; //the radius (distance) from the centre of the cube
GLfloat _d; //used to calculate the x and z offset from the centre of the cube

GLfloat _xrot, _yrot; //x and y rotation of the camera
GLfloat _xpos, _ypos, _zpos; //x y and z position of the camera

GLfloat sine[360], cosine[360]; //sine and cosine take lots of processing power to calculate so just store them
for(int i = 0; i < 360; i++ )
{
	sine[i] = sin(i*PI/180);
	cosine[i] = cos(i*PI/180);
}
//calculates the position of the camera based on xrot and yrot
_d = _r*cosine[(int)_xrot]; //gets the adjacent side of the _xrot triangle 
_xpos = (_d*sine[(int)_yrot]) + cubeXPos; //cubeXPos is where you have the cube
_ypos = (_r*sine[(int)_xrot]) + cubeYPos;
_zpos = (_d*cosine[(int)_yrot]) +cubeZPos;

//in your drawing code (glMatrixMode(GL_PROJECTION))
//rotate first then translate otherwise you will get a different result
glRotatef(_xrot, 1.0, 0.0, 0.0);
glRotatef(-_yrot, 0.0, 1.0, 0.0);
glTranslatef(-_xpos, -_ypos, -_zpos);

Now for the "units" in the rubik's cube I would make some form of array to keep track of the position of each cube so you can swap them when doing your row/col rotations because if you spin a row then spin the column it will mess up the cube and will not give you the result you want.

So swap the …

sfuo 111 Practically a Master Poster

I would move the camera around when you press the arrow keys and rotate the objects around for when they get turned.

I was making a rubik's cube and came across the same problems because if you turn the cube 90 deg on the y axis then when you rotate it on the x axis it looks like the z axis moves because of where you are viewing from.

So what I would do is move the camera around the cube using x rotation and y rotations on its axis and instead of using rotate to move it use glTranslate based on the angles x and y are at.

sfuo 111 Practically a Master Poster

I used 6 for numerator and 1 for denominator and it was crashing because it was trying to divide by 0 when the if statement was not closed because 6 can never go into 1 because he has it stop at 2.

sfuo 111 Practically a Master Poster

This is what I noticed when quickly going through your code.

void AddItem(vector <Inventory> &MyInventory, unsigned &key, int &i) { //change it to &MyInventory instead of *MyInventory since you are going to be changing it like the variable i
//this means just pass it in normally and not by reference
// i = number of elements in the item
	MyInventory[i].ItemName = "Blah";
	MyInventory[i].ItemQty = 3;
	MyInventory[i].ItemPrice = 3.50;
	i++;

	ClearScreen();
	UpdateScreen(key);
}
sfuo 111 Practically a Master Poster

I'm not 100% sure why (5/9) is having problems displaying as a double but that is why you are getting a bunch of zeros.

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    float cel = 0;
	cout << setprecision(1) << fixed; //sets 1 decimal place (fixed makes it decimals instead of digits)
    cout << "Fahrenheit\tCelsius" << endl;
	for( int i = 0; i <= 200; i += 20 ) //not sure why you had a bunch of for loops when you can use 1
	{
		cel = (5.0/9.0)*double(i-32); //could cast 5 and 9 as doubles or just make them doubles like I did
		cout << i << "\t\t" << cel << endl;
	}
    return 0;
}
sfuo 111 Practically a Master Poster

The big problem other than how you are trying to initialize your variables would be the fact that it is dividing by zero. I commented the code where it was wrong.

void Rational::reduction()
{
	int largest = numerator > denominator ? numerator : denominator;
	int gcd = 0;
	for(int loop = largest; loop >= 2; loop--)
		if(numerator % loop == 0 && denominator % loop == 0)
			gcd = loop;
   	else if(gcd != 0)
	{
		numerator /= gcd;
		denominator /= gcd; //problem was here because this if statement was not in brackets (was always dividing by gcd at the end and if it was reduced then it was divided by zero)
	{
}
sfuo 111 Practically a Master Poster

You can do

int jim = (int)sean[0];
cout << dec << jim << endl;

Notice that when you use cout << hex; all numbers outputted after that will be in hex so you have to type cout << dec; to convert back to decimal base.

sfuo 111 Practically a Master Poster

This is what he was trying to do and it was giving him an error.

#include <iostream>

using namespace std;

int *sean; //declaring variable
sean = new int; //cant assign out of a function without declaring at the same time

int main()
{
	//int *sean = new int;
    return 0;
}
sfuo 111 Practically a Master Poster

The error you are asking about is not just for dynamic memory it is for any time you try to assign outside of a function.

You can declare outside of functions like int *sean = new int; but sean = new int; will give you an error because you are not declaring assigning the variable and declaring at the same time.

sfuo 111 Practically a Master Poster

Graphics are just blocks of data that get read in by code and then get displayed using libraries like OpenGL or DirectX or what ever else you choose to use.

If you were to do something with graphics I would suggest just making a box that is colored through the code (ie glColor3f(r, g, b) ) then once you figure that out and understand whats going on, try to use texture mapping bringing in images.

Not sure if you mean graphics as in jpg bmp or tga files or graphics like drawing a box on the screen in general.

sfuo 111 Practically a Master Poster

This is a really easy way to do it. Might be an easier/better way but this is what I put together in a few mins.

#include <iostream>
#include <string>

using namespace std;

int main()
{
	string sean = "hello2";
	cout << sean << endl;

	for( unsigned int i = 0; i < sean.length(); i++ )
		cout << (int)sean[i] << " ";
	cout << endl;
	for( unsigned int i = 0; i < sean.length(); i++ )
		cout << hex << (int)sean[i] << " ";
    cout << endl;
	return 0;
}
sfuo 111 Practically a Master Poster

First question is have you even made a 2D game before?

SDL is "good" because it makes the window, sets pfd, handles keyboard/mouse input and a few other things but I really disliked how you had to carry 50 dll files around with it just so you could have sound and textures. I found it really useful to start out with because instead of spending time learning how to make a window and do handling you are able to focus on figuring out how to make a game.

The next step I took was going to GLUT. It has many similarities to SDL with the window making and handling but with GLUT you learn how to draw with OpenGL functions and you actually learn lots more because when you break off GLUT and go WINAPI and OpenGL (if you use windows) then all you need to know is how to set up the window and manage the message loop.

I would start with a 2D game with GLUT just because SDL was good starter but the stuff I was able to transfer over to OpenGL was just the logic programming since they are too different to copy over handling methods.

Ancient Dragon commented: nice help and explanation +31
sfuo 111 Practically a Master Poster

This thread was dead for 4 years lol. Don't post in old threads as said in the read before posting.

sfuo 111 Practically a Master Poster

You can look over this and see what is going on but as you will notice I commented in most of the stuff it is missing from being complete.

#include <iostream>
using namespace std;

void DisplaySeats( char seats[][4], int rows )
{
	for( int i = 0; i < rows; i++ )
	{
		cout << i+1 << " ";
		for( int c = 0; c < 4; c++ )
			cout << seats[i][c] << " ";
		cout << endl;
	}
	cout << endl;
}

int main()
{
	string input;
	int rows = 7; //amount of rows
	char seats[rows][4]; //holds seat information
	char aRow[] = {'A', 'B', 'C', 'D' }; //only used to assign seats array

	for( int i = 0; i < rows; i++ )
		for( int c = 0; c < 4; c++ )
			seats[i][c] = aRow[c]; //assigns the seats array

	DisplaySeats(seats, rows); //displays the seats

	//start a loop here

	cout << "Please enter your seat (i.e. 4B):" << endl; //include some way to break the loop
	getline(cin, input);

	//come up with better error checking and maybe remove all spaces for cases if someone types "4 B" instead of "4B"
	//does not check if seat is already taken
	if( input.length() < 2 ) //if input is too short (doesnt check if its too long)
	{
		cout << "invalid input" << endl;
		system("PAUSE");
		return 0;
	}

	if(( input[0] < (int)'1' || input[0] > (int)'7' ) || ( input[1] < (int)'A' || input[1] > (int)'D')) //checks if the input is ok …
sfuo 111 Practically a Master Poster

In your calcCelsius() function I don't think that you want the line cin >> cel; since you are displaying it in the next function. This is what makes it seem like it "stops" when really its just waiting for input.

sfuo 111 Practically a Master Poster

Yeah I figured this out a while ago logfont.lfHeight does nothing so you have to use glScalef() to resize the fonts.

NeHe's tutorials are good for some things but for the most part I think that they are pretty out of date and I don't like using them unless I have to.

sfuo 111 Practically a Master Poster

a, b and c do not have a value assigned to them and you are using them.

I think this is how you want the program structured.

Compare what I have to what you have closely because you made many errors and I didn't comment all of them in.

#include <cstdio> //dont use name.h headers use cname headers
#include <conio.h>

float HM = 67.50, MS = 87.00, Ms = 92.75, a, b, c; //change data type to float or double ints do not have decimals
float oHM, oMS, oMs, T;
int main() //always use int main() not void main()
{
	printf("Hi! May I take your Order?");;
	printf("Here's our Menu");
	printf("Happy Meal for 67.50, McSavers1 for 87.00, McSavers2 for 92.75\n");
	printf("How many Happy Meal do you want?\n");
	scanf("%f", &a);
	oHM = HM * a; //figure out oHM after you get a value for a
	printf("It would be for %f\n", oHM);
	printf("How manyMcSavers1 do you want?\n");
	scanf("%f", &b);
	oMS = MS * b; //figure out oMS after you get a value for b
	printf("It would be for %f\n", oMS);
	printf("How many McSavers2 do you want?\n");
	scanf("%f", &c);
	oMs = Ms * c; //figure out oMs after you get a value for c
	printf("It would be for %f\n", oMs);
	T = oHM + oMS + oMs; //total everything up once you get values for oHM oMS and oMs
	printf("Your total bill is %f\n", T);
	printf("Thank You. Come Again\n");

	getch();
	return 0; //add a return since it is int not void …
sfuo 111 Practically a Master Poster

I threw in some ideas quickly so its not just option 1 option 1-a and stuff like that. Most of it is pretty lame but not too much thought went into it.

The main things that are being used in here are functions and the switch statement. You can try to look at my code and add more options in and see how stuff works by playing around with it.

I recommend this website for learning the basics and reference to the standard libraries.

I also like to learn by reading a bit of theory then making my own small program outlining concepts I just went over in the tutorials.

#include <iostream>

using namespace std;

//function prototypes
void Farm();
void Town();
void Cave();
void Options();

int main()
{
	Options();
	system("PAUSE"); //only works on windows comment out if you are using linux
    return 0;
}

void Options() //starting options
{
	cout << "Pick an area to go to:" << endl;
	cout << "1 - Farm" << endl;
	cout << "2 - Town" << endl;
	cout << "3 - Cave" << endl;
	int input;
	cin >> input;
	switch(input)
	{
		case 1:
			Farm();
			break;
		case 2:
			Town();
			break;
		case 3:
			Cave();
			break;
	}
}

void Farm() //farm area
{
	cout << endl << "You are at the farm." << endl;
	cout << "Pick an area to go to:" << endl;
	cout << "1 - Barn" << endl;
	cout << "2 - Corn Field" << endl;
	cout << …
sfuo 111 Practically a Master Poster

I learned C++ here and I still use it website for reference at times.

sfuo 111 Practically a Master Poster

Yeah I switched from Dev-C++ to Code::Blocks when I figured out it was really out of date. Dev-C++ is a pretty nice compiler because everything is pretty easy to use but I suggest you move on sooner before you get too attached.

sfuo 111 Practically a Master Poster

Yes I forgot about just putting using std::cout and the others that works better than the way I said.

sfuo 111 Practically a Master Poster

If you put using namespace std; at the top you wouldn't have to put std::cout and std::endl because they are in the scope of std, however the C++ string library is included in the iostream library and is in the scope of std as well. So just out of me not really knowing and the fact that the object "string" has already been defined in the std namespace I would either not use std on a global scale or just rename your string class to something else.

If you renamed your class and put using namespace std; then yes you would not have to put std::cout and std::endl.

sfuo 111 Practically a Master Poster

One big thing you should do for your programming in general not just for posting on forums is to put white space in your code so you can actually read what is going on. White space does not make your program a bigger executable and instead just makes it take longer to figure out what is going on and where errors could be.

Other than the fact that you are using other header files and you are making a class called string with the iostream library included there are no real errors to this.

For your questions when you make a class they have default constructors for things like = which you can overload if you want. By default the = operator just makes its self an exact copy of the object you have being compared to (of the same class). You can overload the = operator and make it do anything you want that would otherwise be completely illogical, like deleting the contents of your class.

void operator = ( string in )
{
	memset(str, max, 0);
	str[0] = 'p';
	str[1] = 'i';
	str[2] = 'g';
	str[3] = '\0';
}

Here is your code all cleaned up and changed a tiny bit.

#include <iostream> //<iostream.h> is really old do not use it

const int max = 80;

class string
{
	//classes are default private
	char str[max];
	public:

	string() //constructor 1
	{
		str[0] = '\0'; //if not done like said above it gives a junk value …
sfuo 111 Practically a Master Poster

Not sure why you would store all the values from your array into single ints a-j when you could just use the array and for loops to store the sums into a value.

You could use stringstream but if you don't want to include another header file and since the use of it is so small I think just subtracting 48 from the characters (as said above) is a faster and easier method for this small assignment.

When doing mini programs like these I would try to make the program as small and clean as possible just for good practice for when you have to work on bigger projects where it can get really confusing if everything is crammed together with poor formatting and poorly named variables.

#include <iostream>

using namespace std;

int main()
{
	string input; //stores input
	cout << "Please enter a 10-digit ISBN number: " << endl;
	getline(cin, input);

	for( int i = 0; i < (int)input.length(); i++ )
	{
		//checks if each index of the string is valid and if the length is correct
		if( (!(input[i] >= 48 && input[i] <= 57) && !(i == (int)input.length()-1 && toupper(input[i]) == 'X')) || input.length() != 10 )
		{
			cout << "Not valid input!" << endl;
			getchar();
			return 0;
		}
	}
	int sum = 0;
	// (a*1)+(b*2)+(c*3)+(d*4)+(e*5)+(f*6)+(g*7)+(h*8)+(i*9) % 11 = checksum
	for( int i = 0 ; i < (int)input.length()-1; i++ ) //sums the product of the first 9 numbers and 1-10
		sum += ((int)input[i]-48)*(i+1);
	sum …
sfuo 111 Practically a Master Poster

Are we supposed to post the answer we get to double check? I got 6580.

sfuo 111 Practically a Master Poster

I used to use it but other IDEs like CodeBlocks (the one I use because I find it sort of similar to Dev-C++) are more up to date and have more detailed warning checks and tell you what the errors are more accurately.

I recommend that you switch because you will run into problems soon and sometimes your source code will compile for you but will not compile for others using a different IDE with more up to date compilers.

sfuo 111 Practically a Master Poster

I wouldn't recommend SDL because it may be simple but it is pretty rigid and if you want to give your game to a friend you have to include a whole crap load of dll files to make it work.

I prefer using OpenGL for 2D or 3D games but if you are looking for something optimized for 2D games then stick with Direct2D.

You were looking for documentation and the first thing that popped up when I googled Direct2D was the msdn documentation website. http://msdn.microsoft.com/en-us/library/dd370990%28VS.85%29.aspx

sfuo 111 Practically a Master Poster

Not 100% sure what you are asking but if you are using Dev-C++ uninstall it and get a new compiler. That one has been dead for 5 years and is never going to be updated again.

sfuo 111 Practically a Master Poster

I use this for getting the window size in Windows. No idea how you get it on other operating systems.

int WINDOW_WIDTH, WINDOW_HEIGHT;
	HWND hDesktopWnd;
	HDC hDesktopDC;
	hDesktopWnd = GetDesktopWindow();
	hDesktopDC = GetDC(hDesktopWnd);

	WINDOW_WIDTH = GetDeviceCaps(hDesktopDC, HORZRES);
	WINDOW_HEIGHT = GetDeviceCaps(hDesktopDC, VERTRES);

	ReleaseDC( hDesktopWnd, hDesktopDC );