Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Help with sprite collisions

Author
Message
real
User Offline
Joined: 17th Mar 2019
Location:
Posted: 13th Apr 2019 18:45
I wanted to make a breakout game, the game is almost complete but I'm struggling to figure out how to code in side collisions for the game. I want to make it so that if the ball hits the left or right side of a block, it will change the horizontal direction (whether it goes right or left) but wont change the vertical direction (whether it goes up or down), and if the ball hits the top or bottom of the block its vertical direction will change, but its horizontal wont.
This is roughly what I have for those collisions right now, but the if statement is never true (the ball is never at the correct x position when it hits a block)



If anyone could help me out, it'd be greatly appreciated.
PSY
Valued Member
2
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 13th Apr 2019 23:04 Edited at: 13th Apr 2019 23:05
Basically, you need to check 4 events ( above, below, left and right )
Pseudocode ( after collision has taken place ):




PSY


PSY LABS Games
Coders don't die, they just gosub without return

Login to post a reply

Server time is: 2019-04-19 04:11:19
Your offset time is: 2019-04-19 04:11:19