This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2023:projects:ttb1 [2023/09/14 17:15] – [BITWISE OR] dwhite26 | notes:discrete:fall2023:projects:ttb1 [2023/09/21 01:40] (current) – [LARGER PADDLE] cfoster8 | ||
---|---|---|---|
Line 6: | Line 6: | ||
Bitwise AND uses the "&" | Bitwise AND uses the "&" | ||
It checks if the two inputs are numbers and if so then it gives back a 1. | It checks if the two inputs are numbers and if so then it gives back a 1. | ||
+ | |||
+ | For example if we have an int set to 12 and an int set to 6 if we preform a bitwise & operation on them the result would be a 0100. 12 in binary is 1100 and 6 in binary is 0110. | ||
+ | |||
+ | ^ 12 ^ 6 ^ | ||
+ | | 1 | | ||
+ | | 1 | | ||
+ | | 0 | | ||
+ | | 0 | | ||
+ | |||
+ | In this example of bitwise & gives us the result as 4. You can test this out yourself in code. | ||
+ | |||
+ | <code c> | ||
+ | int num1 = 12; // Binary: 1100 | ||
+ | int num2 = 6; // Binary: 0110 | ||
+ | int result = num1 & num2; // Perform bitwise AND operation | ||
+ | |||
+ | printf(" | ||
+ | printf(" | ||
+ | printf(" | ||
+ | </ | ||
+ | |||
+ | it prints out the result as follows: | ||
+ | |||
+ | num1: 12 | ||
+ | num2: 6 | ||
+ | result: 4 | ||
====BITWISE OR==== | ====BITWISE OR==== | ||
Bitwise OR uses the " | Bitwise OR uses the " | ||
It checks if the either of the two inputs are not zero and gives a 1. | It checks if the either of the two inputs are not zero and gives a 1. | ||
+ | |||
+ | ^ 12 ^ 6 ^ 6 or 12 ^ | ||
+ | | 1 | | ||
+ | | 1 | | ||
+ | | 0 | | ||
+ | | 0 | | ||
+ | |||
+ | In this example the result of 12 or 6 is 14. | ||
====BITWISE XOR==== | ====BITWISE XOR==== | ||
+ | Bitwise XOR uses the " | ||
+ | |||
+ | ^ 12 ^ 6 ^ 6 or 12 ^ | ||
+ | | 1 | | ||
+ | | 1 | | ||
+ | | 0 | | ||
+ | | 0 | | ||
+ | |||
====BITWISE NOT==== | ====BITWISE NOT==== | ||
+ | Bitwise NOT uses the " | ||
+ | It inverts all the bits in a single number. | ||
+ | ^ 12 ^ ~12 ^ | ||
+ | | 1 | 0 | | ||
+ | | 1 | 0 | | ||
+ | | 0 | 1 | | ||
+ | | 0 | 1 | | ||
=====POTENTIAL FEATURES===== | =====POTENTIAL FEATURES===== | ||
====LARGER PADDLE==== | ====LARGER PADDLE==== | ||
+ | To make a larger paddle, all you'd have to so is extend your paddle collision to double the length of your paddle and draw a second paddle where the first one ends, or alternatively use a different paddle sprite | ||
+ | |||
+ | You can use the same select region to draw both paddles, like so | ||
+ | select_region( Paddle ); | ||
+ | draw_region_at( PaddleX, PaddleY) | ||
+ | draw_region_at( PaddleX + [paddle length], PaddleY) | ||
+ | Where [paddle length] is the length of the paddle | ||
====PADDLE MAGNET==== | ====PADDLE MAGNET==== | ||
====BRICK HIT POINTS==== | ====BRICK HIT POINTS==== | ||
+ | To code in multiple hit points for bricks, your brick struct should include an integer member for HP and visibility. | ||
+ | |||
+ | Within your calculations for ball-brick collision, make a check to see if the current brick is visible (if not, do not process collision detection). If collision is detected, decrement the brick' | ||
====INVINCIBLE BALL==== | ====INVINCIBLE BALL==== |