Why does this code get the reticle to change back to white when you're no longer over the specified line in one directio

The Partridge Family were neither partridges nor a family. Discuss.

TheCollector
Posts: 41
Joined: August 1st, 2019, 9:57 pm

Re: Why does this code get the reticle to change back to white when you're no longer over the specified line in one dire

Post by TheCollector » August 6th, 2019, 3:03 pm

I think some of the problems I was having had to do with the scope maybe? The else statement was working to return the reticle to white in one direction but not the other. It's not that I couldn't figure out how to get it to turn white again but I was hoping someone could explain to me why the else statements weren't working to do that for the Y but were working for the X when the code was basically the same. Not that important though since like you've explained, they can be done in one shot rather than two separate statements.

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

Re: Why does this code get the reticle to change back to white when you're no longer over the specified line in one dire

Post by albinopapa » August 6th, 2019, 5:58 pm

It's good to explore, chili often recommends practicing what he covers and venturing out if you feel confident enough. Sorry if I sounded rude or harsh.

I did feel a little trolled, I often feel that way when I offer a suggestion and some other thing was actually causing your code not to work and then the person posting comes back and says " Oh, it was this that was the actual problem ". Kind of like the = vs == issue. Felt like it was a test that I had failed :).

Anyway, if you haven't gotten to the cross hair changing colors tutorial and homework, then you may not have covered all the logical operators ( &&, ||, ! ) and comparison operators ( ==, !=, <, >, <=, >= ) nor all the 'if' statements ( if, else if, else ).

As a suggestion as someone who has learned from chili's tutorials, though I learned from his old series starting back in 2013 IIRC, what I did was watch his videos without following along, then I'd go back and watch the videos again and this time follow along. This helped solidify the material being presented. After watching a few videos and following along, I would go into Visual Studio and try a few tests to make sure I understood the material. If I come across something I don't remember or didn't understand, I'd go back and watch the video again at the very least skipping around to find the portion I wanted to rewatch.

The debugger is your friend, this is also something that will be covered in his tutorials in a few episodes. Debugging line by line for me was the most helpful way to understand what I was doing wrong. Sometimes it's going to be difficult to pin down a bug if it only happens under certain conditions, but with enough practice, you should be able to understand what those conditions are and eventually be able to find and resolve them.

Don't hesitate to post here if you do get stuck and have tried debugging. Sometimes it does take someone removed from the project to find the issue.
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