Why is a sprite being created without a Draw function?

The Partridge Family were neither partridges nor a family. Discuss.
pupperoni
Posts: 12
Joined: August 12th, 2017, 12:56 am

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

Post by pupperoni » August 27th, 2017, 2:17 pm

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?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

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

Post by chili » August 27th, 2017, 2:40 pm

A huge difference. What makes you think they would ever be equivalent? ;)
Chili

pupperoni
Posts: 12
Joined: August 12th, 2017, 12:56 am

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

Post by pupperoni » August 27th, 2017, 2:45 pm

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.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

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

Post by chili » August 27th, 2017, 3:06 pm

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.
Chili

pupperoni
Posts: 12
Joined: August 12th, 2017, 12:56 am

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

Post by pupperoni » August 27th, 2017, 3:26 pm

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.

OrbitalReign
Posts: 19
Joined: July 17th, 2017, 1:24 pm

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

Post by OrbitalReign » August 28th, 2017, 1:49 am

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.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

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

Post by albinopapa » August 28th, 2017, 6:10 am

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).
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply