# Collisions maths

0 favourites
• 3 posts
• I'm currently working out maths I've written for game maker and the functions should transfer over but I also love to have confirmation especially before jumping in and creating plugins if it's not worth the effort.

The game well I should say kit I'm planning is Seiken Densetsu 3, now it's sad that C2 doesn't have scripting but it does have an SDK but for plugins.... I don't know if I can write mode7 in a plugin but if I can please let me know as C2 should be at this point as powerful for 2D games as the PS2 considering the PS2 SDKs were out in the late 90s to developers.

On to the collision maths.

degree = radtodeg(arctan2(vec1.y - vec2.y, vec2.x - vec1.x));

Now the vec1 variable would be for the player (or ally who is attacking) and vec2 is for the enemy on screen.

Remember when you played zelda or seiken densetsu? If you say it the enemy on the lower portion he would move back diagonal up, the opposite would be diagonal down, smack dab in the middle would just be pushed back in the opposite direction.

Any easy way without diving into the sdk to port this over?

• Im not sure what any of what you posted has to do with collisions.

It looks more like you are trying to set up a movement.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Well, mode7 can be done with an effect for the visual portion.

http://www.scirra.com/forum/effect-mode7_topic61959.html

adtodeg(arctan2(vec1.y - vec2.y, vec2.x - vec1.x));

The calculation to find the angle from one point to another is made simple with the angle() function in c2. So to get the angle from the player to the enemy the expression would be:

angle(player.x, player.y, enemy.x, enemy.y)

I take it you want a "knockback" like collision response. With a quick search I found:

http://www.scirra.com/forum/how-to-make-a-simple-sprite-knockback-in-8-dir_topic53242.html

In my opinion it's not necessary to utilize the SDK unless there is something that you can't do with events. One typical situation that comes to mind is the need to interface with an outside library of some kind. Another reason could be to assist in some graphic effect that you can't do with existing plugins. However outside of that you can do pretty much anything in events.

• 3 posts