Friday, February 22, 2008

G....g...graphics?

Read up on OpenGL today. It seems rather complex and the tutorial code didn't work in Dev C++. It had a strange header file which was a .h file (C style). Many of the introductory things for OpenGL I have had experience with in programs like Wings 3D.

The code bit had some very cool information however. By reading the code I could understand what it was telling the computer to do... very good!

Here's a link of what I was reading...
http://glprogramming.com/red/

One thing that continues to haunt me is... why is a teapot a primitive!

Wednesday, February 20, 2008

Errorrss


void readpage(char readfile[500]){
****fstream file(readfile[500],ios::in); *********
if( !file.is_open() ){
quit();
}
else{
for ( int x = 0; x < 20; x++ ){
file.getline (output, 500);
cout << output << "\n";
}
file.close();
cin.get();
}
}


This code is giving me the error of "invalid conversion from `char' to `const char*'" on the line that I starred.

It's being accessed by the line "readpage("welcomescreen.txt"); in the main program. So when I open the file it should be opening something called 'welcomescreen.txt' ... perhaps it can't use variables for file names?

Basically this accesses a file (welcomescreen.txt) reads 20 lines and prints them in succession. I had this working in main but decided to make a function out of it for simplicity...

Zhanar.... help? =D

Aside from all that, my finger has grown accustomed to pushing the ; button after I type every line;
I'm much more comfortable typing out code;
I can type code much more quickly now;
Provided I know what I want to type;

Tuesday, February 12, 2008

Classeses

*fireworks*

Classes seem to be very useful things. The C++ book has enlightened me on their use (and what they are), but not their creation (yet).

A class is a data type, more or less. One example would be 'string.' Used like this:

string words; //defines a string called 'words'

The example class used in the book was 'human' which would be used like this:

human maxHardcastle; //defines a human called maxHardcastle

I would then be a human, as opposed to an integer or string. Classes are much like structures except they can have other function like things inside of them. For instance, string.getline() would be a function inside of the class string. A structure couldn't do that.

Perhaps that makes sense... perhaps it doesn't. I don't know the syntax for classes, but it's probably complicated! =D

Monday, February 11, 2008

Kamchatka!!!

The new Kamchatka RPG is up and exiting. So far I made a program that either shows nothing, or closes itself. If an error occurs opening the .txt file, the program will terminate using the "exit" command that Zhanar showed me. She seems to have this weird communication thing going on with the computer that I can't understand. In any case, it's helpful for me! The setup for the program is as follows:

"areas" of the game will be read from .txt files. For instance, the loading screen will be a .txt file that will load and display whatever is inside of it. Then when the player flies their helicopter of doom to the Commander Islands, a new .txt (probably commanderislands.txt) will load and display all of its text. This will keep the program code much simpler.

On a further note, there will be .txt files for skills and inventory that can be accessed. There are ways to get lines of code from a text file until it reaches a certain point, and then take the code after that. For instance, the skills.txt file would look like this:

helicopter flying
15

The program would look through the file until it found "helicopter flying" and then take the next line which will be the level the player has obtained (15 here)

Inventory/Equipment will probably be similar unless someone smart suggests a much better way to do this.

Monday, February 4, 2008

New STUFF!

So in class today, I figured out how to read from files. Pretty easy, but took a while to figure out the basics, as with most things. Also Zhanar presented her program of su doku which was so smart. I learned about void functions, syntax for goto, how pointers can be used...etc. I think I learned something else too, but I'm not sure...

Sunday, February 3, 2008

Time Blogging?

I've been spending almost as much time blogging my work as I have been working on the work...

So here's to short blogs:

I've been working with loops to access specific lines in ascii files.

Friday, February 1, 2008

FINALLY I get to work on C++

Well somehow I managed to miss all classes this week except Monday. Too bad, but today the ski meet ended early and now I can PROGRAM! I've been experimenting with file I/O because whether or not I ever figure out windows, I should probably learn this. On Monday I'm going to look through the books to try to get one on Windows programming. That will be much easier than trying to read these tutorials.

I used the header "fstream" which included ifstream and ofstream to input and output to files to create a program that creates a file with some words in it. To create the file (or open it) I use the lines:

ofstream fout; //fout is a handle, I think
fout.open("file.txt"); //opens file.txt with the fout handle thing

To output to the file the line is:

fout << "word"; //pretty simple, right?

I've messed around a bit with reading from files too. If I open a file with "ifstream" instead of "ofstream" (ifstream = i-f-stream = input-file-stream) I have the ability to read from the file. I can then input the text to a string. The problem here is that the input line looks like this:

fin >> string; //problem = too simple... how can I specify what to get?

So now we have the text inside of the string, and it reads all the text up to any blank spots (spaces or returns). If I put:

fin >> string;
fin >> string;

It inputs up to the blank spot, then inputs whatever is past the blank spot and overwrites the first thing. Therefore if the file contained "a b" string would contain "b".

That's about as far as I've gotten so far... but I have about a weeks time to make up so there's much more to come!