Q
QuoteTheRobot
Guest
Hello, GameMaker Community. I've come across an issue in my attempts to create something. I've been following a series of videos describing how to make a platformer game, (Here's the link to the video of interest for this post:
) Anyways, a large error is occurring with my code. Oddly enough, it isn't with the code itself, rather, how it's used in-game. Whenever I attempt to fire, it appears to mess up where the bullets are coming from. Results are hard to pin down, but it always seems like bullets appear above the player. Or, if I'm firing downwards, they appear below the player. It's quite odd, and if you could give assistance, that would be great! Here's the coding that I used from the video:
oGun (Create):
firingdelay = 0;
recoil = 0;
oGun (Begin Step):
x = oPlayer.x;
y = oPlayer.y+10;
image_angle = point_direction (x,y,mouse_x,mouse_y);
firingdelay = firingdelay - 1;
recoil = max(0, recoil - 1);
if (mouse_check_button(mb_left)) && (firingdelay < 0)
{
recoil = 4
firingdelay = 5;
with (instance_create_layer(x,x,"Bullets",oBullet))
{
speed = 25;
direction = other.image_angle + random_range (-3,3);
image_angle = direction;
}
}
x = x - lengthdir_x(recoil,image_angle);
y= y- lengthdir_y(recoil,image_angle);
if (image_angle > 90) && (image_angle < 270)
{
image_yscale = -1;
}
else
{
image_yscale = 1;
}
oBullet (Post Draw):
if (place_meeting(x,y,oWall)) instance_destroy();
oBullet (Animation End):
image_speed = 0;
image_index = 1;
This is pretty puzzling, and if you could assist with fixing it up, that would be awesome! You can request other parts of the coding in comments below. Thanks, see you soon!
oGun (Create):
firingdelay = 0;
recoil = 0;
oGun (Begin Step):
x = oPlayer.x;
y = oPlayer.y+10;
image_angle = point_direction (x,y,mouse_x,mouse_y);
firingdelay = firingdelay - 1;
recoil = max(0, recoil - 1);
if (mouse_check_button(mb_left)) && (firingdelay < 0)
{
recoil = 4
firingdelay = 5;
with (instance_create_layer(x,x,"Bullets",oBullet))
{
speed = 25;
direction = other.image_angle + random_range (-3,3);
image_angle = direction;
}
}
x = x - lengthdir_x(recoil,image_angle);
y= y- lengthdir_y(recoil,image_angle);
if (image_angle > 90) && (image_angle < 270)
{
image_yscale = -1;
}
else
{
image_yscale = 1;
}
oBullet (Post Draw):
if (place_meeting(x,y,oWall)) instance_destroy();
oBullet (Animation End):
image_speed = 0;
image_index = 1;
This is pretty puzzling, and if you could assist with fixing it up, that would be awesome! You can request other parts of the coding in comments below. Thanks, see you soon!