Hello all,
I'm having a little problem I'm hoping some of you guys could help out with.
I'm trying to create an overworld map like Mario's overworld map for my little game. I'm doing this with invisible walls that stop the player leaving the path, this mostly works good but I'm having a problem with stopping the player at an intersection/crossroad.
For the player object:
//Create
movespd = 4;
spd = movespd;
//Step
//movement
if (up) {
direction = 90;
spd = movespd;
//collisions
if (spd > 0) {
var iwall;
switch (direction) {
// moving right
case 0:
x += spd;
iwall = instance_place(x, y, obj_block);
if (iwall != noone) {
spd = 0;
x -= bbox_right - iwall.bbox_left + 1;
}
break;
etc.
Movement works fine but the player doesn't stop at an intersection so I created an intersec object and placed it at the intersections with the following code:
if instance_place(x, y-31, obj_player) {
obj_player.spd = 0;
}
Here's the problem the player stops at an intersection/crossroad but when I try to move the player again it jumps 4 pixel in the given direction then stops. If I continue to try move it keeps jumping until I'm no longer having a collision with the intersec object then moves normally in the given direction.
I know what's causing the problem but I'm not to sure on how to fix it.
Any ideas?