Pikachumanson 0 Light Poster

For this week yes but the book gives me a real complicated explanation on how one is supposed to to do this. Maybe one of you guys that done such a program can offer me a simplified explanation. Until then, I'll try out what daviddoria told me.

Pikachumanson 0 Light Poster

So what exactly is the problem? It looks like if you add a cout statement

getline(infile, Storeline);
std::cout << Storeline;

you'd have what you asked for (simply displaying each line of the file on the screen)?

I need it to pick out the C++ errors in the text and I'm not sure how exactly how to do that.

Pikachumanson 0 Light Poster

Ok

I have an assignment for school where we are building a compiler step by step each week. This week I have to make a syntax analyzer that picks out the errors from this text file below. In the source code I have provided below I have a lexical analyzer and a symbol able that will point the types and variables. That is there just so you can see what I am working with.

The syntax analyzer is supposed to point out errors in the text file file in lines 3 and 4. No semicolon and undeclared identifier.

What I am confused about is how do I get it so that my program can look for specific line in the text and list them onto the screen. Once I figure out this part I finish my assignment. Thanx in advance.

/////start of text file
main()

{

int i

j = 23;

}
///////end of text file

#include <stdio.h>
#include <stdlib.h>
#include <iostream> 
#include <string.h>
#include <sstream>
#include <fstream>
#include <ctype.h>
#include <conio.h>
#include <time.h>
#include <math.h>
#include <dos.h>
#include <iomanip>


using namespace std;
 

