Page 3 of 3

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 2:17 pm
by pupperoni
I...have no idea what I changed.... but I fixed it.

Extra lost but happy it works lmao.

The only change I see is:

Code: Select all

Bone::Bone(int in_x, int in_y)
{
	x = in_x; 
	y = in_y; 
}


is there really a big difference between x=in_x and in_x=x?

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 2:40 pm
by chili
A huge difference. What makes you think they would ever be equivalent? ;)

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 2:45 pm
by pupperoni
Well I'm trying to think of it in more "concrete" terms. Like if you're solving a problem in math class and you write 24 = x that's weird, but it's not necessarily different from x=24. And it just seems to make more sense to write in_x = x because in_x is the local variable that is created. But I'll just have to remember that it's "member variable = local variable" and not the other way around.

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 3:06 pm
by chili
That's why I said in one of the early beginner videos, the c/cpp/java/C# etc. = operator is not the = of math class. You must have missed that part ;)

The operator= doesn't represent a relationship between two sides of an equation like in mathematics; it is an operation. Typically, it takes (or assigns) the value on the right to the variable on the left (i.e. a storage operation). That's why it is called the assignment operator.

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 3:26 pm
by pupperoni
I suppose I was thinking of it backwards. I was thinking that the in_x basically reads and grabs the x, but really it's putting random numbers into the x.

Re: Why is a sprite being created without a Draw function?

Posted: August 28th, 2017, 1:49 am
by OrbitalReign
I think you still misunderstand whats happening.
and someone correct me if I'm wrong but the way i understand it is when the bone object gets created 'x' and 'y' are created in bone but as they haven't been set to any starting value their uninitialised and set to -8000000000 something something then when you call

Code: Select all

Bone::Bone(int in_x, int in_y)
{
    in_x = x; 
   in_y = y; 
}
int "in_x" and int "in_y" are created locally in bone with the rng values but then the statement
"in_x = x;"
overrides or puts the value of 'x' into 'in_x'. your assigning >> '=' << the value of 'x' into 'in_x' and the same for the y.
reversing it puts the value of 'in_x' into 'x' which is what you want in this case.

Re: Why is a sprite being created without a Draw function?

Posted: August 28th, 2017, 6:10 am
by albinopapa
OrbitalReign wrote:I think you still misunderstand whats happening.
and someone correct me if I'm wrong but the way i understand it is when the bone object gets created 'x' and 'y' are created in bone but as they haven't been set to any starting value their uninitialised and set to -8000000000 something something then when you call

Code: Select all

Bone::Bone(int in_x, int in_y)
{
    in_x = x; 
   in_y = y; 
}
int "in_x" and int "in_y" are created locally in bone with the rng values but then the statement
"in_x = x;"
overrides or puts the value of 'x' into 'in_x'. your assigning >> '=' << the value of 'x' into 'in_x' and the same for the y.
reversing it puts the value of 'in_x' into 'x' which is what you want in this case.
You are correct, the = is an assignment operation. The uninitialized value, the negative 8 million or something isn't terribly important, though it may or may not be helpful in understanding some exceptions that might happen. Debug address fills. The thing to remember is the = is an assignment not an "equal to" and it assigns the value on the right to the value on the left (often called rvalues and lvalues).