crosoft312 2021-06-18 22:21
Why is this broken? Sometimes, the paddles bounce the ball back to where it came from.
I have checked every line of code twenty times, and I honestly don't see anything wrong with it. Please help.
was8bit 2021-06-19 05:36
Fixed... also added rnd to computer to give player a chance to score... ;)
was8bit 2021-06-19 05:41 (Edited)
What you have to remember is that AND OR are not english statements, they are MATHAMATICAL functions that calculate in specific order and calculate to a number that will decide what happens...
Now, remember in math that PARENTHESIS are critical to getting the correct answer, so... 2*3+1 will calculate as (2*3)+1 or 7... but what if you meant 2*(3+1) or 8....
So if you have OR mixed with AND you must do this...
IF (cond. OR cond.) AND cond. THEN
otherwise, unexpected results will occur ;)
was8bit 2021-06-19 05:44
And of course this will calculate differently than the above..
IF cond. OR (cond. AND cond.) THEN
crosoft312 2021-06-19 12:54 (Edited)
Oh, I'm an absolute idiot! I always though Boolean expressions were calculated from left to right. A million thank yous!
G-9 2021-06-19 15:37
Whoa was8bit I didn’t saw that you used the same rnd system as me !!
was8bit 2021-06-19 16:17 (Edited)
@crosoft, i figured out that issue myself the hard way... only after trying everything i could think of did i finally find the solution ;)
@g9, if u scroll thru my stuff and find my pong game(s) and look thru my code, you will find a few more cool tricks ;)