This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:comporg:spring2025:projects:mtb1 [2025/02/20 03:22] – [translating read joystick value into X and Y] tkastne1 | notes:comporg:spring2025:projects:mtb1 [2025/02/20 03:33] (current) – [How to check if our sprite has reached a bound] tkastne1 | ||
---|---|---|---|
Line 101: | Line 101: | ||
====How to check if our sprite has reached a bound==== | ====How to check if our sprite has reached a bound==== | ||
+ | Checking the bounds of the screen can be done using greater than/less than instructions | ||
+ | Remember that instructions overwrite the register | ||
+ | < | ||
+ | mov R0, R1 | ||
+ | ilt R0, YMIN | ||
+ | jt R0, _upper_bound | ||
+ | </ | ||
+ | and | ||
+ | < | ||
+ | mov R0, R1 | ||
+ | igt R0, YMAX | ||
+ | jt R0, _lower_bound | ||
+ | </ | ||
+ | Where R1 is a the y position and YMIN/YMAX are the min and max bounds | ||
====How to limit our sprite from leaving the playfield==== | ====How to limit our sprite from leaving the playfield==== | ||
====How to cause our sprite to wrap-around on the playfield==== | ====How to cause our sprite to wrap-around on the playfield==== | ||