(Thank You tepples, the classic multiplying 16 bits by 16 bits algorithm really helped me!)
How do you set boundaries? After increasing the speed of my bullet, i noticed that sometimes it will cross the screen two or three times.
My code for checking the y boundary of the screen is like this:
The problem is that when the bullet is flying faster, i think, is that it skips over more numbers and may skip row 240 and row 0 causing it to flying again across the screen.
What can be done to make sure that the bullet never crosses the boundary of the screen, no matter how fast it is flying? Maybe it might work to subtract the previous row from the current row and if it's higher or lower than some number, don't let it pass?
How do you set boundaries? After increasing the speed of my bullet, i noticed that sometimes it will cross the screen two or three times.
My code for checking the y boundary of the screen is like this:
Code:
lda bullet_y
eor #%11100000 ;check check for row 240 or row 0. If there, delete the bullet from the index and screen...
bne +
lda bulletindex
and #%11111110
sta bulletindex
lda #0
sta sprite+4
sta sprite+7
eor #%11100000 ;check check for row 240 or row 0. If there, delete the bullet from the index and screen...
bne +
lda bulletindex
and #%11111110
sta bulletindex
lda #0
sta sprite+4
sta sprite+7
The problem is that when the bullet is flying faster, i think, is that it skips over more numbers and may skip row 240 and row 0 causing it to flying again across the screen.
What can be done to make sure that the bullet never crosses the boundary of the screen, no matter how fast it is flying? Maybe it might work to subtract the previous row from the current row and if it's higher or lower than some number, don't let it pass?