MysticTrunks
Member
For RPGs collisions are rather easy as you're only checking either 4 or 8 ways, in a advanced platformer you probably have a physics script running in the background(some betas show curvy lines, diagonals lines etc for showing off their physics scripts)
But today let's worry about the basics, if you can think how something works you can make it work but it's not always the best way to do it.
place_free(x,y)
For an any game this is essential as this is how we check if we;re near a solid, if we're touching solids we just stop movement by "speed=0;" course you may use hspeed/vspeed as well.
Here is just a simple way of moving a character down with collision checking.
It's basically the same way for all directions including diagonal directions, just make sure your using code for the right directions.
Direction Easy Guide
Down"South": +
Left"East": -
Right"West": +
Up"North": -
Now for example a diagonal direction. South-East.
Okay, I realize this is probably not the best tutorial ever written as it's far from it. But it get's right to the point without all the jibber jabber.
Enjoy!
But today let's worry about the basics, if you can think how something works you can make it work but it's not always the best way to do it.
place_free(x,y)
For an any game this is essential as this is how we check if we;re near a solid, if we're touching solids we just stop movement by "speed=0;" course you may use hspeed/vspeed as well.
Here is just a simple way of moving a character down with collision checking.
Code:
if (keyboard_check(vk_down)) {
if (place_free(x,y+8)) {
motion_set(270,2); // I generally use motion set instead of using hspeed/vspeed or X/Y mainly because I personally find it runs smoother.
}
else {
speed=0;
}
}
Direction Easy Guide
Down"South": +
Left"East": -
Right"West": +
Up"North": -
Now for example a diagonal direction. South-East.
Code:
if (place_free(x-8,y+8)) { // movement } else { speed=0; }
Enjoy!