c++ question about Sub procedures

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Jim121
Posts: 21
Joined: Sat Oct 11, 2008 2:23 am

c++ question about Sub procedures

Post by Jim121 »

I the following code in my program but the compiler says that x, y and z are not declared. thanks in advance.

Code: Select all

 
int ang(float x,float y, float z, float angle_xz, float angle_yz, float distance){
    if(angle_xz<=90){
             y=distance*sin(angle_xz/60);
             z=distance*cos(angle_xz/60);
    }
    if(angle_xz>90 && angle_xz<=180){
             y=distance*sin((angle_xz-90)/60);
             z=distance*cos((angle_xz-90)/60);
    }
    if(angle_xz>180 && angle_xz<=270){
             y=distance*sin((angle_xz-180)/60);
             z=distance*cos((angle_xz-180)/60);
    }
    if(angle_xz>270){
             y=distance*sin((angle_xz-270)/60);
             z=distance*cos((angle_xz-270)/60);
    }
}

Code: Select all

ang(rect_basic_bronze_axe[i].x,rect_basic_bronze_axe[i].y,rect_basic_bronze_axe[i].z,rect_basic_bronze_axe[i].direction_xz,
             0,10);
        rect_basic_bronze_axe[i].x=rect_basic_bronze_axe[i].x+x;
        rect_basic_bronze_axe[i].y=rect_basic_bronze_axe[i].y+y;
        rect_basic_bronze_axe[i].z=rect_basic_bronze_axe[i].z+z;
Open Conquest Developer
web site:
http://openconquest.webs.com/
aungsithu
Posts: 39
Joined: Thu Sep 04, 2008 2:14 am
Location: Singapore
Contact:

Post by aungsithu »

rect_basic_bronze_axe.x=rect_basic_bronze_axe.x+x;
rect_basic_bronze_axe.y=rect_basic_bronze_axe.y+y;
rect_basic_bronze_axe.z=rect_basic_bronze_axe.z+z;


Where these underlined x,y,z came from?
Aung Sithu
*** Check out my latest book, Beginner's guide to Irrlicht 3D engine: http://bit.ly/rSnm4O
Company: http://rivaledge.sg
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah your compiler should have told you which line numbers give the errors and will probably pointed to the same ones as aungsithu pointed out. From your code snippet they certainly don't seem to be coming from anywhere sensible but it's hard to tell!
Image Image Image
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Post by asparagusx »

I also can't see how you are going to change the values in the ang function :

int ang(float x,float y, float z, float angle_xz, float angle_yz, float distance)

In the code you are changing x,y,z, but they are not declared correclty - you either have to define them as

float &x or
float *x (as an example)

if declared as float *

then use

*x = ........

Anton
Jim121
Posts: 21
Joined: Sat Oct 11, 2008 2:23 am

Post by Jim121 »

thanks
I should have seen it before the variables are not declared as global variables meaning that any where out of the sub they would be existent.
Open Conquest Developer
web site:
http://openconquest.webs.com/
Post Reply