Hi dudes,
I'm a super n00b so i'm having a tough time figuring this out.
There seem to be something wrong with collision detection. If I just manually change IsEaten to true then no problem so i think the problem is in the IsColliding function but I can't figure out what. I don't get any errors when I run the debugger so I'm not sure where to look.
Thanks to any one who can help.
Colliding not Working - BegC++ Tutorial 8
Colliding not Working - BegC++ Tutorial 8
- Attachments
-
- Chili Framework 2016 -game CKatt.zip
- (89.88 KiB) Downloaded 128 times
Re: Colliding not Working - BegC++ Tutorial 8
No sooner did i post this then i found the problem:
const int right0 = x0 + width0;
const int bottom0 = y0 = height0;
const int right1 = x1 + width1;
const int bottom1 = y1 + height1;
return
right0 >= x1 &&
x0 <= right1 &&
bottom0 >= y1 &&
y0 <= bottom1;
i typed a = rather then a +. the old lazy shift finger problem.
Any way, my question now is: how could I have used the debugger to find this?
Thanks,
const int right0 = x0 + width0;
const int bottom0 = y0 = height0;
const int right1 = x1 + width1;
const int bottom1 = y1 + height1;
return
right0 >= x1 &&
x0 <= right1 &&
bottom0 >= y1 &&
y0 <= bottom1;
i typed a = rather then a +. the old lazy shift finger problem.
Any way, my question now is: how could I have used the debugger to find this?
Thanks,
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Colliding not Working - BegC++ Tutorial 8
Breakpoint in the beginning of the collision code
F10 to step through each line, when something doesn't "add" up, you found your bug.
F10 to step through each line, when something doesn't "add" up, you found your bug.
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
-
- Posts: 115
- Joined: April 27th, 2012, 11:49 pm
Re: Colliding not Working - BegC++ Tutorial 8
Typographical errors like this which don't get caught by the compiler are the hardest to debug. Like albinopapa suggested, that is the only way the debugger is useful in this scenario.
This is why it is always recommended to make small changes to your code and test immediately. This way you have a smaller code base to scrimmage through to find the error.
This is why it is always recommended to make small changes to your code and test immediately. This way you have a smaller code base to scrimmage through to find the error.
Re: Colliding not Working - BegC++ Tutorial 8
Thanks for the tips guys!