int main(int argc, char* argv[])
{
	
	 ifstream infile ("input.txt");/*assigning infile to to the input text otherwise 
						     the program will spit out all zeroes as the result.*/

	//Variables
	string Storeline;//Variable to store the line
	string token = "";//variable to store the token
	string Name = "";//variable to store the table name
	bool Finished = false;//boolean to determine …
Pikachumanson 0 Light Poster

I am working on a 2-d scrolling map RPG ala final fantasy. Anyway the question I wanted to ask you is how do you go about tile based collision? Let's say I got my scroll map made up and I don't want my player to walk over tiles assigned to ten and twelve. How would I go about doing something like that?

I asked my professor about this and he told me this:

You could create a two dimensional array of RECTs that map to the tiles. Then you could check for collision between the player and the RECT by looping through the two dimensional array.


I'm not understanding what he means by this. Could someone show me an example what he means by mapping the Rects to the tiles and looping through the dimensional array? I don't any experience with working with scrolling tile maps so any help would be appreciated. Oh yeah, and before anyone says anything I already asked him this question he hasn't gotten back to me yet.

//my tile array
int TOWN[TOWN_MAPWIDTH*TOWN_MAPHEIGHT] = {
	0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, 
    8,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,7, 
    8,157,3,3,3,3,3,3,3,3,3,156,157,157,9,9,9,9,9,3,3,3,3,156,7, 
	8,156,3,3,3,3,3,3,3,3,3,157,157,156,9,10,11,12,9,3,3,3,3,157,7, 
    8,157,3,3,3,3,3,3,3,3,3,156,157,157,9,26,27,28,9,3,3,3,3,156,7,
    8,156,3,3,3,3,3,3,3,3,3,157,157,156,9,42,43,44,9,3,3,3,3,157,7, 
    8,157,3,3,3,3,3,3,3,3,3,156,157,157,9,9,9,9,9,3,3,3,3,156,7, 
    8,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,7, 
    8,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,7, 
    8,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,7, 
    8,157,3,3,3,3,3,3,3,3,3,156,157,156,3,3,3,3,3,3,3,3,3,156,7,
    8,156,3,3,3,3,3,3,3,3,3,157,157,156,3,3,3,3,3,3,3,3,3,157,7,
    8,157,3,3,3,3,3,3,3,3,3,156,157,157,3,3,3,3,3,3,3,3,3,156,7, 
    8,156,3,3,3,3,3,3,3,3,3,157,157,156,3,3,3,3,3,3,3,3,3,157,7, 
    8,157,3,3,3,3,3,3,3,3,3,156,157,157,3,3,3,3,3,3,3,3,3,156,7, 
    8,156,157,156,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,7,
    8,157,156,157,157,156,157,157,156,157,157,156,157,157,156,157,156,156,157,156,156,157,157,156,7,
    4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6 
};



//my collision function

int Collision(SPRITE *sprite1, SPRITE *sprite2)
{
       RECT rect1;
    rect1.left   = sprite1->getX() + 1;
    rect1.top    = sprite1->getY() + 1;
    rect1.right  = sprite1->getX() + sprite1->getWidth()  -1;
    rect1.bottom = sprite1->getY() + sprite1->getHeight() -1;

    RECT rect2;
    rect2.left   = sprite2->getX() + 1;
    rect2.top    = sprite2->getY() + 1;
    rect2.right  = …
Pikachumanson 0 Light Poster

Thanx for your advice! UGP_BUTTON_DOWN isn't anything special, just the name of a case option. Anyway I didn't really need a mouse flag I just had to make another enum with some state options and a class to boot!

Pikachumanson 0 Light Poster

For example, I want to set flag so that when I click a mouse down a screen schows up. I got that. But when I take my finger off of the button it disappears. Does anyone know how to set up a falg so that doesn't happen?

 switch(id)
      {
         case BUTTON_ID_1:
 if(state == UGP_BUTTON_DOWN)  TeaPotFPS();

break;
Pikachumanson 0 Light Poster

Thanks I didn't think of that before. But I would still like a method of deleting font. For now I am just changing Game states to get rid of the font. But I would like a way to actually deleting the text so when I have dialog between the hero and NPCs the text doesn't stay around on the screen even though it's painted over. Just a pet peeve of mine I guess. I think for now I will try Game state for the NPC dialog and that doesn't work I'll do your WM_Paint suggestion. Thanx for replying!

Pikachumanson 0 Light Poster

How do I erase the font once it's done it's purpose? I've checked the web and it only shows how to put up font but not how to erase it so I can put up new font in it's place. Also if you have an easier way to do what I am doing I would love to hear it. NOTE: I am using C++ visual Studio 2008 with the March 2009 Direct x sdk.

here's what I got.

// Set up story screen display
			// Text color (red)
			D3DCOLOR fontColor = D3DCOLOR_XRGB(0,0,255); 

			// story string
			string game_story = "Welcome brave traveler.";
			string story2 = "The kingdom of Thorinhold is in great peril!";
			string story3 = "Monsters roam the land and the lovely Princess Sara has been kidnapped";
			string story4 = "by the evil Vampire Lord Radu.";
			string story5 = "You must help the brave Knight Sir Delrin rescue her";
			string story6 = "and end the Vampire Lord's reign of terror!";
			string story7 = "Press space or the left mouse button to continue!";
	   
 
			// Rectangle for where it will be
			RECT story;
			story.left = 180;
			story.right = 640;
			story.top = 70;
			story.bottom = story.top + 20;	

			// Draw the text
			m_font->DrawText(NULL, game_story.c_str(), -1, &story, 0, fontColor);


 
			story.left = 140;
			story.top = 90;
			story.bottom = story.top + 20;
			m_font->DrawText(NULL, story2.c_str(), -1, &story, 0, fontColor);

			story.left = 40;
			story.top = 110;
			story.bottom = story.top + 20;
			m_font->DrawText(NULL, story3.c_str(), -1, &story, 0, fontColor);

			story.left = 140;
			story.top = 130;
			story.bottom = story.top + …
Pikachumanson 0 Light Poster

The problem was I took out the first RECT function. So when I put it back in I didn't have that problem anymore. Anyway I got the program fixed. I needed to use static ints to make the sphere move around the smoothly instead of just appearing in another spot like in my original program.

Pikachumanson 0 Light Poster

Sounds like you need a bit more experience with C++ before you start messing around with graphics. Seriously though, there's is a whole process you have to do just to set up OpenGL with C++. Are you using Visual C++? You can do some things with OpenGL without win32 but why would you want to? Your program will run slow.

Pikachumanson 0 Light Poster

ok I am almost done doing what I need to do and that is getting a portion of a bitmap to appear on the screen and have it move around using directional controls. My problem is that while I get the the bitmap move it leaves the original behind and a new one appears in the direction I pressed. Then when I take my finger off the button it returns to the middle.

So basically I want to make the bitmap that was in the previous position disappear and have the bitmap stay in the position I put it in so I can move it around like if I was playing zelda. The bitmap problem is the problem I really want to solve.

Here is my Game_Run function where all the magic happens
Let me know if you need the whole program..

void Game_Run(HWND hwnd)
{
 

HRESULT result;	
RECT rect2;
rect2.left = 164;
rect2.top = 0;
rect2.right = 320;
rect2.bottom = 160;
//load surface from file
result = D3DXLoadSurfaceFromFile(
surface, //destination surface
NULL, //destination palette
NULL, //destination rectangle
"spheres.bmp", //source filename
&rect2, //source rectangle
D3DX_DEFAULT, //controls how image is filtered
0, //for transparency (0 for none)
NULL); //source image info (usually NULL)
//return okay
if(d3ddev == NULL)
return;

//start rendering
if (d3ddev ->BeginScene())
{
 
 if (KEY_DOWN(VK_DOWN))
    {
      d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
      rect2.top = rect2.top + 10;
      rect2.bottom = rect2.bottom + 10;
       
   
      if (rect2.bottom > SCREEN_HEIGHT)
      {
      rect2.top = rect2.top - 10;
      rect2.bottom = rect2.bottom - …
Pikachumanson 0 Light Poster

Ok that explains quite a bit for me. Thank you Liz. I will get to working on the code right.

I believe this bit of code here is the heart of what I want to do.

for(int i=0; i< nFrames; i++)
        {
            Point pt = new Point(Hero_width * i, 0);
            frames[i] = new Rectangle(pt, new Size(Hero_width, Hero_height));
        }

Am I on the right track?

And while I'm at it here is the timer function I've written:

private void TimerSprite_Tick(object sender, System.EventArgs e)
    {
        if(currentframe >= nFrames - 1)
        {
            currentframe = 0;
        }
        else
        {
            currentframe++;
        }
    }

I've gotten it so that I can get bmp file to run through all of its animations now I gotta figure out how to assign those animations to each key.

Pikachumanson 0 Light Poster

Yeah I saved it in 24-bit bmp format. All a straight line of 8 individual animations. So what do I do? I know I'm supposed to make a private int for the frame variable.

so should I have something like this.

private int frame = 0;

or something like this?

Rectangle[] rectFrames = new Rectangle[8];

also I know I should have my bmp's width and height. width = 31 height = 43
But where I get confused is when I try to assign animations to the direction I want my character to move. I want two animations for each direction I want my little man to move in. So basically, I have two questions. One how do I access my frame animate from one bmp seperately and two where do I put these methods so i can get the desired effect?

Pikachumanson 0 Light Poster

What I want to do is take my rpg man sprite and understand how I can access each of his eight animations with methods. I've looked at code that does something like this but I'm not quite getting it. Right now, I got my guy to do two seperate animations from two separate bmps and he's facing forward in every direction he goes.So it looks like he's walking forward all the time. I guess what I am asking is how do I go about accessing all eight of his animations from a single bmp and assign them to the direction I want that animation to go to?

Pikachumanson 0 Light Poster

Thanks for the advice but I already tried that. I did manage to solve the problem by making use of the MakeTransparent(); method. YAY!!!

It works something like this:

if (HeroImage == null)
            {

                HeroImage.MakeTransparent();
                HeroImage = new Bitmap("Hero.bmp");

            }
Pikachumanson 0 Light Poster

I have a hero sprite which I have implemented in in my game. He walks around in a grass field. Unfortunately, he is surrounded by a white border that is also in the btmap(or JPG in this case). Any idea on how I can get my program to differentiate the white color(Make it disapper so I just see grass where the white used to be) from my character sprites colors? I'm using Visual Studio 2008 C# with Directx 9 and have no interest in using XNA for this project. Any tips or suggestions will be greatly appreciated.

I will post code if there is a need for it but I think this problem can be solved with out... I just happened not to have the solution....

Pikachumanson 0 Light Poster

That is what I am trying to do. My assignment is to make the Calcpoints method abstract and I want to know how I can access it from my child class Ultimate Warrior, Dragoon and KarateWizard. By the I have have redone my code and put them in their own cs files as a class with : Charclass denote that as a base class. But yeah, Calcpoints is the of my problem right not now.

Pikachumanson 0 Light Poster

I am making a character generator for school. What I have to do is make my CalcPoints method abstract. Unfortunately I keep getting These three error for each of my derived character classes and I don't know what to do.

C:\Users\Hector Rosario\Documents\Visual Studio 2008\Projects\Rosario_Week3\ConsoleApplication2\Program.cs(126,26): error CS0115: 'UltimateWarrior.CalcPoints()': no suitable method found to override

C:\Users\Hector Rosario\Documents\Visual Studio 2008\Projects\Rosario_Week3\ConsoleApplication2\Program.cs(137,26): error CS0115: 'KarateWizard.CalcPoints()': no suitable method found to override

C:\Users\Hector Rosario\Documents\Visual Studio 2008\Projects\Rosario_Week3\ConsoleApplication2\Program.cs(152,26): error CS0115: 'Dragoon.CalcPoints()': no suitable method found to override

I've working on this for two days and I think I am close but I can't figure out what I am doing wrong. Any help or advice would be awesome, Thanx

 public class CharClass
    {
      public CharClass()
      {
          Console.WriteLine("Calculating Life points");
          Calculate();
      }
       public static void Main(string[] args)
        {


            string Name;
            string choose;
            string Sex;
            string race;
             string species;




             Dragoon Mydragoon = new Dragoon();
             Console.ReadLine();
             KarateWizard Mykaratewizard = new KarateWizard();
             Console.ReadLine();
             UltimateWarrior Myultimatewarrior = new UltimateWarrior();
           Console.ReadLine();
            Console.Write("Please enter your name: ");
            Name = Console.ReadLine();//set character's name
            Console.WriteLine("Your character's age is {0}", age);
            Console.WriteLine("You have three races that you can choose for your\n character. Please type in human, elf or dwarf.");
            race = System.Console.ReadLine();
            switch (race)//choose character's race
            {
                case "human":
                    species = "Your character is human.\n";
                    break;
                case "elf":
                    species = "Your character is an elf.\n";
                    break;
                case "dwarf":
                    species = "Your character is a dwarf.\n";
                    break;
                default:
                    species = "Please pick human, dwarf or elf";
                    break;

            }
            System.Console.Write("Ok, " + species);



            Console.WriteLine("Do you want your …
Pikachumanson 0 Light Poster

Well We aren't going to write the code for you! What have you got so far?

Pikachumanson 0 Light Poster

Never mind, I fixed it. This is how I did it.

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            
            string Name;
            bool Life;
           string choose = "Ok, ";
           int age = GenerateRandomInteger(10, 40);
            
            string Sex;
            Console.WriteLine("Welcome to Hector Rosario's Character Generator.");
              Console.Write("Please enter your name: ");
            Name = Console.ReadLine();
            Console.WriteLine("Your character's age is {0}", age);
            
            Console.WriteLine("Do you want your character to be male or female?\n Prees m or f to make your choice.");
            
            switch (choose)
                {
                    case "m":
                        Sex = "Your character is male";
                        break;
                    case "f":
                        Sex = "Your character is female";
                        break;

                       default:
                        Sex = "I'm sorry but uh... last I checked there were only two sexes, male and female.";
                        break;
                }//end switch statement

                Console.WriteLine();
                Console.WriteLine(Sex);
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to Exit");
                Console.ReadLine();

}
       private static int GenerateRandomInteger(int intMin, int intMax)
        {
            //Create a new instance of the class Random
            Random randomNumber = new Random();
            //Generate a random number using intMin as the minimum and intMax as the maximum
            return randomNumber.Next(intMin, intMax);
        }//end of number generator    
        }//end class "switchStatement
    
        
          
        }

It didn't have the intended results I wanted but it compiled. I can get to to making that switch working now!

Pikachumanson 0 Light Poster

I was hoping you guys could help me out as you have in the past. I am kind of new to C# coming from C++.
I get two of each of these errors.

C:\Users\Hector Rosario\Documents\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs(51,39): error CS1518: Expected class, delegate, enum, interface, or struct
C:\Users\Hector Rosario\Documents\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs(57,9): error CS1022: Type or namespace definition, or end-of-file expected

Here is what I am working on

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            
            string Name;
            bool Life;
           string choose;
        
            string Sex;
            Console.WriteLine("Welcome to Hector Rosario's Character Generator.");
              Console.Write("Please enter your name: ");
            Name = Console.ReadLine();
            Console.WriteLine("Your character's age is {0}", age);
            int age = GenerateRandomInteger(10, 40);
            Console.WriteLine("Do you want your character to be male or female?\n Prees m or f to make your choice.");
            switch (choose)
                {
                    case "m":
                        Sex = "Your character is male";
                        break;
                    case "f":
                        Sex = "Your character is female";
                        break;

                       default:
                        Sex = "I'm sorry but uh... last I checked there were only two sexes, male and female.";
                        break;
                }//end switch statement

                Console.WriteLine();
                Console.WriteLine(Sex);
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to Exit");
                Console.ReadLine();

}
           
        }//end class "switchStatement
    private static int GenerateRandomInteger(int intMin, int intMax)
        {
            //Create a new instance of the class Random
            Random randomNumber = new Random();
            //Generate a random number using intMin as the minimum and intMax as the maximum
            return randomNumber.Next(intMin, intMax);
        }//end of number generator
        
          
        }

        


     
    }
Pikachumanson 0 Light Poster

You are going to have to do this the hard and just learn by buying books on C# or taking a class on it at your local college. Also youtube offers some interesting tutorials on C#

Pikachumanson 0 Light Poster

I'm sorry if I made it seem I was here to copy and paste... THat surely wasn't the case. If it was like that what am I doing trying to become a programmer in the first place? If I don't understand something, I don't understand something. I know I got more than more than a little annoying with my problem and I apologize. I'm still learning, as we all are.
Anyway, I thank you all helping me out. The solution worked.

Pikachumanson 0 Light Poster

Ok here is what I want to do. "Hello world" is on my list of objects by default. When I type in "list" Hello world should come up. Now I type in "add" and it aks what object would you like to add. So I type in "Hellboy". Now when I type in list, "Hello world" and "Hellboy" should come up.
This part I have down pat.
The problem I have been wrestling with for the past two days is now I want to input "search"
and type in one of the existing items that is on the list
I want to input "Hellboy" and then have the word pop up on the screen.
Vernon's example is good for predefined objects that are hard coded into the program but I am trying to find objects that have been created due to the add function.

#include <iostream> 
#include <string>  // Include this...
#include <algorithm>
#include <vector> 
#include<fstream>
using namespace std; 

// Constants
static const string ADD	= string("add");
static const string LIST	= string("list");
static const string EXIT	= string("exit");
static const string SEARCH = string("search");

// No need for global strings here
 

class objects { 
public: 
	objects() {} // This can be left out, it will be automatically generated
	~objects() {} // Same
	std::string name; 
	std::string find; 
}; // Don't need to create some global object here

int main(int argc, char* argv[]) 
{  
 int SearchVector(const vector<objects*>& allObjects, const string& aString);//gotta figure out the parameters …
Pikachumanson 0 Light Poster

Thanks ArkM and Vernon, your posts have helped me alot!
But I have one more point of contention.

Here it is.

else if (input == SEARCH)
		{
			cout << "What object do you want?";
			 string s1 = "T"; 
			 string s2 = "S"; 
			 string s3 = "TestOne"; 
			 cout << "Object s1 == s2 " << (s1 == s2) << endl; 
cout << "Object s2 == s3 " << (s2 == s3) << endl; 
cout << "Object s1 == s3 " << (s1 == s3) << endl; 
cout << "The object you found is " << endl;
cout << endl << (*iter)->name == objects;//Problem is here!
operator==(name);//Do I need this here?
return 1;
  
		
		}

This is the error I get:
1>c:\users\hector rosario\documents\visual studio 2008\projects\rosario_week9\rosario_week9\dictionary.cpp(91) : error C2227: left of '->name' must point to class/struct/union/generic type
1> type is 'int'


What exactly does that mean and even better how the heck do I fix it?

Pikachumanson 0 Light Poster

You could use the Beep command...

Beep(523,500); // 523 hertz (C5) for 500 milliseconds
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);

but you probably didn't want to hear that from a novice like me...

Pikachumanson 0 Light Poster

What am I doing wrong?

Pikachumanson 0 Light Poster

I'm not quite clear on how to do that...
This is what I got so far.

else if (input == SEARCH)
		{
			cout << "What object do you want?";
			std::vector - scan::iterator iter=vect.begin();iter != vect.end();iter++) 

 
  if (iter=vector.end())}
Pikachumanson 0 Light Poster

Ok here is what I got so far.
When you type add, it asks what object would you like to add
When you type list, it lists those objects
When you type exit, you leave the program
What I would like to do is create a search function where I can type in the name of an object that is on the list and it will come up on the screen.
I would like at LEAST an explanation of how this would be done if I can't have an example.
I know it has something to do with a loop and iteration but my mind is drawing a blank right now. Any help would be greatly appreciated!

#include <iostream> 
#include <string>  // Include this...
#include <vector> 
#include<fstream>
using namespace std; 

// Constants
static const string ADD	= string("add");
static const string LIST	= string("list");
static const string EXIT	= string("exit");
static const string SEARCH = string("search");//My search declarer thing

// No need for global strings here
 

class objects { 
public: 
	objects() {} // This can be left out, it will be automatically generated
	~objects() {} // Same
	std::string name; 
}; // Don't need to create some global object here

int main(int argc, char* argv[]) 
{ 
	vector<objects*> vect; 

	// We'll use this to refer to all objects we create
	objects *object_pointer;

	// This is generally how we'll push objects...
	object_pointer = new objects;
	object_pointer->name = "Hello World!";
	vect.push_back(object_pointer);
	
	cout <<"type add to add an …
Pikachumanson 0 Light Poster

I know this a long dead subject but... if anyone else has this problem like I did!
here is the solution

#include <iostream>
using namespace std;
 
void spaces(int x) //I'm thinking, everybody else is going to do a diamond full of stars. So why not
//put spaces in mine and show the outline of the shape
{
   for (int c = 1; c <= x; c++)
      cout << " ";//the spaces
}
 
void stars(int x)//the stars
{
   for (int c = 1; c <= x; c++)
      
   {
            cout << "*"; 
         }
          
}

void row(int r, int rows) //print out each row
{
   spaces (rows - r);
  stars (1);//outline of diamond
  stars (2 *(r - 1));//fills up inside of daimond.
 
    
   stars(1);
 
   cout << endl;
}

void top_row(int rows)  
{
   spaces (rows);
   stars (1);
   cout << endl;
}
 

int getDiff(int X, int Y) { // Tail Implementation
  X++; // Inc X
  if (X == Y)
    return 1;

  return (1+getDiff(X, Y));
}


void getDiff2(int X, int Y, int Diff = 0) //subtracting x from y
{
  X++;
  Diff++;

  if (X != Y)
    getDiff2(X, Y, Diff);
  else
    cout << "Diff Was: " << Diff << endl;

  return;
}

int main(void) {

  
   
   int r, rows;
   cout << "Size of diamond? ";//input the number
   cin >> rows;
cout << "Difference Between 1 & 7 Is: " << getDiff(1, 7) << endl;//getting the difference between 1 and 7
  
   top_row(rows);
   for (r = 1; r <= rows; r ++) row(r, rows);
   for (r = rows - …
Pikachumanson 0 Light Poster

I have the this fight in a function that is in the main file. Now I know I can just as easily put the Life variable in the main cpp and it's problem solved but I want to learn how to do it from a class the correct way. I don't have a fight class for now. I am just learning how to implement battle in my RPG.

"If so you should not be making a new player but instead passing who is fighting what. That way you dont need to set health each time cause its contained in the player information. "

That is exactly what I would love to figure out.

Pikachumanson 0 Light Poster

I keep getting a logic error when I go to fight a monster.
It says the life must be initialized and then I get a runtime error. So I put a value to it and it runs fine. But the question is, what happens after the fight. I don't want my character to to take all this damage and then win and then all of a sudden he has one hundred hit points again. I would just like to know the correct way to access the life class variable so that it shows up in the fight funtion and works how it is supposed to.

ENTITY.h
private:

int life;
------------------------------------------------------------------------

ENTITY.cpp
void ENTITY::SetLife(int newLife)
{
	 
	if (life < 0)
		life = 0;
}
int ENTITY::GetLife()
{
	return life;
}
}
---------------------------------------------------------------------------------
PLAYER::PLAYER()//derived from ENTITY class
{
SetLife(100);//Here the value of SetLife is stated
}
---------------------------------------------------------------------------------------
void fight()
{
PLAYER player;// derived from ENTITY
  
  int life = 100;// I don't think I should have to put a value to this variable if it's already stated in a class.


player.SetLife(life);
}
Pikachumanson 0 Light Poster

Ok, let's put it this way. I need to know how to set it up for my project without it interfering with OpenGL. I have a good idea which folder but don't know what DLL to put in. So far the manual has not addressed that because it already assumes that you know how. That's all I need help with.

Pikachumanson 0 Light Poster

For Visual Studio 2008. I am not sure if this is the right place for it, but maybe someone here can help me. I have my program set up for Open GL, I also want to put Open AL in there too. Now I scoured the net for tutorials and found none and the documentation that comes with Open AL is too confusing. So maybe someone who has solved this problem can impart this knowledge onto me.
Give it to me in a step by approach.
Much thanx.

Pikachumanson 0 Light Poster

Thanx a lot Ancient Dragon! Here is my solution in case anyone else ever runs into this type of problem.

void continueGame()// My problem is here...
{
 //open save file for previous matrix position and health
 PLAYER player;
 
 int something;
 ifstream continueData;
	continueData.open("save.txt");
	continueData >> playerName >> something >> x >> y >> m >> n >> g >> h >> Currentroom;
player.SetLife(something);
    continueData.close();

}

Pikachumanson 0 Light Poster

GetHealth() returns the persons life and places it on the screen. Originally, (nit sure if you remember) I had put the health variable called int life; in the main cpp. I believe I have the save function part correct. On the continue function when I try to do the same thing I keep getting some type of binary error saying it should be << instead of >>. Any thoughts on how I should get around that while still getting what I want from the class? I have to do it like that so that when my character gets experience his life can go up too.

void save()
{ 
 
 	 PLAYER player;
	//save player name, life, and current coordinates on the board
             ofstream saveGame;
             saveGame.open("save.txt");
             saveGame << playerName << " " << player.GetLife() << " " << x << " " << y << " " 
                 << m << " " << n << " " << g << " " << h << " " << Currentroom << endl;
             saveGame.close();
}
void continueGame()// My problem is here...
{
 //open save file for previous matrix position and health
 PLAYER player; \\ I'm to replace the integer life with it's counter GetHealth() 
 ifstream continueData;
	continueData.open("save.txt");
	continueData >> playerName >> life >> x >> y >> m >> n >> g >> h >> Currentroom;//life to getlife
    continueData.close();
Pikachumanson 0 Light Poster

Can anyone give me a hint on how to save my heroes health that is in a PLAYER class that would be GetHealth() because it inherited that from the base class entity.
SetHealth() is in the base class Entity. I know I am just a couple line away from solving the problem. If you guys need more info let me know. I'm thinking this is enough code though...

void save()
{
 
 
	//save player name, life, and current coordinates on the board
             ofstream saveGame;
             saveGame.open("save.txt");
             saveGame << playerName << " " << player.GetHealth() << " " << x << " " << y << " " 
                 << m << " " << n << " " << g << " " << h << " " << Currentroom << endl;
             saveGame.close();
}
void continueGame()//I think my problem is here...
{
 //open save file for previous matrix position and health
 	
 
	ifstream continueData;
	continueData.open("save.txt");
	continueData >> playerName >> player.GetHealth() >> x >> y >> m >> n >> g >> h >> Currentroom;
    continueData.close();
 
					
 
}
Pikachumanson 0 Light Poster

I believe you got to declare what today is.

Pikachumanson 0 Light Poster

Thanx it it worked! Now if I could figure out the composition thing... Thanks a lot man u r awesome!

Pikachumanson 0 Light Poster

First off, this is homework and I do my classes online and the teacher doesn't respond to my e-mails in the fastest fashion. I've been getting linker errors all day and I'd like at least an explanation of why they happen.

here is my problem.
Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Dictionary::Dictionary(int)" (??0Dictionary@@QAE@H@Z) referenced in function _main
C:\Documents and Settings\Keith Acevedo\My Documents\Visual Studio 2008\Projects\RosarioWeek3\Debug\RosarioWeek3.exe : fatal error LNK1120: 1 unresolved externals

I get these two when I try to compile my program. It also does this when I try to put composition in it.

the problem is in the dictionary file. It's not seeing myDictionary.loadDictionary(); for some reason and I don't know why.

Also if you guy/gals would I have included a second zip of an alternate way I was going with the project maybe you can tell me what I am doing wrong there too.

The one I really want to focus is week 3 they are both the same program it's just I was trying different things and yes, the menu funtions thing is supposed to be in controller. I have included them both to show supposed to show my problems in composition and this inheritance error. Any help will be appreciated.

Pikachumanson 0 Light Poster

For unions. Unions cannot have base classes, and unions can not be used as base classes.
Did I get it right?

Pikachumanson 0 Light Poster

Thank you very much!! I post the cpp file so if anyone else needs help like I did they can get it here! You can consider this thread solved!

Pikachumanson 0 Light Poster

Thanx for the code optimization Ancient Dragon. Now if I could just figure out how to get the program to recognize the difference between saving and continuing in the first room and saving and continuing in the others. I realize that I am probably sounding annoying already, but that making all those separate save texts was my attempt to get the program to recognize the difference between the rooms. But alas, it is always to the same effect. Hopefully I can figure out the solution soon. Or if somebody does please let me know!

Pikachumanson 0 Light Poster

Still got the same results. Did you type in the code and get it to work yourself? Because I had tried something to that effect before and had no luck.

Pikachumanson 0 Light Poster

Hello everyone. This is my first post here. I am only posting here under the most extreme circumstances because I cannot for the life of me figure out how to make my save function for RPG game to work. So for it will only save in the first room. So I tried making different ttext files for each room. Let's say I save in the second room. While the program will write down the coordinates and other data to the text when I try to continue it will only bring up the save I did in the first room. I am almost done my game and I love to get this problem fixed so any help will be greatly appreciated. By the way I am using VS 2008 C++professional edition.

Here is the code

//Author Hector Rosario
 

#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <string>
#include <time.h>

using namespace std;

//my void functions
void drawMaze();
void Maze1();
void cokeparty();
void room1();
void room2(); 
void drawRoom();
void help();
void newRoom(); 
void input();
 void input2();
 void input3();
void mainMenu();
 void continueGame();
 
 
 //My chars      
char guy = 1; //our hero
 
string playerName;    
 //my ints
int move; //input for movement
	  int x = 14; //starting x value on room one for main character
      int y = 8; //starting y value on room one for main character
	  int m = 6;//starting x value on room two for main character
	  int n …