Game design 101 - questions

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Game design 101 - questions
by on (#66725)
So I'm working on an Arkanoid clone (with powerups, enemies, etc) as a programming practice project. Using XNA/C# to do it (because I know C# and dot net).

What is a good method to detect which side of the block the ball hit (either X or Y) to reflect the balls corresponding velocity (either X or Y).

Its a little different than the normal collision detection I'm used to. When it normally doesn't matter where the object was hit.

Something like this must be used for Super Mario Bros, as Mario dies if he hits a goomba from the side, but not if it is on the head.

by on (#66726)
SMB1's hit detection acts much like Balloon Fight: based on relative position. If Mario's feet are high enough, he will defeat the enemy even if he is on the way up.

What you probably need to do is move the ball in the Y direction, check for overlap, flip DY if necessary, then move the ball in the X direction, check for overlap, flip DX if necessary.